0003. Emit C first; the interpreter is the reference
- Status: Accepted
- Date: 2026-10-29
- Plan: M1.5, M3.3–M3.6, M8.2–M8.4, M8.7
- Review: Compiler and backend
Context
Measured on the MVP, emitted C ran 2–61× faster than Python and started in 1.7 ms. The original decision list also carried VM decisions (typed slots, specialized bytecode) left over from an earlier VM-first plan, plus a long optimizer roadmap.
Decision
- The C backend is the first and main execution tier.
- A simple interpreter over the typed IR is the reference semantics. It is the oracle for differential tests and the sandbox that runs generators with fuel.
- No VM bytecode tier. No LLVM or JIT until a measurement asks for one.
- Harness performs only optimizations a C compiler cannot: arena
placement, uniqueness reuse, destination passing, schema
specialization, bounds and overflow facts, byte-class tables.
Scalar replacement, inlining, jump tables, unrolling and strength
reduction are left to gcc and clang, and emitted C helps them
(
restrict,cold, simple counted loops). - Emitted C preserves Harness's left-to-right evaluation by hoisting calls into temporaries, because C leaves operand order unspecified.
Alternatives considered
- VM first — more work than a C backend, slower, and needs a JIT to compete.
- LLVM first — a heavy dependency and slow builds; nothing measured needs it.
Consequences
Building a Harness program needs a C compiler, and CI tests
both gcc and clang. A fast dev path (in-process TinyCC, or
-O0 per-module builds) keeps agent edit-run loops
short; see the tcc-run experiment and M8.7.