
machin ⎯ Machine-First Language (MFL)
A language shaped for AI agents to write and edit cheaply: zero type annotations, one canonical declaration per line, every design choice measured for token cost. Compiles through C to a single native binary — C/Rust-class speed, unboxed values, no runtime.
Spec · Language tour · Agent guide · Contributing · Ecosystem → awesome-machin · Landing · Releases
Write MFL, hit Run — it compiles to WebAssembly and runs client-side. No install.
🧬 machin is written in machin — a self-hosting compiler
The whole toolchain — lexer, parser, type checker, C code generator, and encode /
build / run — is written in machin (selfhost/, ~4k lines). It
compiles its own source back into itself, and the rebuild reproduces itself
byte-for-byte — a genuine compiler fixpoint — at ~0.9× the original's speed. A
language mature enough to build itself from scratch, verified to the byte. Every stage
was built against a byte-diff oracle, which flushed out three real compiler bugs along
the way. CI enforces it on every push — the fixpoint, a 415-program codegen
oracle diffed against the reference compiler, and the embedded runtime being in
sync — so this is a checked claim, not a milestone someone once reached. See
selfhost/ and BOOTSTRAP.md.
Same service, measured
The pitch in one table. The same REST + SQLite API (POST / GET / DELETE /notes) written idiomatically in each language, then measured for what actually
costs an AI agent: tokens to write, and tokens to edit. All three build and
pass the same CRUD test (bench/rest-sqlite).
| author tokens | edit tokens | ships as |
|---|
| machin | 388 | 290 | 44 KB static binary · 0 deps |
| Go | 527 · 1.36× | 329 · 1.13× | 14.8 MB binary + module deps |
| Python | 383 · 0.99× | 332 · 1.14× | source + CPython interpreter |
machin is as terse as Python to write, ~36 % cheaper than Go, lowest on
edit cost — and the only one that ships as a single 44 KB native binary with
SQLite, the HTTP server, and the router built in. No interpreter, no go mod,
no container. Write it like a script, ship it like C. That combination — not a
raw token count — is the whole idea. (o200k_base; cl100k_base gives the same
ranking. Reproduce: python3 bench/rest-sqlite/measure.py.)
…and then it ships in a way an interpreter can't (bench/cold-start):
| same HTTP server | deployable image | cold start | idle RSS |
|---|
machin (static, FROM scratch) | 92.9 kB | 0.49 ms | 108 kB |
Node (.js + node:alpine) | 178 MB · 1916× | 28.9 ms · 59× | 51 MB · 477× |
Python (.py + python:alpine) | 47.6 MB · 512× | 49.1 ms · 100× | 17.9 MB · 166× |
A 92.9 kB image — the binary and nothing else — that's serving traffic in half a
millisecond on ~0.1 MB of RAM.
Why
Every mainstream language was designed for human ergonomics — readable syntax, explicit types, multi-line formatting. For an AI agent, every output token costs, and that human-friendly ceremony taxes the writer without adding meaning. machin measured this: tools/tokcost.py showed base64 source costs ~2.5× the tokens to output; whitespace alone costs ~13%. The canonical one-line-per-declaration form, with every type inferred, is the end of that measurement — the smallest token surface that still produces C/Rust-class native code with zero runtime overhead.
Measurement