Skip to main content
BookintermediatePaid

Writing a C Compiler: Build a Real Programming Language from Scratch

by Nora Sandler · No Starch Press

A guided project in 792 pages: compile the smallest valid C program to x64 assembly, then add one language feature per chapter through types, pointers, structs and dynamic memory. Uses language-agnostic pseudocode plus a public open-source test suite.

Visit resource

This link may earn us a small commission at no extra cost to you. Affiliate disclosure

More resources on Compilers & Interpreters

WebsiteFree

My First Language Frontend with LLVM (Kaleidoscope Tutorial)

LLVM's official ten-chapter tutorial builds Kaleidoscope in roughly 1,000 lines: lexer, recursive-descent parser with operator precedence, LLVM IR generation, a JIT, control flow, mutable variables, object-file emission and DWARF debug information.

Book

Engineering a Compiler (3rd Edition)

Cooper and Torczon's 848-page textbook treats each compiler pass as an engineering problem with explicit tradeoffs: scanning, parsing, semantic elaboration, intermediate representations, SSA-based optimisation, instruction selection, scheduling and register allocation. Third edition adds chapters on runtime naming and code shape.

CourseFree

Cornell CS 6120: Advanced Compilers (Self-Guided)

Adrian Sampson's PhD-level course, released for self-study with videos, notes, assigned papers and implementation tasks. Fourteen lessons cover intermediate representations, dataflow analysis, SSA, loop optimisation, alias analysis, memory management and JIT compilation, using LLVM and the teaching IR Bril. Bril keeps implementation tasks tractable in any language while the LLVM tasks touch a production toolchain.

CourseFree

Stanford CS143: Compilers

Stanford's undergraduate compilers course, with public lecture slides, written assignments and solutions, and five programming assignments that build a working compiler for Cool, a small object-oriented language, targeting MIPS assembly.

BookFree

Crafting Interpreters

Robert Nystrom builds the Lox language twice: first a tree-walking interpreter in Java, then a bytecode virtual machine in C, covering scanning, parsing, resolution, closures, classes and garbage collection. The complete text is free online.

See all Compilers & Interpreters resources →