Basics

Variables

// No keyword needed (default mode) name = "Aether" age = 25 pi = 3.14159 active = true // Immutable (cannot reassign) let id = 42 // Compile-time constant const MAX_SIZE = 1024 // Explicit type annotation score: Float = 99.5 count: Int = 0

Comments

// Single line comment /* Multi-line comment */

Strict mode

#strict // All variables need keywords (let/const) and type annotations let name: Str = "Aether" let age: Int = 25

Types

TypeDescriptionExample
Int64-bit signed integer42
Float64-bit floating point3.14
NumAuto-promotes Int/Float5 or 5.0
BoolBooleantrue, false
StrUTF-8 string"hello"
CharUnicode character'A'
ByteUnsigned 8-bit0xFF
nilAbsence of valuenil
Sized numeric types
Int8 .. Int64Signed integersEmbedded/binary use
UInt8 .. UInt64Unsigned integersNetworking/bit ops
Float3232-bit floatAI tensors

Generics

SyntaxMeaningOther languages
Str[]List of stringsList<String>
Int[]List of integersArray<Int>
{Str: Int}Map / dictionaryMap<Str, Int>
User?Nullable / optionalOptional<User>
Set<Int>Set of integersHashSet<Int>
Result<T, E>Success or errorResult<T, E>
Tensor<Float32>AI tensor typetorch.Tensor

Generic functions and classes

def first<T>(items: T[]) -> T? { if items.is_empty() { return nil } return items[0] } class Stack<T> { items: T[] = [] def push(item: T) { items.append(item) } def pop() -> T? { return items.remove_last() } } // Constrained generics def sort<T: Comparable>(list: T[]) -> T[] { ... }

Strings

// Auto-interpolation (no f-prefix needed) name = "Aether" print("Hello, {name}!") print("2 + 2 = {2 + 2}") // Multiline text = """ This is multiline. Indentation auto-trimmed. """ // Raw string (no escaping) pattern = r"\d{3}-\d{4}" // Methods s = "Hello, Aether!" s.len() // 14 s.upper() // "HELLO, AETHER!" s.split(", ") // ["Hello", "Aether!"] s.contains("Ae") // true s.replace("Hello", "Hi") s[0..5] // "Hello" "-" * 40 // repeat names.join(", ") // join list

Control flow

// if / else if / else (no parens, braces required) if age >= 18 { print("Adult") } else if age >= 13 { print("Teen") } else { print("Child") } // if as expression status = if active then "ON" else "OFF" // Guard (early return) guard let value = data else { return Err("No data") } // Nil-safe chaining city = user?.address?.city ?? "Unknown"

Match (pattern matching)

// Replaces switch. Exhaustive checking. match status { "active" -> process() "banned" -> deny() _ -> print("Unknown") } // Ranges grade = match score { 90..100 -> "A" 80..89 -> "B" _ -> "F" } // Destructuring match result { Ok(value) -> print("Got: {value}") Err("timeout") -> retry() Err(msg) -> fail(msg) }

Loops

// for: iteration (Python-familiar) for item in items { print(item) } for i, item in items { print("{i}: {item}") } // built-in enumerate for i in 0..10 { print(i) } // range 0-9 for i in 1..=10 { print(i) } // inclusive 1-10 for i in 0..100 step 2 { print(i) } // stride for key, val in my_map { ... } // dict iteration // loop: repeat / while / infinite loop 5 times { print("Hello!") } loop while lives > 0 { play(); lives -= 1 } loop { msg = await receive(); if msg == "quit" { break } } // Controls break // exit loop next // skip iteration (replaces continue) next if x == 0 // one-liner guard break:outer // named break for nested loops // Parallel loop for url in urls |parallel: 10| { await fetch(url) } // Comprehensions squares = [x ** 2 for x in 0..10] evens = [x for x in data if x % 2 == 0] lookup = {name: score for name, score in results}

Functions

def greet(name: Str) { print("Hello {name}") } def add(a: Num, b: Num) -> Num { return a + b } // One-liner def double(x: Num) -> Num = x * 2 // No types (gradual) def quick(data) { return data.transform() } // Default params with : def connect(host: Str, port: Int = 8080) { ... } // Variadic def sum(*nums: Num) -> Num { return nums.reduce(0, (a, b) -> a + b) } // Async async def fetch(url: Str) -> Response { ... } // Lambdas nums.map(x -> x * 2) nums.filter { x -> x > 0 } // trailing closure // Tuple return (multiple values) def divide(a: Int, b: Int) -> (quotient: Int, remainder: Int) { return (quotient: a / b, remainder: a % b) } let (q, r) = divide(17, 5) // Decorators @gpu def kernel(data: Tensor<Float32>) -> Tensor<Float32> { ... } @cached(ttl: 60) def expensive() -> Data { ... }

Classes & OOP

// Class (reference type) class Dog { name: Str breed: Str age: Int = 0 init(name: Str, breed: Str) { self.name = name self.breed = breed } def bark() { print("{self.name} says Woof!") } } // Struct (value type, stack-allocated) struct Point { x: Float y: Float def magnitude() -> Float = sqrt(x**2 + y**2) } // Interface interface Serializable { def to_json() -> Str } // Implementation class User impl Serializable { pub name: Str priv balance: Float prot id: Int def to_json() -> Str { return json.encode(self) } } // Inheritance class Admin : User { role: Str = "admin" } // Computed property area: Float => width * height // Observed property temperature: Float = 20.0 { did_change(old, new) { if new > 100 { alarm() } } } // Lazy property lazy data: Data => expensive_load()

Enums

// Simple enum Direction { North, South, East, West } // With associated values (algebraic data types) enum Shape { Circle(radius: Float) Rect(w: Float, h: Float) def area() -> Float { match self { .Circle(r) -> PI * r ** 2 .Rect(w, h) -> w * h } } }

Error handling

// Result type def parse(s: Str) -> Result<Int, ParseError> { ... } // ? propagation def process() -> Result<Data, Error> { data = read_file("in.csv")? parsed = parse(data)? return Ok(parsed) } // try / catch / finally try { data = risky_op() } catch IOError as e { print("IO: {e.message}") } catch any as e { print("Unknown: {e}") } finally { cleanup() } // Nil coalescing name = user?.name ?? "Anonymous"

Parallel blocks

parallel { users = fetch_users() orders = fetch_orders() stats = fetch_stats() } // Dependencies parallel { data = load() model = after(data) { train(data) } report = after(model, data) { evaluate(model, data) } } // Race (first wins, others cancel) result = parallel.race { fast = cache_lookup(id) slow = db_query(id) } // With timeout parallel(timeout: 5.seconds) { ... }

Collections

// List nums: Int[] = [1, 2, 3] nums.push(4) nums.map(n -> n * 2) nums.filter(n -> n > 2) nums.reduce(0, (a, b) -> a + b) // Map ages: {Str: Int} = {"Alice": 30, "Bob": 25} ages["Alice"] ?? 0 // Set ids: Set<Int> = {1, 2, 3} ids.union(other).intersect(another) // Tuple point = (10, 20) record = (name: "Alice", age: 30) let (x, y) = point

Math

// Constants (always available, no import) PI // 3.14159... E // 2.71828... TAU // 6.28318... (2π) INF // Infinity // Trig sin(x) cos(x) tan(x) asin(x) acos(x) atan2(y, x) // Powers sqrt(x) cbrt(x) pow(x, y) x ** y // Log log(x) log2(x) log10(x) // Rounding round(x) floor(x) ceil(x) trunc(x) // Comparison abs(x) min(a, b) max(a, b) clamp(x, lo, hi) // Random random() // 0.0..1.0 random(1, 100) // random int in range // Extended (use math) use math math.gcd(12, 8) math.factorial(5) math.is_prime(17)

File I/O

use fs // Read / write content = fs.read("data.txt")? fs.write("out.txt", "Hello")? fs.append("log.txt", "entry\n")? // Read lines for line in fs.lines("data.csv")? { print(line) } // Structured reading config = fs.read_json("config.json", as: Config)? data = fs.read_csv("data.csv")? // File operations fs.exists("file.txt") fs.delete("temp.txt")? fs.copy("src", "dst")? fs.mkdir("output/data")? // Path handling use path path.join("usr", "local", "bin") path.extension("file.tar.gz") // "gz"

Networking

use net.http // GET res = await http.get("https://api.example.com/users")? users = res.json(as: User[])? // POST res = await http.post("https://api.example.com/users", body: json({"name": "Alice"}), headers: {"Authorization": "Bearer {token}"} )? // Server use net.server app = Server() app.get("/users", def(req, res) { res.json(await db.all("users")) }) app.listen(8080) // WebSocket use net.ws socket = await ws.connect("wss://stream.example.com")? for msg in socket.messages() { match msg { .Text(data) -> process(data) } } // Database use db.sql conn = await db.connect("postgres://localhost/mydb")? users = await conn.query( "SELECT * FROM users WHERE age > $1", [18] )?

GPU computing

// Auto-detect hardware: NVIDIA, AMD, or WebGPU @gpu def matmul(a: Tensor<Float32>, b: Tensor<Float32>) -> Tensor<Float32> { return a ** b } // device blocks device(.gpu) { result = heavy_tensor_computation() } device(.cpu) { config = parse_json(file) } // Targets: CUDA PTX (NVIDIA), ROCm HIP (AMD), WebGPU WGSL (Browser)

Tensors & AI

use aether.tensor // Creation w: Tensor<Float32> = Tensor.random([784, 256]) b: Tensor<Float32> = Tensor.zeros([256]) // Operations result = w ** input // matrix multiply normalized = (data - data.mean()) / data.std() subset = data[0..100, :, 3..] // slicing // Autodiff loss = cross_entropy(pred, labels) grads = gradient(loss, for: model.params) // Neural network model Classifier { layers { dense(784, 128, activate: relu) dropout(0.3) dense(128, 10, activate: softmax) } }

Modules & packages

// Import use net.http use fs use json use math use aether.tensor use python.torch as torch // Python bridge // Define module mod utils { pub def helper() { ... } priv def internal() { ... } } // aether.toml // [project] // name = "my-app" // version = "1.0.0" // [dependencies] // aether/tensor = "^2.0"