pawan

all books

cover of the first compiler

the first compiler

uops, rewrites and c, built from zero

a book on the first two weeks of geohot's compilers for machine learning course. you build a small compiler in python: a graph of arithmetic ops, rewrite rules that simplify it, a c renderer, and a runtime that compiles it with clang and runs it. it starts with a 14 step short path, one small program per step with its real output, then 16 deep chapters with exercises. every program in it was run. the compiler is checked against numpy and separate c code in over 2.1 million checks, 59 rewrite claims are settled with z3, and 19 deliberately planted bugs were all caught.

2026 · 198 pages · free pdf