Lumen is a statically‑typed, compiled language. You write TypeScript‑style source; it type‑checks, lowers to Zig, and builds a small native binary.
Familiar syntax, fixed static types, no runtime — just a native executable.
interface Point {
x: int;
y: int;
}
function distanceSq(a: Point, b: Point): int {
let dx = a.x - b.x;
let dy = a.y - b.y;
return dx * dx + dy * dy;
}
let origin: Point = { x: 0, y: 0 };
let p: Point = { x: 3, y: 4 };
console.log(`distance² = ${distanceSq(origin, p)}`); // distance² = 25
A predictable static subset of TypeScript — no prototypes, no eval, no dynamic shapes.
Local inference, int/i64/number/bool/string, float & hex/binary literals.
Closed object shapes, nested records, arrays of records, enums.
if/else if, while, do, C‑style for, for…of, switch, ternary.
T | null, optional ? fields, ??, ?., and if (x != null) narrowing.
Function types, arrow functions, and capturing closures.
Fields, constructor, this, and methods — instances lower to heap structs.
`hi ${name}` with string & numeric interpolation.
Zig‑style scope‑exit cleanup, last‑in‑first‑out.
test "…" { expect(…); } run with lumen test on Zig's test runner.
extern function + // @link call native C libraries — and C++ via an extern "C" shim.
Compiles through Zig to a small, fast, dependency‑free binary.
Capture locals by value — lowered to a heap environment, no GC.
function makeAdder(n: int): (x: int) => int {
return (x: int) => x + n;
}
let add10 = makeAdder(10);
console.log(add10(5)); // 15
let factor = 3;
let nums: int[] = [1, 2, 3];
for (const v of nums) {
console.log((v: int) => v * factor); // closes over `factor`
}
Fields, a constructor, this, and methods — instances are heap structs.
class Counter {
count: int;
constructor(start: int) {
this.count = start;
}
increment(): void {
this.count += 1;
}
get(): int {
return this.count;
}
}
let c = new Counter(5);
c.increment();
console.log(c.get()); // 6
Declare an extern function and link a C library — no bindings generator, no runtime.
// @link m
extern function pow(base: number, exp: number): number;
extern function sqrt(x: number): number;
let hypotSq = pow(3.0, 2.0) + pow(4.0, 2.0);
console.log(sqrt(hypotSq)); // 5
console.log(pow(2.0, 10.0)); // 1024
extern "C" shimZig links the C ABI, so expose the C++ you need behind extern "C", then link the object.
// geometry.cpp
extern "C" int rectangle_area(int w, int h) { return w * h; }
// demo.ts
// @link ./geometry.o
extern function rectangle_area(w: int, h: int): int;
console.log(rectangle_area(6, 7)); // 42
V1 FFI passes scalar arguments (int, i64, number, bool).
This links local/system libraries — it is not a package manager.
Requires Zig 0.16 on your PATH.
zig build
./zig-out/bin/lumen compile hello.ts
./hello
./zig-out/bin/lumen test math.test.ts
The generated Zig is an implementation detail — you think in the TypeScript-syntax source language, not in Zig.