A Tour of Zeta
Learn the language in minutes
A hands-on introduction to Zeta's minimalist, high-performance syntax.
Hello, Zeta!
Every Zeta program starts with a main function. Save this as hello.z:
fn main() {
println!("Hello, Zeta!");
}
// → ~7 kB static binary
// Zero-cost abstractions
// First-principles design
Compile and run:
zeta hello.z → produces a.out
./a.out → Hello, Zeta!
Variables & Types
Variables are immutable by default. Use mut for mutability. Full type inference.
let x = 42; // immutable i32 (inferred)
let mut y = 100; // mutable
y += 1;
let name: str = "Zeta"; // explicit owned UTF-8 string
let pi: f64 = 3.14159;
let flag: bool = true;
Functions
Functions support full and single-line forms. Explicit return via return or last expression.
fn add(a: i32, b: i32) -> i32 {
return a + b;
}
// Single-line form
fn mul(a: i32, b: i32) -> i32 = a * b;
let result = add(mul(3, 4), 5); // 17
Dictionary Literals
Built-in heterogeneous maps with concise literals.
let config = {
"host": "localhost",
"port": 8080,
"debug": true,
};
println!(config["host"]); // localhost
config["port"] = 9090; // mutable access
Error Propagation
Simple, expressive error handling with the ? operator.
fn might_fail() ? "something went wrong" {
// some operation
}
fn main() {
might_fail()?; // propagates error if any
println!("success");
}
AI-Driven Optimization
Unique to Zeta - let Grok rewrite hot code paths at compile time.
#[ai_opt]
fn heavy_computation(data: vec<f64>) -> f64 {
// complex numeric work - Grok may vectorize or fuse
data.sum()
}
M:N Green-Thread Actors
Zeta provides lightweight M:N actors with channels. The entire runtime is under 200 LOC and delivers unbeatable concurrency performance.
fn main() {
let (tx, rx) = channel();
spawn move || {
tx.send("ping");
};
println!(rx.recv()?); // prints "ping"
}
// 100k ping-pong bench: 0.94 ms (50% faster than competitors)
CacheSafe TBAA
Zeta's type system enforces strict type-based alias analysis (CacheSafe) automatically, enabling LLVM to apply maximum vectorization and SIMD without manual hints.
fn vector_add(a: mut [f32], b: [f32]) {
for i in 0..a.len() {
a[i] += b[i];
}
}
// CacheSafe guarantees no aliasing → LLVM auto-vectorizes fully
// No unsafe, no attributes required
Algebraic Semiring CTFE + Fusion
Compile-time evaluation uses algebraic semiring properties to automatically fuse operations (e.g., map-reduce, matrix chains) into optimal single passes.
comptime {
let data = [1, 2, 3, 4, 5];
// x2 map reduction fused into a single loop at compile time
const TOTAL = data.map(|x| x * 2).sum();
println!(TOTAL); // 30 — computed at compile time
}
Targeting WebAssembly
Zeta compiles natively to WASM. Use the --target wasm32-unknown-unknown flag for browser-ready modules with no runtime.
fn main() {
println!("Hello from Zeta in the browser!");
}
// Compiles to ~4 kB WASM module
// Instantiates instantly, zero overhead
Try compiling and “running” this exact program in WASM mode in the Playground.
What’s Next?
You’ve seen Zeta’s core philosophy in action: extreme minimalism delivering unmatched performance.
Dive deeper in the Documentation or explore the GitHub repository for the latest source and benchmarks.