
Writing A Compiler In Go
by Thorsten Ball · first published 2018
42mentions
33recommended by
39HN commenters
2016–2026first – last mentioned
85% recommend15% neutral
Why HN recommends it
Approachable, step-by-step tutorial that extends the interpreter into a bytecode compiler and virtual machine; no CS degree needed. Suits newcomers who want to build a working compiler hands-on.
Summarised by Claude from recommending comments
Affiliate links. As an Amazon Associate I earn from qualifying purchases.







…language agnostic) * The Elements of Computing Systems: Building a Modern Computer from First Principles * Programming Machine Learning: From Coding to Deep Learning * Writing an Interpreter in Go and Writing a Compiler in Go (both by the same author) * Introducing Blockchain with Lisp: Implement and Extend Blockchains with the Racket Language * Exploring Language with Logo * Visual Modeling with Logo * Turtle Geometry:…
on “Ask HN: Books like “Crafting interpreters” or “The ray tracer challenge”?” ↗I’m on mobile, but three recommendations for books/resources are: 1. Crafting interpreters. There’s plenty of hn discussion on it and it was recently completed. 2. Writing a compiler in go. There’s also a book on interpreters that goes along handily with it from Thorsten ball as well. 3. Build your own lisp There’s also plenty of traditional textbooks such as the dragon book. I don’t…
on “Ask HN: Online Compiler Courses?” ↗Writing an Interpreter in Go / Writing a Compiler in Go, the two part series by Thorsten Ball, was what I really cut my teeth on. It straightforwardly takes you through some parsing, ASTs, a basic tree-walk interpreter, and then in part two refactors the whole…
on “Why Learn Compilers” ↗Writing an Interpreter in Go and it's sequel Writing a Compiler in Go by Thorstan Ball are both excellent reads. Also enjoyed Game programming patterns by Bob again, but that has already been mentioned.
on “Crafting Interpreters: Closures” ↗I'd also recommend Writing An Interpreter In Go [1] by Thorsten Ball, and its companion, Writing A Compiler In Go. [1] https://interpreterbook.com/
on “So you want to design a programming language (2017)” ↗I've read Writing an Interpreter in Go and Writing a Compiler in Go. Crafting Interpreters is on my bookshelf and on the list to get through Soon™. The latter books by Thorsten Ball are an incredibly approachable introduction to the topic. It's how I initially learned…
on “Ask HN: Writing an Interpreter in Go or Crafting Interpreters?” ↗A very instructive exercise for anyone who is or intends to be a software developer is to write some sort of interpreter and/or compiler. (As well as a virtual machine and/or emulator) Depending on your approach this can take a weekend, a few months, or the rest of your life. For instance, and amusingly enough written in golang, one of the most respected recent books on this topic is `Writing an
on “What Is Good About Haskell?” ↗I've been making my way through "Writing an Intepreter in Go" and "Writing a compiler in Go" https://interpreterbook.com/ The Go stuff is really just a means to an end, the real value comes from the practical learnings of how to build a functioning interpreter and compiler (and virtual machine!)…
on “Ask HN: What are some books where the reader learns by building projects?” ↗There's also Thorsten Ball's Writing an Interpreter in Go[1] and Writing a Compiler in Go[2]. [1] https://interpreterbook.com/ [2] https://compilerbook.com/
on “Crafting Interpreters: A Review” ↗This is a great introduction to writing an interpreter if you know, or are learning, Go: https://interpreterbook.com/ There's a follow-up as well: https://compilerbook.com/
on “Crafting Interpreters: Closures” ↗…best at Go, so it's a useful "nightly devotion" of time to spend working through it for an hour or so. I've also been going through Writing an Interpreter in Go, and have picked up the companion to that Writing a Compiler in Go. So far, that's pretty good too, but I'm focusing on Black Hat Go first, to complete it.
on “Ask HN: What are some books where the reader learns by building projects?” ↗I'm almost done with "Writing an interpreter in Go"[0] which I highly recommend. Even though it's less theoretical than the usual books in this area I learned a ton of practical stuff and a lot of things I "knew" from more theoretical sources make now much more sense. Looking forward to work through the second book of the series [1] which is aimed at compilers. [0]:https://interpreterbook.com/ [
on “A crash course in compilers (2018)” ↗There are a ton of great books out there! If you're looking for a bit of the whole shebang, check out Compilers: Principles, Techniques, and Tools (aka, The Dragon Book). It's an older book, but a lot of what is described in there is still very relevant and good info. If you want a more high level overview at first, I'd recommend Crafting Interpreters [0] and Writing a Compiler/Interpreter in Go [
on “LLVM merges machine function splitter for reduction in TLB misses” ↗I've heard good things about Writing A Compiler In Go, which is a sequel to Writing An Interpreter In Go. I've worked through some of the latter and have enjoyed it so far. https://compilerbook.com/
on “Ask HN: Best Resources for Compiler Construction” ↗Oh wow! Great resource. I think it strikes the right balance between lexing/parsing vs code generation/optimization. I see that not even in modern books things like PEG parser or Pratt parsing make the cut. Which is a pity IMHO. As an aside I am yet to find a great book/resource of garbage collectors that I can understand. It is such a fascinating subject! If you want to dive into compiler/inter
on “Introduction to Compilers and Language Design (2021)” ↗