Hacker News new | past | comments | ask | show | jobs | submit login

Lox is a more featured language than Monkey, meaning that you'll learn more techniques to implement those features. Lox has classes and a garbage collector for the bytecode implementation and is closer to C++'ish languages. While I think Monkey is closer to Javascript.

That being said, I've implemented both in C# (during peak quarantine seasons) and I don't regret doing both of them as they cover slightly different aspects or do the same things differently. Both books are well written, meant for non-CS programmers, and patiently guides you through small chunks of code, so that you end up with an actual working interpreter. As opposed to other books I've seen where there are long blocks of code explained by long paragraphs, and rely on you looking up the "accompanying source code" to figure out how the code pieces together. Thorsten Ball also acknowledges that he also learned from Nystrom's Wren, so there are some things that follow the same approach (the Pratt parser if I remember correctly). WAIG also documents some clever simple optimizations which is nice to know on top of having implemented Lox.

What I appreciate most from WAIG that is absent in CI is how it re-uses its AST from the tree-walking interpreter to make a byte code interpreter. CI on the other hand, writes the bytecode interpreter from scratch (C instead of Java) and doesn't cover how to emit bytecode given an AST (something I had the fun of doing myself for Lox) as it took the single pass compilation approach (with focus on efficiency).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: