3 ms·
I learned best in Scheme because you don't need to parse your input and can just evaluate a tree[0] (Parsing is, in my opinion, the most boring part about writi
by prezjordan 5y ago
I learned best in Scheme because you don't need to parse your input and can just evaluate a tree[0] (Parsing is, in my opinion, the most boring part about writing an interpreter!)
Chapter 7 of Crafting Interpreters lays out how an evaluator works in a pretty clean way [1]. I've also blogged about evaluating ASTs in JavaScript [2]
Lastly, Gary Bernhardt took it a step further and instead of "evaluating" code, "compiled" it to JavaScript (this tutorial uses Ruby) [3]. Very much a mind-blown moment for me.
Have fun!! Writing interpreters remains one of my favorite things to do when learning a new programming language.
[0] https://www.youtube.com/watch?v=aAlR3cezPJg https://www.youtube.com/watch?v=aAlR3cezPJg
[1] https://craftinginterpreters.com/evaluating-expressions.html https://craftinginterpreters.com/evaluating-expressions.html
[2] https://thatjdanisso.cool/programming-languages https://thatjdanisso.cool/programming-languages
[3] https://www.destroyallsoftware.com/screencasts/catalog/a-compiler-from-scratch https://www.destroyallsoftware.com/screencasts/catalog/a-com...