Re:GoAWK: an AWK interpreter written in Go
by simplegeek on Sunday November 18, 2018 @12:37PM
(#18481511)
I also really like such posts. I have never written an interpreter. What do experts recommend i.e. how can someone without a formal CS background learn about write an interpreter? Any good sources, articles, or books? Thanks in advance.
[ Parent
| on HN ]
Re:GoAWK: an AWK interpreter written in Go
by nprescott on Sunday November 18, 2018 @05:20PM
(#18482805)
Depending on how involved the language you are interpreting is, you might get by having only read chapter 6 of The AWK Programming Language[0] (linked in the article), which covers "Little Languages", including what it terms an assembler and interpreter.
If you are interested in more depth, either Crafting Interpreters[1] (mentioned in the article) or Writing an Interpreter in Go[2] looks promising. I've read more of Crafting Interpreters and really enjoy it, though it isn't yet finished. One of the aspects I really enjoy is that the language is implemented and re-implemented in different languages to gradually introduce lower level concepts.
Finally, this one may be a little more "out there" than what you are looking for, but if you are interested in designing a language more than the plumbing of an interpreter Beautiful Racket[3] is really good.
caveat: not an expert
[0]: https://ia802309.us.archive.org/25/items/pdfy-MgN0H1joIoDVoI...
[1]: http://www.craftinginterpreters.com/
Re:GoAWK: an AWK interpreter written in Go
by benhoyt on Sunday November 18, 2018 @05:01PM
(#18482728)
Sure! I also don't have a formal CS background (I studied electrical engineering without doing any programming / CS courses). Bob Nystrom's free online book http://www.craftinginterpreters.com/ is excellent. There's also the (much older but still enlightening) "Let's Build a Compiler" by Jack Crenshaw: https://compilers.iecc.com/crenshaw/