Getting Started
Build the pure Odin compiler, write your first effect-inferred .exp module, and inspect zero-overhead ES2022+ JavaScript, strict .d.ts, and C99 output.
Build the Odin compiler
The exp compiler is written in pure Odin with zero external native compiler
dependencies — no LLVM, no C++ toolchain, and no Node.js required to compile .exp
into JavaScript or C99. A stripped release binary weighs 2.14 MB and compiles
at 636,000 LOC/s on a single core.
# Build the standalone Odin release compiler (2.14 MB, zero LLVM / C++ deps)
odin build src -out:build/exp-release -o:speed
# Typecheck, emit ES2022+ .mjs + strict .d.mts/.d.ts + Source Map v3
exp build hello.exp --target=js --out-dir dist
# Or emit standalone C99 from the exact same verified Core IR
exp build hello.exp --target=c --out-dir dist
# Print inferred types, error constructors, and effect rows
exp sig hello.exp Your first .exp module
Notice that no type annotations are required on area or totalArea.
Hindley–Milner inference resolves exact parameter types, checks pattern exhaustiveness with
Maranget's algorithm, and proves both functions pure. Hover any symbol below, inspect the
JavaScript, .d.ts, C99, and
exp sig tabs, or click Run.
export type Shape
Circle(radius: Float)
Rect(w: Float, h: Float)
end
--- Compute the area of any Shape using exhaustive pattern matching.
export fn area(shape)
match shape with
Circle(r) then Float.pi * r * r
Rect(w, h) if w == h then w * w
Rect(w, h) then w * h
end
end
export fn totalArea(shapes)
sum = 0.0
for s in shapes do
sum = sum + area(s)
end
sum
end
fn main()
shapes = [Circle(2.0), Rect(3.0, 3.0), Rect(4.0, 2.5)]
print("total area = {totalArea(shapes):.2}")
endCompile to JS, .d.ts, and C99
Every frontend pass — name resolution, HM + row inference, restrictable error subtraction, compile-time handler wiring, Maranget match compilation, escape analysis, and affine drop elaboration — finishes before producing one verified, target-neutral Core IR.
- JavaScript backend (
--target=js): emits ES2022+ ESM, Source Map v3, and strict TypeScript.d.tsdeclarations verified undertsc --noEmit --strict. - C99 backend (
--target=c): consumes the unchanged Core IR to emit standalone C99, proving zero JavaScript-specific leakage in the frontend or IR. -
T0reference evaluator (exp eval/exp test): an independent CESK interpreter over Core IR with a deterministic virtual clock used as the semantic oracle for differential verification.
Test & verify with T0
Tests live right beside your code in test("...") do ... end blocks. Concurrent
tests using Async.sleep and Async.timeout advance instantaneously on
the built-in virtual clock without sleeping in real wall time.
# Run test(...) blocks with the deterministic virtual clock
exp test app.exp
# Execute directly via the independent T0 reference evaluator
exp eval hello.exp
# Audit public signature & capability changes between revisions
exp diff old_api.exp new_api.exp Day-to-day CLI workflow
| Command | Purpose |
|---|---|
exp check --json <file> | Type, effect, and linearity check with stable codes (E0001–E0060) and machine-applicable fixes. |
exp build <file> | Compile to ES2022+ JS + .d.ts + .js.map (or --target=c). |
exp sig <file> | Print inferred top-level signatures in valid round-trippable .exp annotation syntax. |
exp fmt --write <file> | Single canonical layout with zero style options; idempotent and refuses invalid syntax. |
exp fix --write <file> | Apply semantics-preserving machine edits (including JS/TS/Effect-TS foreign idiom rewrites). |
exp lsp / exp mcp | Event-driven Language Server and Model Context Protocol server sharing one incremental compiler session. |