from Hacker News

Ask HN: Writing an Interpreter in Go or Crafting Interpreters?

by lordleft on 4/18/25, 11:39 AM with 27 comments

I'm thinking of learning about compilers and am pleased to find that there seems to be at least two very accessible choices, "Writing An Interpreter In Go" and Crafting Interpreters. Curious if folks here have experience with either and could provide recommendations?

https://interpreterbook.com/ https://craftinginterpreters.com/

  • by stefanos82 on 4/18/25, 12:58 PM

    Read both if you like.

    I read and liked them both, but my heart belongs to Bob's writing, especially the C implementation in Crafting Interpreters and how he explains things.

  • by wduquette on 4/22/25, 3:55 AM

    Crafting Interpreters is the right at the top of my list of favorite programming books…and I’ve been reading them since the late 70’s. Amazingly clear and well-designed.
  • by greybox on 4/21/25, 10:24 PM

    I recommend skimming over the first few chapters of crafting interpreters, the main value there is the recursive descent algorithm and abstract syntax trees, the rest is implementation. I've been developing my own language [1] and that's how I got started

    The ideas in crafting interpreters are not language specific, the examples are in java, but I used C++ for instance. Im sure you could transfer the same ideas to Go. Then again I've never read the go book you are referring to

    [1] https://youtu.be/azR1mUfFjHI?si=PsP-7o-w1yIN4xyq

  • by eleventhborn on 4/22/25, 8:43 AM

    If you go with Crafting Interpreters, there is a coding challenge on CodeCrafters that follows the book: https://app.codecrafters.io/courses/interpreter/overview

    It is free (for now) and it helps me focused.

  • by SwiftyBug on 4/21/25, 10:35 PM

    I'm doing Crafting Interpreters... in Go! The book uses Java, but I prefer Go so I just went with it. It was an interesting exercise to "translate" the understanding of the implementation shown in the book (which relies heavily in OOP) to something more idiomatic in Go.
  • by kgabis on 4/22/25, 6:34 PM

    I went over "Writing an Interpreter in Go" and "Writing a Compiler in Go" but instead of doing it in Go, I did it in C. In hindsight it was a very good decision, because it forced me to write the code myself, instead of mindlessly copying it. After finishing the books I've spent some time extending the compiler I've written and I've published it on github (https://github.com/kgabis/ape). I've read Bob Nystrom's previous book, so I'm sure Crafting Interpreters is great as well, but I really recommend Writing an Interpreter/Compiler in Go.
  • by __alexander on 4/22/25, 10:36 AM

    Crafting Interpreters has been sitting on my shelf for two or so years. I would love to read the book but the use of Java shelved it. I don’t have the time to understand the concepts from the book while simultaneously learning Java.
  • by Spartan-S63 on 4/22/25, 12:09 AM

    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 Go and it reinforced what I learned back in my undergrad on how parsers and compilers work.

    I love writing parsers and get far too few opportunities to flex that muscle. I wish I had read Crafting Interpreters for this question, as well, but by all accounts it's an incredible tome, as well. Read them all and see what different information you pick up from them!

  • by markus_zhang on 4/21/25, 1:49 AM

    I only read Crafting Interpreters and I can recommend this one. It's also free as a website so you can evaluate it before making a purchase. I did think it is interesting enough to go straight to make the purchase.
  • by dusted on 4/22/25, 6:59 AM

    There's also an excellent tutorial from LLVM, it got me started, I got some ideas and didn't want to be too influenced by "the right way", so I stopped somewhere mid tokenizer.. But I have a turing complete, interpreted language as of now, that I'm having a lot of fun thinking about.

    https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/index...

  • by FusspawnUK on 4/24/25, 1:04 PM

    Crafting interpreters is still the one book that made me truely understand how they worked. always get's a vote from me!
  • by angra_mainyu on 4/21/25, 11:50 PM

    I started them but dropped them and went straight for:

    - Engineering a Compiler

    - Programming Language Pragmatics

    - Crafting a Compiler

    Quite doable, particularly if you focus on one and supplement with the other two.

  • by MeetingsBrowser on 4/23/25, 1:13 AM

    Both are great!