Disclaimer: I wrote this blog post. If this were an "Ask HN" post, though, the question would be "What next after reading Crafting Interpreters?" I have only done the tree-walk interpreter half of the book, but I'm already excited to move beyond Lox, and I'm curious to hear what others have done in this situation.
I'd do the second half of the book, it's got plenty of important techniques that aren't taught in the first half. Once you've done that, you can see how it's done "for real" in a production setting by reading the source code to Wren (by the same author). [0] Wren's implementation maps very closely to the C implementation of Lox. At that point, you're ready to do your own language. As far as compilation techniques go,…
Building a Lox Interpreter in Julia
21–25 of 25 posts
Re: Building a Lox Interpreter in Julia
#22Earlier quoted context omitted.
I'd do the second half of the book, it's got plenty of important techniques that aren't taught in the first half. Once you've done that, you can see how it's done "for real" in a production setting by reading the source code to Wren (by the same author). [0] Wren's implementation maps very closely to the C implementation of Lox. At that point, you're ready to do your own language. As far as compilation techniques go,…
I agree on the suggestion to do part two, it's where things get really fun! One thing you can do with the finished Lox (or Monkey, if you prefer WACIG) before going into the world of intermediate representations is implementing a peephole optimizer. You look for reducible patterns in the bytecode, and replace them with optimized bytecode. You can also look for certain patterns and replace naive implementations with n…
I'm not sure how far down the compiler I actually will enjoy going vs. exploring ideas around type systems, linters, etc. up near the AST level, but if I do venture down this advice will certainly come in handy!
Re: Building a Lox Interpreter in Julia
#23Disclaimer: I wrote this blog post. If this were an "Ask HN" post, though, the question would be "What next after reading Crafting Interpreters?" I have only done the tree-walk interpreter half of the book, but I'm already excited to move beyond Lox, and I'm curious to hear what others have done in this situation.
Personally, I found "Writing an Interpreter in Go" better than "Crafting Interpreters". It has a follow-up book titled "Writing a Compiler in Go", which (similar to Crafting Interpreter's second half) implements a virtual machine. The books take a lot of inspiration from Crafting Interpreters. If this sounds at all appealing to you, I would check it out. I found Monkey so far somewhat more compelling than Lox (might…
Re: Building a Lox Interpreter in Julia
#24Earlier quoted context omitted.
I'd do the second half of the book, it's got plenty of important techniques that aren't taught in the first half. Once you've done that, you can see how it's done "for real" in a production setting by reading the source code to Wren (by the same author). [0] Wren's implementation maps very closely to the C implementation of Lox. At that point, you're ready to do your own language. As far as compilation techniques go,…
I agree on the suggestion to do part two, it's where things get really fun! One thing you can do with the finished Lox (or Monkey, if you prefer WACIG) before going into the world of intermediate representations is implementing a peephole optimizer. You look for reducible patterns in the bytecode, and replace them with optimized bytecode. You can also look for certain patterns and replace naive implementations with n…
Re: Building a Lox Interpreter in Julia
#25Earlier quoted context omitted.
I agree on the suggestion to do part two, it's where things get really fun! One thing you can do with the finished Lox (or Monkey, if you prefer WACIG) before going into the world of intermediate representations is implementing a peephole optimizer. You look for reducible patterns in the bytecode, and replace them with optimized bytecode. You can also look for certain patterns and replace naive implementations with n…
Do you have any pointers to papers/books exploring peephole optimizers? I've read a few paper, but found them underwhelming…