Live data from Hacker News

Crafting Interpreters

craftinginterpreters.com

81–90 of 193 posts

Re: Crafting Interpreters

#81

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

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

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

Re: Crafting Interpreters

#82

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

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

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

Re: Crafting Interpreters

#83

Earlier quoted context omitted.

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

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

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.

Re: Crafting Interpreters

#84
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.

Re: Crafting Interpreters

#87
post #86

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

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.

Re: Crafting Interpreters

#88
post #56

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

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.

Re: Crafting Interpreters

#90
post #88
post #56

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

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 boo…

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

Post reply on HN