Hacker News new | ask | show | jobs
by liamilan 701 days ago
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.

3 comments

> when building Crumb (https://github.com/liam-ilan/crumb)

> As an aspiring engineer

I’ve got some good news for you.

> Aspiring engineer

You already made it, no need to be humble. You don’t need to finish the CS to call yourself engineer :)

Great documentation and an awesome project. Good job.

This looks cool! How did you decide on what data types to include?
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/

Really neat article, this is my first encounter with the concept of NaN Boxing. Thanks for sharing!
It 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 if anyone’s interested!