Revisiting "Let's Build a Compiler"
Briefly

"I ran into it in 2003 and was very impressed, but it's now 2025 and this tutorial is still being mentioned quite often in Hacker News threads. Why is that? Why does a tutorial from 35 years ago, built in Pascal and emitting Motorola 68000 assembly - technologies that are virtually unknown for the new generation of programmers - hold sway over compiler enthusiasts? I've decided to find out."
"The tutorial is easily available and readable online, but just re-reading it seemed insufficient. So I've decided on meticulously translating the compilers built in it to Python and emit a more modern target - WebAssembly. It was an enjoyable process and I want to share the outcome and some insights gained along the way. The result is this code repository."
"To get a taste of the input language being compiled and the output my compiler generates, here's a sample program in the KISS language designed by Jack Crenshaw: var X=0 { sum from 0 to n-1 inclusive, and add to result } procedure addseq(n, ref result) var i, sum { 0 initialized } while i < n sum = sum + i i = i + 1 end result = result + sum end program testprog begin addseq(11, X) end ."
Jack Crenshaw's Let's Build a Compiler remains influential despite its 1988–1995 Pascal and Motorola 68000 focus. A complete port translates the tutorial's compilers into Python and targets WebAssembly, preserving the original compiler structure while modernizing the backend. The repository includes a TUTORIAL.md that maps each tutorial part to the new code, enabling readers to experiment with runnable examples. A KISS sample program demonstrates procedures, while-constructs, and by-reference parameter handling, and the emitted WASM reveals implementation subtleties. The port aims to make the tutorial's pedagogical value accessible to contemporary developers and tooling ecosystems.
Read at Thegreenplace
Unable to calculate read time
[
|
]