Stages 0–4 — Foundation
Loon was bootstrapped from bare-metal x86-64 assembly with no external dependencies. The compiler is self-hosting, compiles to native code on five platforms, and enforces privacy types at compile time.
- Stage 0 — Hand-written assembly lexer
- Stage 1 — Hand-written assembly compiler
- Stage 2 — Self-hosting compiler in Loon-0
- Stage 3 — LLVM backend, WASM, Float, cross-platform
- Stage 4 — Privacy types, effect verification, 78/78 gauntlet
Stage 5 — Making Loon real
The compiler works. Now make the language usable for production programs. Rewrite the compiler in full Loon, build the standard library, add generics and closures.
5.0 — Compiler rewrite
The compiler is currently written in Loon-0, the bootstrap subset. Flat integer arrays instead of ADTs. Global state slots instead of typed variables. The rewrite uses everything Loon now has:
type AstNode {
FnDecl(name: String, params: List<Param>, body: Block),
LetBinding(name: String, value: Expr),
BinOp(op: OpKind, left: Expr, right: Expr),
Match(subject: Expr, arms: List<MatchArm>),
}
No more nd[ni * 10 + 3]. No more g[] slot collisions. The compiler becomes a demonstration of what Loon can do.
5.1 — Standard library
- Strings — substring, starts_with, index_of, contains, trim
- Option/Result — concrete types for Int, String, Bool
- Collections — List, Map, Set (needs generics)
- IO — file system, directories, streams
- HTTP — client and server (via FFI)
- JSON — parsing and serialization
- Time — dates, durations, formatting
Every package privacy-aware from the start. http.get() returns Result<Response, HttpError>. No panics, no null returns.
5.2 — Generics
type Option<T> {
Some(value: T),
None,
}
fn map<T, U>(opt: Option<T>, f: fn(T) -> U) [] -> Option<U> {
match opt {
Some(v) -> Some(f(v)),
None -> None,
}
}
Monomorphization — each concrete instantiation generates specialized code. The type checker verifies generic constraints.
5.3 — Closures
let double = fn(x: Int) [] -> Int { x * 2 };
let result = [1, 2, 3] |> List.map(double);
Closures capture their environment by value. The privacy type system applies to captures — a closure can't capture a Sensitive value and pass it to a non-Audit function.
Stage 5 continued — Performance & platform
5.4 — Garbage collector
The bump allocator works for small programs. For long-running servers, memory needs to be reclaimed. Mark-and-sweep first, generational later. ZeroOnDrop values are zeroed before the GC reclaims them.
5.5 — Parallel by default
// These run in parallel — pure functions are safe
let a = expensive_computation_1();
let b = expensive_computation_2();
let c = a + b; // waits for both
// Explicit sequence when order matters
sequential {
do write_header();
do write_body();
}
The effect system makes this safe. Pure functions can always run in parallel. IO functions need explicit sequencing. The compiler enforces it.
5.6 — FFI ✓
Call C libraries from Loon. extern fn declarations are implemented — the compiler emits extern directives that the linker resolves. The FFI boundary uses the Unsafe:TrustBoundary effect.
extern fn sqlite3_open(path: String)
[IO, Unsafe:TrustBoundary] -> Result<DbHandle, Error>;
Stage 6 — The full mission
6.0 — Device types
type Tensor<T>[Device] {
data: Array<T>,
shape: List<Int>,
}
fn matmul(
a: Tensor<Float32>[GPU:0],
b: Tensor<Float32>[GPU:0]
) [Compute:GPU] -> Tensor<Float32>[GPU:0]
// Compile error — CPU tensor where GPU expected
let cpu_tensor: Tensor<Float32>[CPU] = ...;
matmul(cpu_tensor, gpu_tensor); // ERROR
The same structural safety that applies to privacy types applies to computation devices. An AI agent writing GPU kernels can't accidentally mix CPU and GPU tensors.
6.1 — LSP rewrite
The LSP server rewritten in Loon. The compiler becomes a library. Inline errors as you type. Hover shows types including privacy level. Autocomplete respects effect boundaries.
6.2 — Package registry
The real ecosystem. Official and community tiers under the MPLS License. The crypto package becomes a full cryptography library where the types are the documentation and the enforcement.
How we'll know it's working
Give five different AI models the same security-critical prompts. Run their output through the Loon compiler. Measure what gets caught. Publish the results.
When AI agents writing Loon produce demonstrably safer code than AI agents writing Python — Loon is ready for the world.