TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Crafting Interpreters: A Review

461 pointsby chidiwalmost 3 years ago

28 comments

bow_almost 3 years ago
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&#x27;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&#x27;re reading this, thank you, Bob :).<p>[1] <a href="https:&#x2F;&#x2F;www.lua.org&#x2F;doc&#x2F;jucs05.pdf" rel="nofollow">https:&#x2F;&#x2F;www.lua.org&#x2F;doc&#x2F;jucs05.pdf</a>
评论 #31838775 未加载
评论 #31847370 未加载
评论 #31843010 未加载
评论 #31841747 未加载
评论 #31841224 未加载
评论 #31839750 未加载
评论 #31842286 未加载
评论 #31842956 未加载
评论 #31841771 未加载
评论 #31839805 未加载
Derbastialmost 3 years ago
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 &quot;how do computers work&quot;. 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.
评论 #31841850 未加载
评论 #31839326 未加载
评论 #31843833 未加载
评论 #31838321 未加载
评论 #31837591 未加载
评论 #31839338 未加载
评论 #31839479 未加载
评论 #31839788 未加载
评论 #31838917 未加载
hardwaregeekalmost 3 years ago
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&#x27;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&#x27;d be a cross between an O&#x27;Reilly book and a SerenityOS stream
评论 #31852355 未加载
alexobenaueralmost 3 years ago
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!
lordleftalmost 3 years ago
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:&#x2F;&#x2F;craftinginterpreters.com&#x2F;introduction.html" rel="nofollow">https:&#x2F;&#x2F;craftinginterpreters.com&#x2F;introduction.html</a>
d23almost 3 years ago
This book is a work of art. It&#x27;s one of the best technical books I&#x27;ve ever read. Truly a masterpiece along every dimension.
评论 #31837159 未加载
recursivedoubtsalmost 3 years ago
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!
评论 #31837550 未加载
munificentalmost 3 years ago
Thank you for the excellent review!<p>Also, I&#x27;ll second the comments here: The design of your blog is beautiful.
评论 #31845943 未加载
评论 #31838643 未加载
chapliboyalmost 3 years ago
The author says it took about 6 months to thoroughly go through the book and examples.<p>This is really useful in setting expectations.
评论 #31836235 未加载
Noe2097almost 3 years ago
Following a slightly different path, &quot;Modern compiler implementation&quot; 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).
评论 #31837333 未加载
评论 #31836741 未加载
wrpalmost 3 years ago
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&#x27;t read yet, but it looks very practical:<p>5. Clinton L. Jeffery. 2021. Build Your Own Programming Language: A Programmer&#x27;s Guide to Designing Compilers, Interpreters, and DSLs for Solving Modern Computing Problems.<p>I don&#x27;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.
collinvandyck76almost 3 years ago
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.
评论 #31838837 未加载
hyperzhialmost 3 years ago
I&#x27;ve been wanting to read this book, but I&#x27;m not sure how I should go about it. Are you supposed to read and type out the code examples? I&#x27;m just wondering if I will learn anything that way?
评论 #31836535 未加载
评论 #31836320 未加载
评论 #31836287 未加载
评论 #31837223 未加载
评论 #31838654 未加载
评论 #31836885 未加载
评论 #31836392 未加载
评论 #31837921 未加载
评论 #31836347 未加载
评论 #31836220 未加载
vertexmachinaalmost 3 years ago
I&#x27;m in the middle of this book at the moment and I have mixed feelings on it.<p>It&#x27;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&#x27;ll present a function that calls a function that doesn&#x27;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&#x27;re trying to copy his code verbatim, but not so much for high-level understanding. Maybe that&#x27;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.
评论 #31839243 未加载
评论 #31842261 未加载
评论 #31844756 未加载
shaftoe444almost 3 years ago
This is an excellent book. I got so much out the first half I keep building little toy interpreted languages and haven&#x27;t got round to the second half yet!
dingosityalmost 3 years ago
This is the type of content I come here for. I also enjoyed the &quot;other posts&quot; listed at the bottom of this article. Well done, Chidi!
nphard85almost 3 years ago
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.
cpardalmost 3 years ago
And it&#x27;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&#x27;m sure that you will end up buying it at the end.
评论 #31837271 未加载
geekraveralmost 3 years ago
If you’ve never read it, a fun article on Bob from some years back.<p><a href="https:&#x2F;&#x2F;www.wired.com&#x2F;2013&#x2F;01&#x2F;comedy-in-the-hacker-world&#x2F;amp" rel="nofollow">https:&#x2F;&#x2F;www.wired.com&#x2F;2013&#x2F;01&#x2F;comedy-in-the-hacker-world&#x2F;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).
mhh__almost 3 years ago
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 &quot;You&#x27;re not ready yet, read this&quot; book when it comes go guiding people going down the dark unhappy path of working on language implementations.
评论 #31845613 未加载
twh270almost 3 years ago
Has anyone worked their way through both this and Beautiful Racket? I&#x27;d love to get a comparison of your experience with both.
EamonnMRalmost 3 years ago
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.
MarquesMaalmost 3 years ago
This is my favorite book!<p>But I think it could be more straight forward if the first interpreter didn&#x27;t use Java, but a modern main stream language that can avoid code generation and Visitor Pattern. Those parts feels like unnecessary detour.
评论 #31838807 未加载
xbaralmost 3 years ago
Thanks Chidi for a great review and a blog with a lovely design.
ParallelThreadalmost 3 years ago
What other books are of the same caliber that HN would recommend?
评论 #31836834 未加载
评论 #31837144 未加载
评论 #31839159 未加载
评论 #31836886 未加载
评论 #31838172 未加载
评论 #31842255 未加载
评论 #31837494 未加载
icholyalmost 3 years ago
I&#x27;m glad to see this book get the attention it deserves.
mengibar10almost 3 years ago
Beautiful typeface, well organized and very appealing to eyes.
sydthrowawayalmost 3 years ago
Java is such a god damn turn off.
评论 #31843172 未加载