# Aether 0.0.1-stable > Aether is a small statically typed systems language with checked ownership, explicit effects and named traps. Compiler: aetherc (Python 3.9+). Install: curl -fsSL https://aether.presenceorbit.com/install.sh | sh ## Docs (Vietnamese) - [Giới thiệu](https://aether.presenceorbit.com/docs/gioi-thieu/): docs/guide/01-gioi-thieu.md - [So sánh với ngôn ngữ khác](https://aether.presenceorbit.com/docs/so-sanh/): docs/guide/02-so-sanh.md - [Định hướng sử dụng](https://aether.presenceorbit.com/docs/dinh-huong/): docs/guide/03-dinh-huong.md - [Cài đặt](https://aether.presenceorbit.com/docs/cai-dat/): docs/guide/04-cai-dat.md - [Hướng dẫn lập trình](https://aether.presenceorbit.com/docs/lap-trinh/): docs/guide/05-lap-trinh.md - [Trình biên dịch](https://aether.presenceorbit.com/docs/trinh-bien-dich/): docs/guide/06-trinh-bien-dich.md - [Phát triển trình biên dịch](https://aether.presenceorbit.com/docs/phat-trien/): docs/guide/07-phat-trien.md - [Hướng dẫn cho AI](https://aether.presenceorbit.com/docs/cho-ai/): docs/guide/08-cho-ai.md - [Phát hành và Cloudflare](https://aether.presenceorbit.com/docs/phat-hanh/): docs/guide/09-phat-hanh-web.md - [Aether và Rust](https://aether.presenceorbit.com/docs/aether-va-rust/): docs/guide/10-aether-va-rust.md ## Optional - [llms-full.txt](https://aether.presenceorbit.com/llms-full.txt): all guide pages in one file - [AGENTS.md](https://aether.presenceorbit.com/AGENTS.md): coding rules for assistants ## Coding rules Aether is a small statically typed language. Write only the syntax below; it is not Rust or Go. Check every file with `aetherc verify FILE [flags]` and run it with `aetherc eval FILE --result-protocol` (or `eval-ssa` when buffers are used) before reporting success. ## Program shape - Entry point: exactly `fn main() -> i32 { ... }`. - Functions: `fn name(a: i32, b: i64) -> bool { ... }`; generics `fn f(x: T) -> T`, called as `f::(x)`. - Every path returns. A `while` loop is never assumed to end: put a `return` after it. - `;` is optional. Comments: `//`. ## Types - Scalars: `i32`, `i64`, `bool`. No unsigned, float, char or string types. - Integer literals are `i32` (0..2147483647). Use `i64(x)` / `i32(x)`; no implicit conversion. - Fixed arrays: `array_i32_3(1, 2, 3)`, `[0; 8]`, type `[i32; 3]`; read `at(a, i)`, length `length(a)`, update copy `with_at(a, i, v)`. - Tuples (2–3 scalars): `tuple(a, b)`, read `first(t)`, `second(t)`, `third(t)`. - `struct P { x: i32, y: i32 }`, build `P(1, 2)`, read `p.x`. Declare before use. - `enum E { A: i32, B: (i32, i32) }`, build `E.A(1)`, dispatch `match_enum(e, on_a, on_b)`. - Strings only inside `length("...")` or `at("...", i)` (UTF-8 bytes). ## Statements - `x := expr`, `let x: T = expr`, `mut x := expr`, `let mut x: T = expr`, `x = expr` (mutable only). - `if cond { } else { }` (no `else if`: nest), `while cond { }`, `return expr`. - No `for`, `break`, `continue`, `match`, `+=`, closures, methods, traits, macros. - A call whose result is unused must still be bound: `ignored := f()`. - `comptime(expr)` folds a closed constant expression. ## Operators `|| && == != < <= > >= + - * / %`, unary `- !`. Integer arithmetic wraps. Division by a runtime zero traps (`trap:division-by-zero`, exit 125); a literal zero divisor is a compile error. ## Reserved names (never use as variables) `first second third at length slice with_at tuple match_enum own move borrow borrow_mut borrow_field borrow_mut_field load store comptime extern struct enum fn pub module return let mut if else while true false` and type names. ## Ownership - `c := own(v)`, `m := move(c)`, `r := borrow(c)`, `w := borrow_mut(c)`, `load(r)`, `store(w, v)`. - These must initialize an immutable local. Owners/references cannot be copied, reassigned, returned or stored. - Exclusive borrow conflicts with any other borrow; no move while borrowed; no use after move. - Borrows last to the end of the block unless `--nll` is passed. ## Opt-in features (state the flags in a header comment) - `--nll`: reference parameters `ref_i32`, `mutref_i32`, … and early borrow expiry. - `--dynamic-buffers`: `buffer_new(n)`, `buffer_len(b)`, `buffer_get(b, i)`, `buffer_set(b, i, v)` (i32 only). - `--owned-signatures` (with `--dynamic-buffers`): `own_buffer_i32` parameters/returns; pass `move(b)`, return `return move(b)`. - `--host-io`: `input_len()`, `input_byte(i)`, `output_byte(b)`. - `--module-root DIR`: `module a.b;` then `import c.d;` → file `DIR/c/d.ae`. - `extern "C" { fn f(x: i32) -> i32; }` and `extern "C" fn g(x: i32) -> i32 { }`: native backend only, `bool`/`i32`/`i64` only. ## Build `aetherc build FILE --backend c-aggregate --release -o out` (full language); `--backend native --target linux-x64|macos-arm64|win-x64|...` (scalar + FFI). ## Porting from Rust - Check scope first: `String`, `Vec` (T other than i32), `HashMap`, traits, closures, iterators, floats, unsigned/`usize` business values, threads, `async` are not available in 0.0.1. Say so; do not emulate with wrong semantics. - Arithmetic always wraps (Rust's `wrapping_*`); Rust debug-mode overflow panics have no equivalent; add explicit checks if the Rust code relies on them. `i32::MIN / -1` wraps instead of panicking. - `for i in 0..n` → `while`; `a[i] = v` → `a = with_at(a, i, v)`; `match` on enums → `match_enum`; `Option`/`Result` → declare an `enum`; methods → free functions; `&mut` parameters → `--nll` with `mutref_*`; returned references → return values. - Compare `aetherc eval --result-protocol` output with the Rust program on the same input before reporting success.