HackerTube.live
Books / Computer Science

THE READING ROOM / BOOK GUIDE

Writing An Interpreter In Go

Thorsten Ball

A working interpreter, built line by line in Go: lexer, parser, evaluator. Ball keeps the code small enough to follow and explains each decision before the next one depends on it.

About the book

Writing an Interpreter in Go walks through building an interpreter for a small programming language in Go, starting from source text and ending with evaluated programs. The approach is practical: you learn the ideas by writing the machine.

The subject is the interpreter pipeline. A lexer turns characters into tokens, a parser turns tokens into a syntax tree, and an evaluator walks that tree to produce results. Ball uses Go because its syntax is compact and its tooling is immediate, so readers spend time on interpreter design rather than on language ceremony. The scope stays deliberately small, which keeps the whole system visible at once.

Because the project is incremental, each piece is motivated by the previous one. The reader sees why a token type exists before the parser needs it, and why the tree shape matters before evaluation begins. Concepts arrive when they are needed, attached to code that already runs.

How to read it

Read with an editor open and type the code rather than skimming listings. The value comes from making the small decisions yourself: how to represent tokens, where to put precedence, how errors surface. Pause at each stage and run the interpreter against your own test inputs before moving on.

The prose is direct and the difficulty is moderate. Prior comfort with Go helps, but the interpreter concepts are introduced from scratch. Expect the parser section to demand the most attention; precedence and recursive descent reward slow reading. Treat the book as a guided build, not a reference to consult later.

Who it suits

This suits programmers who learn by constructing systems and want a concrete entry into language implementation. Go developers curious about what happens between source code and execution will find the material close to their daily work. Students who have met parsing theory abstractly can use it to see those ideas in running code. Readers seeking a survey of interpreter theory or coverage of large language features should look elsewhere; the book's strength is depth on a small, complete example.

Reading considerations

The project language is intentionally minimal, so the book does not cover optimization, type systems, or production-grade error recovery. Readers wanting those topics will need follow-up material. One exercise worth trying as you read: ask how much of the design would change if the host language were not Go. That question reveals which choices are essential to interpreters and which are conveniences of the implementation.

Follow the HN conversation

73 different recommenders are recorded in the upstream dataset. These are AI-classified source counts, not an independent rating.

Search HN comments about this book ↗

Explore videos on the same subject ↗

Book notes prepared with DeepSeek, using catalogue records and Open Library subject information. They are reading guidance, not a personal review or a verified chapter-by-chapter account. Book details can vary by edition. HN data methodology · Book metadata and covers.