← session · LOG ENTRY ·
Building a language twice: treewalk vs bytecode
In college I led a five-person team building a toy language, and we implemented it twice: once as a treewalk interpreter, once as a bytecode VM. Same language, same tests, two execution models. It placed top-3 in the campus hackathon (twenty-plus Project Euler problems solved in our own language, under two hours), but the durable value was the comparison itself.
The treewalk version is the honest one: walk the AST, evaluate as you go. Trivial to write, trivial to debug, and slow, every execution re-traverses structure that never changes. The bytecode version pays an upfront compile to a flat instruction stream, then executes in a tight loop. Same semantics, an order of magnitude apart, and the gap comes entirely from doing work once instead of every time.
That compile-once-execute-many split turned out to be the shape of half the systems I've built since. The YAML workflow engine that runs production agents? Config compiles to an execution plan; the plan runs in a loop. Prompt caching? Literally 'stop re-evaluating the unchanging prefix.' Recognizing the pattern early, because I'd built both sides of it by hand, is the most compounding thing that project gave me.
Recommendation for anyone learning systems: build the naive version and the optimized version of the same thing, once. The delta is the education. Either alone teaches you a technique; the pair teaches you the trade.
— end of log entry. back to session · handoff to human