Crafting Interpreters
A free online book that walks you through building two complete interpreters for a small scripting language, one in Java and one in C, explaining scanning, parsing, evaluation, bytecode, virtual machines and garbage collection along the way. It is the friendliest route to understanding how programming languages work.
11.1k
GitHub (munificent/craftinginterpreters) · Sept 2026
Book
Other
Robert Nystrom
Self paced
Intermediate
Free
What it is
Crafting Interpreters is a book by Robert Nystrom, who works at Google on the Dart language. It teaches how programming languages are implemented by building an interpreter for a small dynamically typed language called Lox, twice. The first interpreter, jlox, is a tree-walk interpreter written in Java and covers scanning, parsing with a grammar, syntax trees, evaluation, variables, control flow, functions, closures, classes and inheritance. The second, clox, is written in C and compiles to bytecode for a virtual machine, covering a hash table, a stack-based VM, single-pass compilation, closures and a garbage collector. The author says the whole web version is free to read.
Who it is for
Students taking or preparing for a compilers or theory course, and developers who want to understand what their language does under the hood. You should be comfortable programming in Java or a similar language for part one, and able to read and write C for part two.
Why it is worth your time
Compiler courses often stay theoretical, with grammars and automata on paper. This book connects the theory to working code: the scanner is a finite automaton in practice, the parser follows a context-free grammar, and the virtual machine shows how bytecode runs on a stack. Every line of code in the interpreters is in the book, explained as you go, and the writing is clear and often funny. After it, compiler theory lectures make much more sense, and error messages like "unexpected token" stop being mysterious.
Free or paid
The complete web edition is free. A print edition of about 640 pages, ebooks and a PDF are sold for those who prefer them. The code is open source on GitHub.
Time and pacing
The book is long. Part one alone, the Java interpreter, is a solid few weeks of evenings. Many readers finish part one first, take a break, then return for part two. You do not need to finish both to benefit.
How to use it
Type the code yourself rather than copying it, and do the challenges at the end of each chapter, which ask you to extend or change the language. If you prefer another language, some readers port jlox to Python, TypeScript or another language as they read, which forces understanding.
Common questions
Is this the same as a compilers course? It covers the front end and a bytecode VM in depth, but not advanced optimisation or native code generation. It is an excellent first step before a full course.
Do I need to know Java and C? Enough to read and write simple programs. The book explains the language-specific parts it relies on.
Ready to start?
Opens on Robert Nystrom in a new tab.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
Follow along
New writing, resources and project ideas land here first.