
Writing An Interpreter In Go
by Thorsten Ball · first published 2018
107mentions
73recommended by
90HN commenters
2016–2026first – last mentioned
81% recommend17% neutral2% critical
Why HN recommends it
Approachable, short, hands-on walkthrough of building a lexer, Pratt parser, and tree-walking interpreter for a simple C-style language. Suits newcomers; the code ports easily to Rust or C++.
Summarised by Claude from recommending comments
Affiliate links. As an Amazon Associate I earn from qualifying purchases.






Writing an interpreter in Go https://www.amazon.com/Writing-Interpreter-Go-Thorsten-Ball/... is pretty good. The book assumes that you know Go and the resulting interpreter is not a Lisp.
on “Learn C and Build Your Own Lisp (2014)” ↗…Tracer Challenge but is not as 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…
on “Ask HN: Books like “Crafting interpreters” or “The ray tracer challenge”?” ↗…niche, small, modern, or new languages you enjoy experimenting with, even if not used in production? (Not directly related, but if you do have an interest in writing a language I'd highly recommend the "Writing an interpreter in Go" book, by Thorsten Ball. I had fun working through the code, and my own version of the monkey interpreter became pretty advanced https://github.com/skx/monkey/ it also lead to me writing a simple BASIC…
on “Ask HN: Tell me of your niche languages?” ↗Thorsten Ball’s “Writing an Interpreter in Go” has a very in-depth walkthrough of building a Pratt parser. It’s a very good read/tutorial. Maybe it’s just me but it seems there’s a lot of language design coming out recently. E.g. Bob Nystrom has…
on “Making a Pratt Parser Generator” ↗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…
on “Why Learn Compilers” ↗…up. Some of the resources which were very helpful were the CMU database course on youtube and the book called "database internals" by Alex Petrov (I just read parts of it as required). Also the book Writing an interpreter in Go by Thorsten Ball was very useful when writing the sql parser.
on “Ask HN: Share your side project” ↗…I'm going to try self publishing. I'm liking leanpub's use of a markdown like format. But again none of this really matters. You can fix formatting later. You have to sit down and write! PS Thorsten's "Writing an Interpreter in Go" is great: https://amzn.to/3yLTJjE
on “The Tools I Use to Write Books (2018)” ↗Check out "Writing An Interpreter In Go" https://interpreterbook.com/ It uses Golang to make an interpreter for a simple C-Style language and it's "only" 200 pages long. I'm about a third in and my head is smoking.
on “Ask HN: What's a starting point for learning how to write programming languages?” ↗For those of you that found this interesting, I also highly recommend: Writing An Interpreter in Go [1] and Crafting Interpreters [2]. [1] https://interpreterbook.com/ [2] http://craftinginterpreters.com/
on “Bytecode compilers and interpreters” ↗Seems to be a hot topic, a friend and colleague published this in December 2016 and I can thoroughly recommend it (Uses Go as an implementation language): - https://interpreterbook.com
on “Show HN: Crafting Interpreters – A handbook for making programming languages” ↗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!) for a programming language the author made up called Monkey. It's not a book full of theory but it la
on “Ask HN: What are some books where the reader learns by building projects?” ↗https://interpreterbook.com is a pretty good resource to hit the ground running, with unit tests and little magic. Once you've gone through it, you'll probably want to use the magic tools as they're well tested at this point, and make your life easier. Still, understanding what they're doing for you is a massive boon. I should note, it uses Go but not in an idiomatic way. Strings instead of us
on “Ask HN: Resources for building a programming language?” ↗For someone who care the implementation than the high-level design: It's written in go, interpreter-based, and pretty small [1]. Although the author seems to be a well-studied PL lover, you don't have to be like this to create a small language. It's fun experience and there are books for non-experts like [3]. - [1] https://github.com/thesephist/ink/tree/master/pkg/ink - [2] https://thesephist.c
on “Ink programming language” ↗When I went through these books (https://interpreterbook.com/ and its sequel https://compilerbook.com/), I did them in Typescript, which was a great exercise. I felt like this is the sort of program that really gives TS its time to shine. Ironically, I didn't get _any_ speed up using the interpreter vs the compiler in my TS implementations. I'm not sure if that's because I wasn't careful enough w
on “Comparing Implementations of the Monkey Language VIII: Ruby, Python and Lua” ↗