ShitRust

A programming language combining the best features from Rust, Python, and C/C++

Version 0.3.0

Features

ShitRust combines the best aspects of modern programming languages to deliver performance, safety, and developer productivity.

Memory Safety

Inspired by Rust, ShitRust provides strong memory safety guarantees without the complexity of a garbage collector.

High Performance

LLVM-based optimizing compiler that generates efficient native code with performance comparable to C/C++.

Modern Syntax

Clean, Python-inspired syntax that emphasizes readability while maintaining the expressiveness of systems languages.

Built-in Formatter

Integrated code formatter ensures consistent style across your codebase, eliminating style debates.

Async Support

First-class async/await syntax provides seamless asynchronous programming without callback hell.

Error Handling

Combination of Result types and try/catch blocks gives you flexibility in error handling approaches.

Traits & Interfaces

Powerful trait system allows for composition-based code organization with clear interfaces.

List Comprehensions

Python-style list comprehensions enable powerful, concise data transformations.

Pipeline Operator

Functional programming with pipeline operator for clean, readable data transformations.

Optional Chaining

Safely access properties deep in object hierarchies without worrying about null references.

Pattern Matching

Comprehensive pattern matching with destructuring, guards, and or-patterns for expressive code.

Generics

First-class generic types and functions for type-safe, reusable code components.

Module System

Robust module system with explicit imports and exports for better code organization.

Concurrency

Built-in concurrency primitives make parallel programming straightforward and safe.

Foreign Function Interface

Seamless interoperability with C/C++ libraries through a simple and safe FFI.

Built-in Testing

Integrated testing framework makes writing and running tests frictionless.

Static Analysis

Advanced static analysis catches bugs and ensures code quality before runtime.

Package Management

Integrated package manager simplifies dependency management and sharing code.

Installation

Getting started with ShitRust is easy. Follow these steps to install the compiler on your system:

bash
# Clone the repository
git clone https://github.com/Waowzar/shitrust.git
cd shitrust

# Build the compiler
./build.sh

# Install the binary (optional)
cargo install --path .

# Show help
shitrust --help
batch
# Clone the repository
git clone https://github.com/Waowzar/shitrust.git
cd shitrust

# Build the compiler
build.bat

# Install the binary (optional)
cargo install --path .

# Show help
shitrust --help

Build Script Options

The project includes build scripts for both Windows and Unix platforms with various options:

bash
# Show help
./build.sh help

# Build debug version
./build.sh

# Build release version
./build.sh release

# Clean build artifacts
./build.sh clean

# Run tests
./build.sh test

# Run examples
./build.sh examples

# Run benchmark with timing information
./build.sh bench

# Generate documentation
./build.sh docs
batch
# Show help
build.bat help

# Build debug version
build.bat

# Build release version
build.bat release

# Clean build artifacts
build.bat clean

# Run tests
build.bat test

# Run examples
build.bat examples

# Run benchmark with timing information
build.bat bench

# Generate documentation
build.bat docs

Examples

ShitRust's syntax is designed to be familiar to developers coming from Rust, Python, or C/C++. Here are some examples to help you get started:

Hello World

rust
// Hello World in ShitRust - A simple example

// Function to generate a greeting
fn generate_greeting(name: string) -> string {
    let greeting = "Hello, " + name + "!";
    return greeting;
}

// Main function - entry point of the program
fn main() -> void {
    // Basic println
    println("Hello, ShitRust World!");
    
    // Variables with type inference
    let name = "ShitRust";
    let version = 0.2;
    
    // String concatenation and method calls
    println("Welcome to " + name + " version " + version.to_string() + "!");
    
    // Conditional statement
    if (version < 1.0) {
        println("This is an early preview version.");
    } else {
        println("This is a stable release.");
    }
    
    // Function call
    let message = generate_greeting("Programmer");
    println(message);
}

Basic Syntax

rust
// Function definition
fn add(a: int, b: int) -> int {
    return a + b;
}

// Variables
let x = 5;          // Type inference
let mut y = 10;     // Mutable variable
let z: float = 3.14; // With type annotation

// Constants
const PI: float = 3.14159;
const MAX_SIZE: int = 100;

// Control flow
if x > y {
    println("x is greater");
} else {
    println("y is greater");
}

// Loops
while x > 0 {
    x = x - 1;
}

for i in 0..10 {
    println(i.to_string());
}

// Infinite loop with break
loop {
    if x > 10 {
        break;
    }
    x = x + 1;
}

// Match statement
match x {
    0 => println("Zero"),
    1 => println("One"),
    n if n < 10 => println("Single digit"),
    _ => println("Other"),
}

Advanced Features

rust
// Type aliases
type UserId = int;
type UserMap = HashMap;

// Generic struct
struct Point {
    x: T,
    y: T,
    
    fn distance_from_origin() -> float {
        return (this.x.to_float() * this.x.to_float() + 
                this.y.to_float() * this.y.to_float()).sqrt();
    }
    
    // Static method
    static fn origin() -> Point {
        return Point { x: T.from(0), y: T.from(0) };
    }
}

// Trait definition
trait Printable {
    fn print() -> void;
    fn debug_print() -> string;
}

// Implementing a trait
impl Printable for Point {
    fn print() -> void {
        println("Point(" + this.x.to_string() + ", " + this.y.to_string() + ")");
    }
    
    fn debug_print() -> string {
        return "Point { x: " + this.x.to_string() + ", y: " + this.y.to_string() + " }";
    }
}

// Result enum for error handling
enum Result {
    Ok(T),
    Err(E)
}

// Function returning a Result
fn divide(a: int, b: int) -> Result {
    if b == 0 {
        return Result::Err("Division by zero");
    }
    return Result::Ok(a / b);
}

// Async function with await
async fn fetch_data(url: string) -> Result {
    // Async code here
    await timing.sleep(1000);
    return Result::Ok("Data from " + url);
}

// Using async/await with error handling
fn process_data() -> void {
    try {
        let result = await fetch_data("https://api.example.com");
        match result {
            Result::Ok(data) => println("Success: " + data),
            Result::Err(err) => println("Error: " + err)
        }
    } catch e {
        println("Exception: " + e.to_string());
    }
}

// List comprehension
let numbers = [1, 2, 3, 4, 5];
let squares = [x * x for x in numbers if x % 2 == 0];

// Pipeline operator
let result = numbers 
    |> [x * 2 for x in _]
    |> _.filter(|x| -> bool { return x > 5; })
    |> _.sum();

// Optional chaining and nullish coalescing
let user = get_user(123);
let username = user?.name ?? "Unknown";
let isActive = user?.is_active() ?? false;

More Examples

Check out our full collection of examples to explore all of ShitRust's features:

View More Examples

Documentation

Comprehensive documentation is available to help you learn and use ShitRust effectively.

Getting Started

New to ShitRust? Start here to learn the basics and get your first program running.

Read Guide

Language Reference

Detailed documentation of ShitRust's syntax, types, functions, and standard library.

Explore Reference

API Documentation

Complete API reference for the ShitRust standard library and core modules.

View API Docs

Tutorials

Step-by-step tutorials to build real applications with ShitRust.

Start Learning

Generate Local Documentation

You can also generate comprehensive documentation locally using the build scripts:

bash
# Windows
build.bat docs

# Linux/macOS
./build.sh docs

# Documentation will be available at:
# target/doc/shitrust/index.html

About the Project

ShitRust is currently developed by a solo developer. Feel free to check out the GitHub repository for the latest updates.

Contributing

ShitRust is an open-source project, and contributions are always welcome! Check out the contribution guidelines to get started:

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add some amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request