I hesitated a little bit before deciding to purchase and go through the book. Had already read many glowing reviews then, but was not sure if the choice of language (Java) for the first half of the book would be a hindrance (it's not the stack I am most familiar with).<p>Decided to buy it anyway, primarily because the two implementations of the toy language piqued my interest (most other books only go through one implementation).<p>Boy was I glad I did.<p>Writing is superb, end-of-chapter challenges are instructive, code samples are meticulously and beautifully done. Here and there I also encountered references to other languages (e.g. had a brief detour to Lua internals [1], thanks to a side note), which I have enjoyed too.<p>Went through the first half twice: first using Java as it is written and then secondly implemented the interpreter in Rust (my initial fear turned out to be unfounded). Currently going through the second half.<p>So if you're reading this, thank you, Bob :).<p>[1] <a href="https://www.lua.org/doc/jucs05.pdf" rel="nofollow">https://www.lua.org/doc/jucs05.pdf</a>
Without a doubt one of the best technical books I have ever read.<p>To me, it was a missing piece of the big puzzle of "how do computers work". I read many a book to answer this question, and came away with three books:<p>- CODE by Charles Petzold explains the CPU<p>- Operating Systems: Three Easy Pieces by Arpaci-Dusseau explain OSes<p>- Crafting Interpreters by Robert Nystrom explains programming languages<p>Masterfully done.
I love this book! My only gripe is that I wish it was a whole series, no, a whole genre of books. We need more hands on, code first books that take you through 1-2 extended projects where you can type along and get working code at the end. These books should have CS theory, but still be fundamentally focused on implementation. It'd be really fun to have one of these for a more functional compiler (type checking, code generation, optimization), for a language service (query based compilation, concrete syntax trees, language server protocol), for databases, operating systems, and so on. Ideally they'd be a cross between an O'Reilly book and a SerenityOS stream
Truly one of the best books in our field; very well done.<p>Doing the tree-walk interpreter (the first “half” of the book) took two weekends, working much of the day on Saturdays and Sundays.<p>When I went through it, I built my interpreter in another language, and added other features as I went along. Both helped solidify the concepts. I often had to pull out my additional features as I learned better in subsequent chapters; getting to see the difference between my amateur approach versus the author’s experienced methods was quite helpful!
Beautiful typeface. Clear writing. Passion and humor seeping out of every page.<p>The author has also kindly made a web version of his book freely available:<p><a href="https://craftinginterpreters.com/introduction.html" rel="nofollow">https://craftinginterpreters.com/introduction.html</a>
highly, highly recommend this book<p>when i was given a compilers class to teach i wanted to teach hand-written recursive descent because it is simple, elegant and makes the recursive nature of grammars so readily apparent without hiding concepts behind obscure tools<p>i was despairing that there were no good books around on recursive descent, but stumbled on crafting interpreters before it was even released as a book and immediately structured my class around it<p>absolute life saver and my students all love it<p>cannot say enough good things about it!
Following a slightly different path, "Modern compiler implementation" goes over several topics mentioned in the review (lexing, parsing, type checking, code optimization and generation, runtime environments aspects e.g. garbage collection).<p>There exists various flavors of the book (in ML, Java, and C).
The literature on interpreters (vs. compilers) is pretty thin. I enjoyed reading these:<p>1. Peter John Brown. 1979. Writing Interactive Compilers and Interpreters.<p>2. Timothy Budd. 1987. A Little Smalltalk.<p>3. Ralph E. Griswold. 2000. The Icon Programming Language, 3e.<p>4. Pat Shaughnessy. 2013. Ruby Under a Microscope: An Illustrated Guide to Ruby Internals.<p>This is a new one I haven't read yet, but it looks very practical:<p>5. Clinton L. Jeffery. 2021. Build Your Own Programming Language: A Programmer's Guide to Designing Compilers, Interpreters, and DSLs for Solving Modern Computing Problems.<p>I don't know anything about this one, but people have told me they prefer the first edition:<p>6. Ronald Mak. 1991. Writing Compilers and Interpreters: An Applied Approach.
This is the kind of book that really pays dividends into the future. Once you realize that lexing and parsing is not really that difficult, it makes a whole class of problems much easier.
I've been wanting to read this book, but I'm not sure how I should go about it. Are you supposed to read and type out the code examples? I'm just wondering if I will learn anything that way?
I'm in the middle of this book at the moment and I have mixed feelings on it.<p>It's definitely well-written and you can feel the love and care that went into producing it. But I think it would have been stronger had Nystrom skipped the Java version and spent those pages on theory instead before jumping into the C implementation. While going through the Java stuff (implementing in C# instead because I have an emetic reaction to Java) I found myself just wanting to hurry up and get to the good stuff in C. And I found the visitor pattern and code generation stuff to be a distraction.<p>The code can also be a bit hard to follow at times because he jumps around from file to file and function to function. He'll present a function that calls a function that doesn't exist yet, and then define the new function, etc. He does it that way because he wanted to ensure that every single line of code was present in the book (he wrote a tool to ensure that was the case), and it certainly helps if you're trying to copy his code verbatim, but not so much for high-level understanding. Maybe that's a failing on my part.<p>Finally I wish he had gone into more detail on how one might implement a register-based VM because they are faster and more interesting (to me) than a stack-based one.
This is an excellent book. I got so much out the first half I keep building little toy interpreted languages and haven't got round to the second half yet!
Just completed part 1 (used Python instead of Java to spice it up a bit) and it was a great experience! Looking forward to working through part 2, but it will be a while before I can get around to it. I hope more books follow this engaging writing pattern (when it makes sense). Kudos to Bob Nystrom for this great book.
And it's so much fun to go through. Most CS books are usually very dry, this one is such a fun read. I would encourage everyone to go and read at least the web version of the book, I'm sure that you will end up buying it at the end.
If you’ve never read it, a fun article on Bob from some years back.<p><a href="https://www.wired.com/2013/01/comedy-in-the-hacker-world/amp" rel="nofollow">https://www.wired.com/2013/01/comedy-in-the-hacker-world/amp</a><p>I was lucky enough to be working on the Dart team in Seattle at the time with Bob, who is one of the smartest, funniest and nicest people I have ever met (although the whole team was an exceptional bunch).
I think this book is ever so slightly overrated when it comes to actually implementing programming languages, but it contains such a nice introduction to parsing that I have for years been using it as my goto "You're not ready yet, read this" book when it comes go guiding people going down the dark unhappy path of working on language implementations.
I keep meaning to pick this back up. It was my go-to project during air travel and train travel for a while, but I stopped going in to the office so much and command line only projects have trouble competing for mind space with visual stuff, at least for me.
This is my favorite book!<p>But I think it could be more straight forward if the first interpreter didn't use Java, but a modern main stream language that can avoid code generation and Visitor Pattern. Those parts feels like unnecessary detour.