11 ms·
Crafting Interpreters
- eternityforest 2y agoMad respect to those with that kind of dedication, and everyone working to keep all the dev infrastructure going, but I'm super glad my "I want to make a language" phase was just a passing interest! That's just a crazy amount of work!
- grumpyprole 2y agoIt doesn't have to be a crazy amount of work, see Lisp-in-Lisp in the original SCIP book or a lambda calculus interpreter in Haskell (fits on a screen).
- eternityforest 2y agoActually doing anything beyond weekend project complexity with that sort of thing is pretty hard though. I guess if you have a lot of fairly small ideas with a lot of novelty, I could see the appeal of a new language to express them in.
- kazinator 2y agoL-in-L interpreters assume that you already have symbols implemented, memory management implemented, reader and printer implemented, ... You could spend considerably more time implementing a Lisp dialect's math library than the interpreter. There are a lot of combinations. Where are the objects, hash tables, exception handling, ... Of course you can get some of these things from a host language, but someone had to make them.
- grumpyprole 2y agoYes but my point is that these problems are as hard as we want to make them. For a simple language implemented in C, maybe it's fine to never free any memory until the process quits.
- kazinator 2y agoMore like, for a simple problem or a sufficiently small instance of a complex problem being solved in C, or a language written in C (simple one or otherwise), maybe it's fine to never free memory until the process quits.
- deleted 2y ago[deleted]
- brcmthrowaway 2y agoIs this book still relevant?
- danielvaughn 2y agoDefinitely. I just went through the first 60% or so and it's great. The language is java but it's easy to translate to other languages, which would be a good learning exercise in its own right.
- SatvikBeri 2y agoIt's a 3 year old book on compilers, so if it was ever relevant once, it surely still is today!
- metadat 2y agoYes, very much so. Why wouldn't it be? Can you recommend a better resource for learning how to create a programming language from first principles? I just started it today, which I why I felt the inclination to create this post.
- LoFiSamurai 2y agoIt’s an incredible book. Munificent did an amazing job.
- runevault 2y agoThis is not a book about bleeding edge compiler techniques. It teaches the foundations that makes it easier to learn the more complex parts of writing a compiler. Unless compiler design radically changes it will likely remain a relevant book for a very very long time. Especially since Java-adjacent languages are likely to remain in vogue and the odds of us losing C as a major language in the next few decades is basically zero.
- linhns 2y agoSuper. Bob’s way of presenting his content is what I feel the most important to get out of. Great communicator.
- 2y ago
- britannio 2y agoI just finished the second half, it's a great book! I recommend doing one or two of the proposed challenges in each chapter to reinforce your understanding of the content.
- chris37879 2y agoI feel like this is a book most programmers should work through at some point or another. Doing so made me really appreciate just what's going on inside a compiler / language toolkit. It's also one of the most well written technical guides I've ever followed, it really helped me internalize the concepts, and they are useful all over the place, not just in compilers.
- sva_ 2y agoThis comment sold me. Gonna keep this as an inactive tab for the next couple months.
- phyrex 2y agoWhy not buy an copy and put it on your to-read shelf for the next couple of months?
- blackerby 2y agoMonths? How about years? And then start it, step away for a year, come back and start it again, then step away for a year, come back and … ?
- BoiledCabbage 2y agoJust to be safe, make sure to also copy the url into a note app, or some other location where you'll never look at it again.
- fuzztester 2y agoRedirect it to /dev/null, that way you'll never see it again, so won't feel guilty: $ cat this >/dev/null Bonus points for redirecting standard error to standard output: $ cat this >/dev/null 2>&1 Now no one will hear the screams ...
- fuzztester 2y ago>really helped me internalize the concepts, and they are useful all over the place, not just in compilers. Which are some of those places? Parsing data formats could be one, I guess.
- cageface 2y agoThe author is one of the lead developers for Dart, which has evolved over time into a pretty nice language.
- throwaway032023 2y agoI think Dart is underappreciated. Almost the entire compiler is written in Dart. It has a VM, AOT compiler, FFI/Native, and first class Javascript interop with ability to compile to javascript. It has first class WASM support. Null sound safety. They have experimental support for macros. Pretty impressive.
- cageface 2y agoI completely agree. I was lukewarm on Dart but decided to do my new app in Flutter and it's turned out to be a great experience. Kotlin and Swift may look better on paper but Dart is very productive. The tooling is really solid and the fast compile times and hot reload really help for rapid iteration. I've also had no performance issues.
- munificent 2y agoI should clarify that I've been an engineer on the Dart team for a long time, but I wasn't one of the original designers of the language. (If I had been, the language would be pretty different.) I am on the language team now, but I'm just one of the team members and not a lead. The Dart team is really fantastic. Every day I'm grateful I get to work with such a good group of people.
- cageface 2y agoThanks to you and the rest of the team for all your great work! It really is a very nice language. I've been working almost exclusively in Dart for the last 6 months and it really is a very pragmatic and productive language. I'm looking forward to macros and more fully featured record types.
- tashmahalic 2y agoHow might Dart be different if you were an original designer?
- chasil 2y agoThe lex and yacc utilities are part of POSIX.2; is there any reason not to reach for them first? https://pubs.opengroup.org/onlinepubs/9699919799/utilities/lex.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/l... https://pubs.opengroup.org/onlinepubs/9699919799/utilities/yacc.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/y... All the POSIX.2 standards for shell utilities can be found here: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ The original introduction to lex and yacc was in the book by Kernigan and Pike: https://scis.uohyd.ac.in/~apcs/itw/UNIXProgrammingEnvironment.pdf https://scis.uohyd.ac.in/~apcs/itw/UNIXProgrammingEnvironmen...
- gavinhoward 2y agoAs the author of a POSIX standard utility, I would advise you to only reach for such utilities when portability is the most important thing. POSIX utilities are not great. Lex and Yacc included.
- chasil 2y agoIs your criticism of the relationship of the lexer and the parser, or something more fundamental? Is an LR parser expressed in BNF notation unsatisfactory? I say this only as it has been many years since I have written one, but I thought this OCaml presentation on a POSIX shell held the structure in high regard. https://archive.fosdem.org/2018/schedule/event/code_parsing_posix_s_hell/ https://archive.fosdem.org/2018/schedule/event/code_parsing_...
- gavinhoward 2y agoThe UX of the BNF notation. I am partial to hand-coded recursive descent purely because I struggled with Lex and Yacc too much when I tried.
- chasil 2y agoI commiserate, it can be unforgiving, and the use of C is admittedly out of vogue.
- yodsanklai 2y agoI know this book has been praised before on HN, but I've been personally a bit disappointed. It's suitable for someone with no very little knowledge on the topic, but it doesn't really cover any advanced topic.
- atan2 2y agoI trust that you're correct, but I'm glad that this is the case. There are books designed to be introductory, and there are books that serve as reference for advanced topics and state-of-the-art techniques. The first type can often serve as an enabler for the second type.
- phatskat 2y agoI’m personally very excited for this book. When I would get programming books at the library as a youth, it would be a gamble as to “introductory or advanced?” and I needed the former way more. “3D Rendering in X Windows” wasn’t great at for me at 13, and getting into topics like this takes a solid foundation.
- lolinder 2y agoIt's generally a good idea to judge a book by its explicitly expressed audience, where applicable. In this case Bob made his audience very clear in the first few paragraphs of the book [0]: > It’s the book I wish I’d had when I first started getting into languages, and it’s the book I’ve been writing in my head for nearly a decade. > In these pages, we will walk step-by-step through two complete interpreters for a full-featured language. I assume this is your first foray into languages, so I’ll cover each concept and line of code you need to build a complete, usable, fast language implementation. > In order to cram two full implementations inside one book without it turning into a doorstop, this text is lighter on theory than others. It sounds to me like you picked up the wrong book, skipped the introduction, and then were disappointed that it wasn't directed at you. The good news is that it is free, so you aren't actually out anything but time. [0] http://craftinginterpreters.com/introduction.html http://craftinginterpreters.com/introduction.html
- linhns 2y ago
- sunday_serif 2y agoMy favorite part of this book is that guides you through writing two separate interpreters for the same language. I think it really allows you to grasp some of the more intricate and nuanced parts about building a programming language. You can encounter all of the big ideas in the first half of the book and gain enough familiarity with them so that when you revisit them again in the second interpreter, you can actually absorb the interesting parts. Such a phenomenal book!
- liamilan 2y agoRead Crafting Interpreters when building Crumb (https://github.com/liam-ilan/crumb https://github.com/liam-ilan/crumb). It was indispensable, especially the sections on scope and local variables. The balance between technical implementation and conceptual insights is super helpful, especially when trying to go off of the book’s set path. It’s inspiring to see technical writing done like this. As an aspiring engineer, this sets a really high standard to aim for - excellent resource.
- news_to_me 2y agoThis looks cool! How did you decide on what data types to include?
- myco_logic 2y agoPersonal choice, is what I'd say. You can get a lot of mileage out of implementing a dynamic language with NaN boxing[1]. It really depends on the kind of language you're trying to build an interpreter for, and what purpose it could serve. For dynamic languages, I'd say looking at the core types of Erlang is a great place to start (Integers, Symbols, Functions, etc.). For a statically typed language things get more complex, but even with just numeric types, characters, and some kind of aggregating type like a Struct you can build up more complex data structures in your language itself. [1]: https://leonardschuetz.ch/blog/nan-boxing/ https://leonardschuetz.ch/blog/nan-boxing/
- metadat 2y agoReally neat article, this is my first encounter with the concept of NaN Boxing. Thanks for sharing!
- liamilan 2y agoIt was my first time making a language, so I built into the language whatever was needed to build something cool with Crumb. Wanted first class functions to simplify the parse step (they can be treated like any other value), but I needed a different mechanism to invoke “native code” vs user-defined methods, so there’s two different types for that. Needed some kind of compound data type, but I didn’t want to deal with side effects from pass by reference, so Crumb implements lists, but they are always pass by value :) P.s. theres some pretty neat stuff build with Crumb at https://github.com/topics/crumb https://github.com/topics/crumb if anyone’s interested!
- IAmLiterallyAB 2y agoPlanning to read this soon. Anyone got any other compiler book recommendations? Preferably modern (I've heard the dragon book is out of date)
- chin7an 2y agoI’ve not read this book, so can’t offer a comparison but Thorsten Ball’s two books [1] are great. The dragon book was my textbook in college, brings back memories, might be outdated but some concepts should still be useful. [1] https://thorstenball.com/books/ https://thorstenball.com/books/
- signaru 2y agoThorsten Ball's books are the closest thing to Crafting Interpreters. Not just by topic, but also with how the code is presented. By far these are among the few books I know that take the effort to guide the reader to programming something complex from scratch, while also being testable as the program grows. This means that previously presented code changes along the way as new features are added. A lot of other "code yourself" books, on the other hand, simply slice already finished codebases, and there's no way to test a simpler incomplete version of the program unless the reader makes extra effort and go beyond what is presented in the book. While there is a lot of overlapping topics in Nystrom's and Ball's books, there are also enough differences to learn something new from the other. Ball's books uses the same parser and AST as front ends to both tree-walking and VM interpreter. CI, on the other hand, skips the AST for the VM interpreter, and also teaches extra topics like implementing garbage collection, dictionaries/hashtables and class-based OOP.
- pansa2 2y agoEngineering a Compiler (Cooper and Torczon) seems to be widely recommended. I’ve got the second edition but there’s now a third - not sure how significant the changes are. AFAIK the problem with the dragon book is the same as with most academic compiler courses. It spends most of its time on the theory-heavy front-end (parsing) and much less on the back-end (code generation). Real-world compilers are very much the opposite.
- runevault 2y agoSince people are talking about other compiler resources, one I have enjoyed so far though I still need to finish it, Immo Landwerth writing a compiler in c# that generates IL and also debug symbols and the like. It is older (about 5 years, so Core but like 3ish timeframe I believe) so doesn't use current c# syntax but shouldn't matter much for most of what you'd be doing other than a lot of warnings about nullability on types. https://www.youtube.com/playlist?list=PLRAdsfhKI4OWNOSfS7EUu5GRAVmze1t2y https://www.youtube.com/playlist?list=PLRAdsfhKI4OWNOSfS7EUu...
- alabhyajindal 2y agoI really wish this book used something other than Java. Nothing against Java - just that I don't know it and don't feel excited about learning it.
- snats 2y agoYou can do the second part that is C!
- jasonjmcghee 2y agoFor what it's worth, these days you could use an LLM to turn each code snippet into many other languages. Or just focus on his words and use the snippets like generic code and figure out how to do it in whatever language of choice. You don't need to "learn java" to become conversant or read it as pseudocode.
- alabhyajindal 2y agoThat's great advice. Thank you!
- bluedays 2y agoI’m glad it used Java. I wound up rewriting the code in Python and it really helped me understand the concepts a lot better.
- grumpyprole 2y agoWhen Java gets pattern matching, it will become a more reasonable choice to write an interpreter in.
- CraigJPerry 2y agoIt’s had pattern matching since 16, it’s been expanded since with some syntactic sugar and more recently the introduction of sum types and exhaustiveness to go along with pattern matching.
- 2y ago
- trenchgun 2y agoAlright, I will finally read the book. It has been collecting dust in my bookshelf for a while.
- tusharsadhwani 2y agoI finished this book, wrote the two implementations in Python and Zig, genuinely one of the best set of projects I've ever built.
- dailykoder 2y agoHmmm, I started the book once in powershell. I think, I finished chapter 2. Maybe I should finish the whole book with it finally. Just for the fun. (Yes, powershell. Because I didn't have any other toolchain/compiler on the windows machine at some old work place and no admin rights to install anything. So I learned powershell.)
- ayhanfuat 2y agoHow was the Zig experience? I am looking for an intermediate Zig project to practice Zig. Does this require advanced features of Zig?
- cube2222 2y agoI’m also implementing it in Zig right now (and haven’t done any project other than small snippets in zig before) and it’s fine. You can actually appreciate how much nicer it is to write than in C, while still being a fairly 1-1 translation.
- cdcarter 2y agoI’ve also ported the lox vm to Zig and had a great time working through it. Since the project is designed in C, you can mostly write the exact same code in zig, with minimal modifications. If you want to use zig features, they’re easy to integrate, but Nystrom obviously won’t be giving you any hints. But the language offers a lot of useful features (slices, optionals, error types) and makes some C paradigms syntactic realities (tagged enums, explicit pointer casts). Even more so, the standard library comes with very useful stuff (an ArrayList, a handful of different allocators, heck I replaced the trie of keywords with a StaticStringMap). it’s a fun project, I would definitely recommend it!
- xigoi 2y agoDoes anyone know of a good resoucce for creating a statically typed language with stuff like parametric polymorphism and basic type inference?
- rscho 2y agoModern compiler implementation in ML by A. W. Appel There are (inferior) versions of the same in C and Java. I'd use them together with the ML version.
- zellyn 2y agoIt’s a bit more theoretical, but working my way (slowly, with many re-watches of certain videos) through the Coursera compilers course was a major milestone for me: I highly recommend finding an accessible way to do one of the CS things you think only Wizards can do: once you tackle one or two such projects, and realize that it’s hard, but mostly just slogging your way through it, it can be an enormous confidence boost :-) I’m always happy to help anyone going down this path: zellyn@(most things) if anyone reading this wants to try but is feeling nervous.
- zellyn 2y agoOne additional note: the provided code for that course is (or was a decade+ ago!) either C++ or Java, but the tests and test scaffolding are fairly straightforward. I opted to translate into Go as I went, which meant: - a lot more work/time - slower progress - no “if you fill in this missing piece, we’ve provided the rest so your compiler will work end-to-end” - an annoying amount of trying to print ASTs exactly like the C++/Java code for validation purposes But I got to use Go instead of those other languages! ;-)
- kccqzy 2y agoThe main crux of parametric polymorphism and type inference is just implementing Algorithm W. Just find a toy implementation online and poke at it. For me, when I learned it myself, I simply took the toy implementation at https://github.com/wh5a/Algorithm-W-Step-By-Step/blob/master/AlgorithmW.lhs https://github.com/wh5a/Algorithm-W-Step-By-Step/blob/master... realized that it was written in an extremely outdated style, modernized it, cleaned up, and ended up with https://gist.github.com/kccqzy/fa8a8ae12a198b41c6339e8a5c45978a https://gist.github.com/kccqzy/fa8a8ae12a198b41c6339e8a5c459... Then I proceeded to change various things to "break" the algorithm and see how they are broken.
- purple-leafy 2y agoWaiting on the shelf for me once I finish cs50
- Arisaka1 2y agoCurious question from someone new to the programming field who lacks a formal CS background: How are books like this one are meant to be consumed? Do you read it cover to cover as you code along with the author in a way YouTube tutorials work? The main reason for asking is, I don't know if I'm lacking in natural gifts (really likely) but I can't seem to retain knowledge like that. It feels nice to onboard myself to a language or framework by doing so, but afterwards I will still struggle to connect pieces together. I'm interested to learn more on how language interpreters work, I just don't know if the format is something that will assist me. I'm trying to compliment and assist my brain with note taking after reading the note taking thread that is currently in the front page, so perhaps that will change.
- radiospiel 2y agoIm my experience following - as in actually doing the steps - works wonders.
- Measter 2y agoFor this book, that is absolutely what you should do. It starts you off building a simple parser and interpreter, and then has you add features to both as you progress through the book. Skipping sections can mean that you end up missing functionality you might need.
- shortercode 2y agoThis book is intended to be a cover to cover job. I tackled it about 2 or 3 chapters at a time while building alongside. But after the midway point where it swaps to a C based byte code compiler I just read it instead. There are books like the dragon book which cover PL design in a more reference book style. But I don’t recommend them. If you’re looking for a lighter alternative then “writing an Interpreter in Go” is worth a look. Also Bob Nystrum has some other good material on his blog, and a chapter in game programming patterns about PL stuff.
- munificent 2y ago> Also Bob Nystrum has some other good material on his blog, and a chapter in game programming patterns about PL stuff. Links: https://journal.stuffwithstuff.com/ https://journal.stuffwithstuff.com/ https://gameprogrammingpatterns.com/bytecode.html https://gameprogrammingpatterns.com/bytecode.html
- fooker 2y agoThis book should be the second or maybe third step of your journey into PL compilers. The first step is to write an interpreter yourself, for a simple language you create, without knowing anything about interpreters or language design. The second step is to rewrite it, and make less mistakes! :) If you don't do this, you are never going to appreciate the nuances of this topic. And you are going to skip over concepts that don't seem important.
- bruce343434 2y agoFor me, this book demystified these topics and allowed me to do your second and third step in the first place :) It's okay to not come up with/reinvent from first principles every technique on your own. It's normal to stand on the shoulders of giants.
- fooker 2y agoI'd think of it as riding a bike vs reading about riding a bike.
- macintux 2y agoI’d much rather have someone, or something, providing guidance as I learned to ride a bike. Of course you’re less likely to end up with a head injury writing an interpreter, but still, it’s not exactly a crime to learn before doing.
- kleinsch 2y agoWhen you learn to ride a bike, someone teaches you how to do it. You could go out and fall down a few times by yourself so it’s more fulfilling when you have instruction, but I wouldn’t say that’s the most efficient path.
- kccqzy 2y agoThat's exactly what I did. My own experience with the first step is to write a TeX-like language with macro definition and macro replacement. About a few days into the project I kept running into so many bugs that really instilled a more academic culture in me and I started to read books. But it was still a wonderful first step: without it you might not have even realized that this is a book-worthy topic.
- dgb23 2y agoThe secondary but perhaps equally important benefit of this book is that it teaches clarity. The text, code, structure and pacing, everything is clear and to the point. „Crafting“ is the right word, because the book feels like it’s written by and for craftspeople.
- dmeijboom 2y agoHa, neat! I’m building a dynamic programming language in Rust called atom (https://github.com/dmeijboom/atom https://github.com/dmeijboom/atom). It’s an interpreted language with a bytecode compiler. Will definitely check it out.
- nu11ptr 2y agoHow easy is it to follow along and yet build a statically typed language (instead of dynamically typed one as used in the book)?
- lolinder 2y agoDepends on your other goals for your language. If it's a statically typed language along the lines of TypeScript (where the static typing is just for safety, not performance) and you don't have any opinions about how it runs (compiled vs interpreted) then you can totally follow the book and then strap your type checker on later. If you have a compilation target in mind (llvm, wasm, jvm luajit), the first half of the book won't get you much closer to it (you'd have a parser) and the second half would have to be heavily adapted to output your target format instead of the highly specialized custom bytecode the book uses. And in neither case does the book directly help you with using type information to improve efficiency, so without adaptation you'd end up with a language that has static typing for safety but still does type checking at runtime. That's not a bad problem to have, you can always come back and strip away checks later as you get more confident.
- lifeinthevoid 2y agoWhat bothered me a little bit while following the book was that copying the code doesn’t result in compilable code all the time because there is code missing that is only introduced later. I get why the author chose to follow this path, but I’m from the club that every commit should compile and was annoyed a bit by that.
- metadat 2y agoWhat do you think the author's intention was behind doing it this way?
- eyelidlessness 2y agoDoing it the other way is a common pitfall in teaching programming concepts. A very common example is the historically necessary boilerplate in Java’s Hello World, where quite a few concepts are present but handwaved away as you don’t need to worry about this now. The problem with this is twofold: 1. It is challenging to distinguish the pertinent from the impertinent. People who are just starting won’t be able to tell what parts of the code deserve their attention now. 2. It is challenging to retroactively draw attention to previously dismissed details once they do become pertinent. I think there are other ways to address this, with additional formatting considerations in the presentation of example code. But there’s still a problem once the reader wants to tinker with the code, as any such formatting will be lost between a carefully tailored example rendering and the user’s code editor.
- BoiledCabbage 2y ago> Doing it the other way is a common pitfall in teaching programming concepts. 100% disagree If someone is brand new to programming and you're expecting to teach them the following concepts: A class, methods, static methods, data types, method return types, void return type, arrays, and namespaces just to be able to write a simple "Hello World" app [1] I think your approach is the one that's misguided. The most common mistaken people make in teching is teaching things in the order the were discovered historically. Not always, but very often that is a distraction. The second most common is teaching from the outside in. The best way to teach is to explain what your tyring to accomplish and start with a very simple example for people to play with. Then pick on concept and modify it so they can see the results of those changes. Then pick the next concet and modify that so they can see tangibly what that means. In the hello world example, it would be starting with the program in [1] and focusing just on the constant string "Hello World!". Change it see what that means, understand what's going on. Then move out to the Console.WriteLine. Make a copy of that line have two lines of it then 3 to understand the method call. Then swap to Console.ReadLine to see what a different method call can do. Continue exploring out from that core concept. The "static" identifier on a method class is not where to start teaching someone programming. It's also why Racket removed a lot of the boiler plate from thier core teaching langauges for students. For them to not even have to see the things that are unnecessary at that point in their learning.[2] [1] https://www.geeksforgeeks.org/java-hello-world-program/ https://www.geeksforgeeks.org/java-hello-world-program/ [2] https://docs.racket-lang.org/drracket/htdp-langs.html https://docs.racket-lang.org/drracket/htdp-langs.html
- munificent 2y agoAuthor here. Seeing all of the positive comments about my book is really warming my heart. I appreciate everyone and I'm glad so many people have enjoyed the book. I put a ton of time and love into it and it's gratifying to see it had the effect I'd hoped for.
- WJW 2y agoThank you for writing the book! I'm currently almost done with the first part (doing it in Haskell because why not) and every chapter I encounter situations where my "clever hack" turns out not to be so clever in the light of later requirements. It's been great fun so far. Have you considered writing up a follow-up book doing (say) a compiler or a JIT or something for Lox? PS: the lexical analygator is the best and has shown up (with attributions of course) in several of the internal presentations at $WORK. At one point we even had fan art of him on the whiteboard, but it had to be sacrificed when we had a particularly large diagram to put on there. :|
- iftheshoefitss 2y ago[flagged]
- munificent 2y agoIt's my favorite illustration in the book too. :)
- iftheshoefitss 2y agoon bro
- munificent 2y agoYes, people have definitely asked for a follow-up on compilers and/or static types. There's a little context here: https://news.ycombinator.com/item?id=40956138 https://news.ycombinator.com/item?id=40956138 I'm not sure if I'm the best person to write a compiler book, or, at least, not yet. I've written a lot of language front ends and interpreters, but I don't have much experience targeting native code. It's something I've wanted to do for a long time, but haven't made the time to make it happen. Static types are also hard for the reasons the linked comment talks about. I still think about it sometimes, but writing a book is a lot of work and I've been enjoying not writing a book for the past couple of years. :)
- kqr 2y agoFor someone who has sporadically worked through large parts of the dragon book over time (I'm not sure the dragon book is appropriate to consume from cover to cover), and written a couple of tiny interpreters and compilers for fun -- will committing the time for Crafting Interpreters book be revelatory or more of the same? I've long been curious.
- zengid 2y agoI cherish this book, its fantastic. I love all of the tidbits about PL history in the margins, and its a great guide through the world of language design. If you're looking for a follow up, I might have a recommendation. I recently got Essentials Of Compilation by Jeremy G. Siek, and I'm very excited to find some time to read it. There is a version implemented in python and racket (two separate books), so you can pick what you're more comfortable with. (I chose python). Its very elegantly written and after each chapter you end up with a working compiler.
- fuzztester 2y agoI just checked it out. apart from the book which you can buy, there is an open access edition, linked from the MIT press page, thanks to funding by Google, they say: https://github.com/IUCompilerCourse/Essentials-of-Compilation/releases/tag/racket-MIT-press https://github.com/IUCompilerCourse/Essentials-of-Compilatio... .
- endgame 2y agoFinishing the C interpreter gave me enough confidence to begin my own, from-scratch, interpreter project. Thank you, Bob.
- packetslave 2y agocodecrafters (YC S22, http://codecrafters.io http://codecrafters.io) has a new module called "Building Your Own Interpreter" that works its way through this book. It's great because you work in small chunks, each of which has unit tests to tell you if you got, e.g. scanning string literals correct. Currently free while the module is in beta. I spent today working through all of the lexer exercises in Rust (I'm currently learning it), and had a lot of fun.
- iainctduncan 2y agoI love this book, it's an excellent and refreshingly readable complement to more academic texts. I recommend pairing with Friedman's "Essentials of Programming Language". While I also love the Friedman, it's nice to read some PLT without feeling like I got punched in the face sometimes... ;-)
- deknos 2y agoI would wish, there's a german version which i could buy as hardcopy :D
- Piraty 2y agohttps://corecursive.com/032-bob-nystrom-on-building-an-interpreter/ https://corecursive.com/032-bob-nystrom-on-building-an-inter...
- kjlojpo 2y ago[flagged]