What Makes the Intro to Crafting Interpreters so Good?
123 points by mtlynch
123 points by mtlynch
Aww, thanks everyone. <3
Writing the book was a labor of love, with a dollop of unhealthy perfectionism on top. I'm so glad that it resonates with people in the way I hoped it would and I'm glad it's brought people some of the joy I've had playing with programming languages.
We have both of your books in our household, will we ever have a third? :)
Along similar lines, were writing these financially worth it?
will we ever have a third? :)
Here's probably a longer and more personal answer than you expected...
When I finished "Crafting Interpreters", I had been writing almost every day for a decade. I also had a backlog of psychological stuff that really needed addressing. I was very burned out. Not so much on writing specifically but just on, like, the overall ratio of toil to joy in my life.
I have a super-human ability to hunker down and delay gratification. That can be a very adaptive trait. It's how I finished the books and is generally part of being a mature, functional adult who can get through a crisis or reach long-term goals. But I way overshot that into a territory where I just forgot how to relax and have fun. I started to feel like all joy must be deferred, indefinitely.
Then, as someone who cares about US politics, 2016 made it very hard to not feel like I was in "hunker down in a crisis" mode.
Then my mom got cancer in 2018. I won't go into detail, but I'll just say that the gratification of that relationship had been deferred by many years at that point.
Then there was that thing around 2020 where we all had to sit at home and delay a whole bunch of gratification. I was in Seattle, which was an excellent place to be in terms of keeping people alive, but we took the lockdown very seriously. So for about two years, we weren't really going out or doing much of anything. Oh and then an attempted insurrection at the US Capitol. Definitely not in crisis mode, right? Remember when we weren't sure if all of the global supply chains and economy were going to collapse and we'd have to survive by eating all of the leftover empty Amazon boxes in our garages?
In the middle of all that, I finished "Crafting Interpreters". I made a promise to myself then that I wouldn't start a third book until I "got my groove back" and worked through whatever it is I was going through. I needed to reconnect to my own sense of joy for a while and get centered.
Then my mom died.
And then I broke my ankle. Which doesn't sound like a huge deal, and I didn't think it would be a big deal. Don't you just, like, get a cast and then a couple of months later you're back to normal? In my case, not so much. I couldn't walk for three months. I had three surgeries, over a year of physical therapy. You know you are not having a good time when the wound care nurse is like "this stuff should only be administered by professionals but I'll just give you a batch to take home because you know what you're doing at this point". I haven't had a day without pain since last May.
Years ago, I started seeing a therapist. (Thank. Fucking. God.) He once asked me what I do to get out of my head when I'm feeling anxious or down. I said the few things that really help are going out dancing, going running, or going hiking out in nature. You can imagine how the intersection of that and the previous paragraph has gone.
So, I'm definitely trying to get my groove back, but the groove has proven elusive. Fingers crossed, surgery four will be the one that revokes my membership in chronic pain club.
To be clear, I have had many moments and spans of joy and satisfaction and happiness throughout all that. But it has not yet felt like a time in my life where there is room to jam another book project into it. When it does, I have an idea for a book. I'm just waiting for the gas tank to fill back up first.
Along similar lines, were writing these financially worth it?
"Worth it" is a hard to define because I didn't do it for the money in the first place. Comments like the ones here where people say the book helped them understand something, or made them a better programmer, are what really make it worth it. I met someone who once who said that after reading my book they changed their career path to go into programming languages. Having someone tell you that is an amazing feeling. I will take that over a Ferrari any day.
But, also, yes. I am superstitious talking about this because I'm afraid if I acknowledge it, it will disappear. Both books have provided a passive income stream that is more than I expected. I can't retire on it or anything, especially not here in Seattle. But it's certainly made us a little more comfortable and allowed me to feel less guilty indulging in some hobbies. I am extremely grateful for everyone who has shelled out money for that.
Years ago, I started seeing a therapist. (Thank. Fucking. God.) He once asked me what I do to get out of my head when I'm feeling anxious or down. I said the few things that really help are going out dancing, going running, or going hiking out in nature. You can imagine how the intersection of that and the previous paragraph has gone.
Hang in there!!! Things will definitely get better. đ
I haven't read the book, but it has been on my reading list for a year now. I am buying two copies this December, for me and my younger brother.
I'm definitely looking forward to the third, if you ever write one.
Iâm sorry to hear youâre going through a rough patch. Your book is a treasure and you are a generous person. I hope the upcoming surgery goes well and you find âgrooveâ back.
I haven't had the pleasure of reading your book yet, but I've heard such wonderful things about it. Thank you for sharing this personal story - it's moving and touching. I also lost my mother recently, and have felt like my "real" life has been on pause since then. I don't know what words can make your/our experiences better, other than - I feel you.
You'll have one more trickle in that income stream from me soon, and I'm grateful to have had this glimpse of the human behind the words I am going to read.
It's very brave of you to share and inspiring to hear your story ! Take it in your own time and audience will be there when you are ready :)
I sincerely hope you wanted to write that and didn't feel any pressure to, but it makes complete sense! Things will definitely get better, and I'm glad that at least you have some amount of passive income to get you through tough times.
Well let me say that I got my first games job right around when you released GPP, I remember reading it online in the incomplete pre-release state, and definitely helped shape me as a programmer throughout my career thus far. I only actually got the physical copy earlier this year solely because I wanted it on my "books that shaped me" shelf. These days I'm director level, so the knowledge it had provided served me well!
You may have already seen it, but I learned yesterday [1] that David Beazley recently taught a course using Crafting Interpreters!
https://dabeaz.com/crusty.html
That is high praise, at least from the perspective of a long-time Python programmer ... Because David has been working on this kind of thing for closer to 3 decades!
e.g. Python Lex-Yacc: https://www.dabeaz.com/ply/
(I know of him for many other things though, like some "definitive" explanations of Python asyncio)
Yes, I know of it! David and I have chatted back and forth a couple of times online. I'd love to meet him in person someday.
a labor of love, with a dollop of unhealthy perfectionism
Which is how you end up with the book on the topic that everyone refers people to for the next few decades. It truly is a case of going from "well, there's these old articles, and the dragon book, and this set of tutorials, and you can probably figure something out" to "yeah, here's the book."
An old post or two of yours about Pratt parsers and Magpie that I read in 2023âaround a week after also learning about Typstâgot me really excited about parsing and language design, and is part of why Iâm a contributor to Typst now. Your joy is truly infectious, so thank you :)
Q: Since there are plenty of book topics you wonât be writing, are there any youâd be interested in reading that donât exist yet? Perhaps a rabbit hole or nerd snipe for a passing lobster?
Oh, that's a good question!
I actually haven't been reading much lately. Part of being stuck in the house for a couple of years during the pandemic and then stuck in the house another year with a broken ankle is that I'm just so tired of sitting there consuming media. That's made it really hard to feel like reading or watching shows or anything.
I've been a TA for undergrad compilers & interpreters, as well as for a famous postgrad static analysis course. I predict this book will do well and might become the preferred text in many universities for intro courses.
The book seems to have the same quality as much of the classical literature from Scheme or Lisp, and has a great mix of ideas and practice. The typesetting is also really nicely done.
Personally, I think the OP's comparison to the Dragon Book is unfortunate, given that it's the only book from Aho et al. that has not aged well. I've never understood the fixation with that one. It's really outdated on backend techniques as the field has evolved a lot.
I also recommend reading Bob Nystromâs posts about how he wrote the book, including a test suite to run the code examples in a way that lined up with the coding progress in the book, and integrating the code into the Markdown sources of the book.
Just from reading the book I felt a lot of care and attention to detail had gone into it. Yet I didnât expect that much!
https://journal.stuffwithstuff.com/2020/04/05/crafting-crafting-interpreters/
https://journal.stuffwithstuff.com/2021/07/29/640-pages-in-15-months/
Yeah, those were the posts that convinced me to read the book even though I didn't really have an interest in programming language design. It's definitely the most care I've seen anyone put into a software book, and I can only think of a few non-software books where the level of care and effort comes across so clearly.
I was just thumbing through my copy of Crafting Interpreters this week - I'm tinkering around on a toy compiler that emits bytecode, and when I got stuck, I reached for the book as refresher/reference. I'm glad you mentioned it, the intro is great, I remember it grabbing me, and the whole thing is a pleasure to work through, you feel like you really are coding along with Bob.
I wish Bob the best in the world. Everything he does has so much care and thought put in. The quality really shines.
This reminds me of my artist friend who decided to make a graphic novel. She didnât know much about the genre and is primarily a painter, but she had a fantastic story to tell. She totally hit it out of the park because sheâs incredibly talented and she really, really cared about what she was doing. But she wildly underestimated the effort and was similarly exhausted at the end!
She asked me what I thought after my first full reading and I said âhonestly, this is much better than it needed to beâ. (Engineer alert!)
After a pitch like that, you have to tell us what the graphic novel is called!
OK, yeah, I'm an idiot. Sorry, Mary! :)
(Thatâs the Amazon link, but you can order it from your local bookstore.)