Re:A programming language from scratch: 3 steps to an interp...
by FrancisStokes on Thursday August 17, 2017 @03:14AM
(#15034440)
Hey - author here. You're completely right, but I hope the basic understanding will whet peoples appetites to try some more exotic stuff! Really I was just trying to lift the veil of what can be a quite intimidating subject if you haven't grazed past it before. Thanks for checking it out!
Re:A programming language from scratch: 3 steps to an interp...
by jeffhuys on Thursday August 17, 2017 @06:46AM
(#15035467)
Hey Francis, I just wanted to take a moment to tell you that I really enjoyed reading your article. Good stuff!
Re:A programming language from scratch: 3 steps to an interp...
by FrancisStokes on Thursday August 17, 2017 @01:11PM
(#15038659)
Thanks! I really appreciate you saying so, and I'm glad you enjoyed it
Re:A programming language from scratch: 3 steps to an interp...
by e12e on Thursday August 17, 2017 @10:26AM
(#15037044)
> One of the most enlightening points about interpreters/compilers is that, to a first approximation, the only difference between an interpreter and compiler is what it does when it walks the tree --- an interpreter executes the actions immediately, while a compiler generates code which executes those actions.
For something else in a similar vein, I've always liked:
http://howistart.org/posts/nim/1/
I suppose implementing brainfuck is more like writing a vm, than a language - but I still think the article is a surprisingly straightforward implementation of a compiler.
One of the most enlightening points about interpreters/compilers is that, to a first approximation, the only difference between an interpreter and compiler is what it does when it walks the tree --- an interpreter executes the actions immediately, while a compiler generates code which executes those actions.
An amazing demonstration of this is at https://news.ycombinator.com/item?id=8558822 and https://news.ycombinator.com/item?id=8746054 . It doesn't actually build an AST, but implicitly creates one and walks it since it does recursive-descent parsing.
(Aside: I happened to glance at the URL at the same time as I was reading the Tokenisation section, and thought "Francis Tokes? How appropriate..." before looking more closely at the page title.)