return to table of content

Crafting Interpreters

chasil
20 replies
16h1m

The 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/l...

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/

The original introduction to lex and yacc was in the book by Kernigan and Pike:

https://scis.uohyd.ac.in/~apcs/itw/UNIXProgrammingEnvironmen...

gavinhoward
7 replies
15h57m

As 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
3 replies
15h42m

Is 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_...

gavinhoward
2 replies
15h25m

The 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
1 replies
15h20m

I commiserate, it can be unforgiving, and the use of C is admittedly out of vogue.

nicoburns
1 replies
13h3m

Are POSIX utilities even portable? They tend to have poor windows support. And they also tend to target C, which has a high ceiling for portability, but also a high bar for making things portable (whereas more modern languages are often just portable by default).

My take on POSIX utilities would be only to use them on Linux platforms where they effectively form a "native" part of the platform.

gavinhoward
0 replies
12h38m

I was mostly speaking about POSIX, since that was the focus of GGP.

Yes, you should only use them on POSIX.

My utility does build natively on Windows, though.

rnart
0 replies
6h13m

I disagree here. The syntax can be infuriating at first, but once you understand it, Lex/Yacc are rock solid and speed up development significantly.

runevault
6 replies
13h44m

Does a single production compiler use lex and yacc to generate any part of their system, beyond maybe a first pass to test out syntax before it gets rewritten into a hand written parser/lexer? I'm not going to say none exist since I don't know literally every production compiler ever written, but I have never heard of one that used them for the final code.

pansa2
3 replies
13h37m

I think Ruby does? IIRC its source code includes a 10,000+ line “parse.y” file which is converted to C code using Yacc.

runevault
0 replies
13h20m

Just went and looked in the github repo. 16,000+ line .y file. I can't imagine that is pleasant to maintain.

runevault
0 replies
13h32m

Interesting, I'll have to look into this because I'd never heard that before and now I'm curious.

A language with as much going on as Ruby was not one I would have picked as a candidate for yacc

ufo
0 replies
30m

Python notably switched from hand written recursive descent, to a PEG based parser generator.

But indeed, last I checked, recursive descent was the most common choice overall.

rnart
0 replies
6h18m

Yes, OCaml with its very complex syntax and hundreds of features uses the OCaml equivalents of Lex/Yacc. It is a myth that one cannot use Lex/Yacc in production.

pdpi
0 replies
14h56m

For a few reasons.

One, because actually building the lexer and parser from scratch is a useful exercise in a learning context, which is what this is.

Two, because the book wants to teach Pratt parsers, rather than LALR parsers. There’s a lot of literature out there on LALR parsers and generated parsers in general, but precious little on handrolled parsers. Covering material that hasn’t been covered to hell and back is a Good Thing.

Three, because lex and yacc generate C, and the book has two implementations of the interpreter, in C and Java. You could’ve used ANTLR to generate both parsers, but lex/yacc would only cater to the C version

And finally, because not everybody is on a POSIX system. Before WSL, using anything Unix-y on Windows was miserable. These days it’s mostly fine, but using WSL means you’re not actually building windows-native stuff anymore.

jahewson
0 replies
13h10m

Parser generators create more problems than they solve.

fmbb
0 replies
7h21m

Is there any reason to reach for them first?

cdcarter
0 replies
32m

The Unix Programming Environment tutorial for building hoc doesn’t even come close to what Nystrom gets into in Crafting Interpreters. Hoc is a very fun little language, but as Nystrom describes several times in the book…parsing just isn’t the interesting part of the game.

1f60c
0 replies
9h13m

Bob addresses this in the introduction^:

We will abstain from using [parser generators] here. I want to ensure there are no dark corners where magic and confusion can hide, so we’ll write everything by hand. As you’ll see, it’s not as bad as it sounds, and it means you really will understand each line of code and how both interpreters work.

^ https://craftinginterpreters.com/introduction.html#the-code

alabhyajindal
12 replies
13h14m

I 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.

grumpyprole
2 replies
12h2m

When Java gets pattern matching, it will become a more reasonable choice to write an interpreter in.

CraigJPerry
1 replies
11h38m

It’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.

grumpyprole
0 replies
8h23m

I think there should be a second edition of this book then :)

jasonjmcghee
1 replies
12h47m

For 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
0 replies
12h33m

That's great advice. Thank you!

snats
0 replies
12h49m

You can do the second part that is C!

miki123211
0 replies
9h45m

The Java it uses is basically understandable regardless of what language you're used to.

I guess if you're extremely early in your career and have never written anything but Python, it might not be, but if you've ever touched any statically-typed language and a language with a somewhat C-like syntax, you should be fine.

dukeyukey
0 replies
8h38m

Java is pretty readable, as long as your familiar with C-style languages you shouldn't have too many problems rewriting this in another language.

bluedays
0 replies
12h17m

I’m glad it used Java. I wound up rewriting the code in Python and it really helped me understand the concepts a lot better.

WJW
0 replies
8h7m

Don't use Java then. The Java bits are just an example, you can write it in any language you want.

SatvikBeri
0 replies
6h11m

Lots of people have done implementations in other languages: https://github.com/munificent/craftinginterpreters/wiki/Lox-...

I did the first half in Clojure (in order to teach myself Clojure), worked just fine. I had to do a bit of translation but it's really not a lot.

Derbasti
0 replies
9h53m

It does. The second half is written in C. Java is just used for the simplified first part.

brcmthrowaway
7 replies
16h36m

Is this book still relevant?

metadat
1 replies
16h32m

Yes, 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
0 replies
15h55m

It’s an incredible book. Munificent did an amazing job.

runevault
0 replies
13h47m

This 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.

rassibassi
0 replies
8h5m

CFG (context free grammar), which is explained in the book, is used here together with LLMs: https://tree-diffusion.github.io

linhns
0 replies
10h44m

Super. Bob’s way of presenting his content is what I feel the most important to get out of. Great communicator.

danielvaughn
0 replies
16h34m

Definitely. 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
0 replies
16h33m

It's a 3 year old book on compilers, so if it was ever relevant once, it surely still is today!

IAmLiterallyAB
7 replies
14h48m

Planning to read this soon. Anyone got any other compiler book recommendations? Preferably modern (I've heard the dragon book is out of date)

pansa2
2 replies
14h33m

Engineering 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.

bmoxb
1 replies
13h19m

I think Engineering a Compiler is a great next step after Crafting Interpreters. It's both easier to get into (in terms of writing style and structure) and, as you say, generally more practical than the Dragon Book.

eredengrin
0 replies
10h14m

Do you have any thoughts about how to read some of the next step books like Engineering a Compiler/Dragon Book? I don't normally read large technical books end to end so I'm curious how others approach it. I am going through Crafting Interpreters right now and I like how it has well defined checkpoints that help me know that I can move on when I understand the current material. I skimmed Engineering a Compiler and it looks like it has exercises as well, do you recommend all/some of those, or any other methods?

Also I did some searching to see past discussions of Engineering a Compiler and found this interesting comment thread from Bob Nystrom for anyone interested: https://news.ycombinator.com/item?id=21725581

chin7an
1 replies
14h42m

I’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/

signaru
0 replies
8h53m

Thorsten 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.

dils
0 replies
1h40m

"Writing An Interpreter In Go"[1] is also pretty good. I read it after finishing crafting interpreters.

[1] https://interpreterbook.com/

Arisaka1
6 replies
8h12m

Curious 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.

shortercode
0 replies
7h50m

This 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.

radiospiel
0 replies
7h56m

Im my experience following - as in actually doing the steps - works wonders.

foooorsyth
0 replies
7h8m

This book, unlike the infamous “Dragon Book” for compilers, can be read cover to cover. The Dragon Book has great detail but it is a slog, especially in early chapters. So many students drop their first course on compilers every year because of the Dragon Book and not the actual concepts

aodonnell2536
0 replies
7h49m

Well, in the instance of this book, you should follow along with the steps that Bob Nystrom writes for you. From reading it, it’s clear you’re supposed to follow along and write code “with him”. He even outlines exactly where each line of code should go, and explains why along the way.

anta40
0 replies
1h2m

Start at 1st chapter, try all the codes until you understand the concept. Then go to next chapter and repeat the process.

Measter
0 replies
7h50m

For 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.

trenchgun
5 replies
11h21m

Alright, I will finally read the book. It has been collecting dust in my bookshelf for a while.

tusharsadhwani
4 replies
11h19m

I finished this book, wrote the two implementations in Python and Zig, genuinely one of the best set of projects I've ever built.

ayhanfuat
2 replies
5h22m

How was the Zig experience? I am looking for an intermediate Zig project to practice Zig. Does this require advanced features of Zig?

cube2222
0 replies
5h3m

I’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
0 replies
36m

I’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!

dailykoder
0 replies
6h0m

Hmmm, 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.)

fooker
5 replies
6h47m

This 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
3 replies
6h24m

For 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
2 replies
2h23m

I'd think of it as riding a bike vs reading about riding a bike.

macintux
0 replies
2h4m

I’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
0 replies
2h4m

When 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
0 replies
43m

That'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.

eternityforest
5 replies
18h2m

Mad 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
4 replies
11h55m

It 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).

kazinator
2 replies
10h53m

L-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
1 replies
9h34m

Yes 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
0 replies
9h16m

More 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.

eternityforest
0 replies
11h3m

Actually 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.

xigoi
4 replies
9h42m

Does anyone know of a good resoucce for creating a statically typed language with stuff like parametric polymorphism and basic type inference?

zellyn
1 replies
4h2m

It’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
0 replies
3h51m

One 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! ;-)

rscho
0 replies
8h31m

Modern 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.

kccqzy
0 replies
38m

The 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... realized that it was written in an extremely outdated style, modernized it, cleaned up, and ended up with https://gist.github.com/kccqzy/fa8a8ae12a198b41c6339e8a5c459... Then I proceeded to change various things to "break" the algorithm and see how they are broken.

lifeinthevoid
4 replies
1h24m

What 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
2 replies
59m

What do you think the author's intention was behind doing it this way?

eyelidlessness
1 replies
31m

Doing 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
0 replies
9m

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/ [2] https://docs.racket-lang.org/drracket/htdp-langs.html

kccqzy
0 replies
46m

I am the opposite. I think pedagogical materials like this should introduce things in the order that makes intuitive sense, and most of the time that means from the easiest to the hardest.

liamilan
4 replies
14h52m

Read Crafting Interpreters when building 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
2 replies
14h29m

This looks cool! How did you decide on what data types to include?

myco_logic
1 replies
7h11m

Personal 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/

metadat
0 replies
2h25m

Really neat article, this is my first encounter with the concept of NaN Boxing. Thanks for sharing!

yodsanklai
3 replies
15h48m

I 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.

lolinder
0 replies
14h14m

It'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

linhns
0 replies
10h43m

Because it’s meant to be for those people

atan2
0 replies
15h13m

I 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.

chris37879
3 replies
16h22m

I 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_
2 replies
3h18m

This comment sold me. Gonna keep this as an inactive tab for the next couple months.

phyrex
0 replies
9m

Why not buy an copy and put it on your to-read shelf for the next couple of months?

BoiledCabbage
0 replies
8m

Just 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.

nu11ptr
1 replies
4h27m

How easy is it to follow along and yet build a statically typed language (instead of dynamically typed one as used in the book)?

lolinder
0 replies
4h15m

Depends 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.

cageface
1 replies
16h12m

The author is one of the lead developers for Dart, which has evolved over time into a pretty nice language.

throwaway032023
0 replies
2h58m

I 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.

sunday_serif
0 replies
15h22m

My 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!

runevault
0 replies
13h36m

Since 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=PLRAdsfhKI4OWNOSfS7EUu...

purple-leafy
0 replies
8h30m

Waiting on the shelf for me once I finish cs50

dmeijboom
0 replies
4h28m

Ha, neat! I’m building a dynamic programming language in Rust called atom (https://github.com/dmeijboom/atom). It’s an interpreted language with a bytecode compiler. Will definitely check it out.

dgb23
0 replies
4h53m

The 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.

britannio
0 replies
16h35m

I 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.