Zith vs Rust

Both Zith and Rust offer memory safety without garbage collection, but they take different approaches.

Quick Comparison

Feature Rust Zith Winner
Memory Safety Borrow checker NRA ownership types Tie
Learning Curve Very steep Gentle Zith
Lifetimes Explicit annotations Implicit through types Zith
Error Handling Result/Option + macros Failable types + chain flow Zith
DSLs Macros only Contexts + words + macros Zith
State Machines External crates Built-in flow fn / markers Zith
Compile Time Slow Fast Zith
Ecosystem Large, mature Growing Rust
Beginner Friendly Zith
Native ECS (external crates) Built-in Zith

Key Differences

1. Ownership Model

// Rust: borrow checker with lifetimes
fn process<'a>(data: &'a mut Vec<i32>) -> &'a i32 {
    &data[0]
}
// Zith: ownership visible in types, no lifetimes
fn process(data: lend [i32]): view i32 {
    data[0]
}

2. Error Messages

// Rust
error[E0495]: cannot infer an appropriate lifetime
  --> src/main.rs:10:5
   |
10 |     fn get(&self) -> &i32 { &self.data }
   |     ^^^^^^^^^^^^^^^^^^^^^
   = note: first, the lifetime cannot outlive ...

// Zith
error[E005]: Invalid ownership modifier
  --> src/main.zith:10:8
   |
10 | let ref: lend i32 = data;
   |         ^^^^ Cannot create mutable reference while other references exist
   | = help: Use 'view' for read-only access

3. Syntax Complexity

// Rust: many special keywords
let x: Box<dyn Iterator<Item = i32> + 'static> = ...;

// Zith: more straightforward
let x: dyn Iterator(i32) = ...;

4. Generics

// Rust: powerful but verbose
fn process<T: Clone + Debug>(items: Vec<T>) -> Vec<T>
where T: PartialEq { items.clone() }

// Zith: cleaner
fn process<T>(items: [T]) -> [T]
    where T: Clone + Debug + PartialEq { items.clone() }

When to Choose Zith

When to Choose Rust

Code Comparison

Same Program in Both Languages

// Rust
use std::collections::HashMap;

fn main() {
    let mut scores: HashMap<&str, i32> = HashMap::new();
    scores.insert("Alice", 95);
    scores.insert("Bob", 87);

    for (name, score) in &scores {
        println!("{}: {}", name, score);
    }

    if let Some(alice_score) = scores.get("Alice") {
        println!("Alice scored: {}", alice_score);
    }
}
// Zith
fn main() {
    var scores = Map{ "Alice": 95, "Bob": 87 };

    for (name, score) in scores {
        @println("{name}: {score}");
    }

    if let alice_score = scores.get("Alice") {
        @println("Alice scored: {alice_score}");
    }
}

The Bottom Line

Zith is for developers who want memory safety without complexity, fast iteration, built-in features for games and DSLs, and a gentler introduction to systems programming.

Rust is for developers who need maximum safety guarantees, a mature ecosystem, production-proven track record, and platform diversity.


Next: Explore Use Cases