4 ms·
This seems like it could be a great series, but maybe the author should wait a little next time until there is more content to post. I am currently reading Eng
by jdreaver 13y ago
This seems like it could be a great series, but maybe the author should wait a little next time until there is more content to post.
I am currently reading Engineering a Compiler, and I eventually want to build my own small, interpreted language. Does anyone know of any great resources to supplement that book that is particular to interpreted languages? Is a supplement really needed?
- gamegoblin 13y agoI think SICP (http://mitpress.mit.edu/sicp/ http://mitpress.mit.edu/sicp/) is definitely worth a read as far as implementing small languages goes.
- milin 13y agoThe Dragon Book. http://www.amazon.com/Compilers-Principles-Techniques-Alfred-Aho/dp/0201100886 http://www.amazon.com/Compilers-Principles-Techniques-Alfred...
- anaphor 13y agoThis wouldn't be very useful for building a small interpreter.
- anaphor 13y agoPL:AI http://cs.brown.edu/courses/cs173/2012/book/ http://cs.brown.edu/courses/cs173/2012/book/
- dmunoz 13y agoIf your goal is to work with an interpreted language, I would leave reading about compilation until later. This is often how it is taught in university courses, the first being learning language theory and implementing interpreted languages, and the second on theory and implementation issues of compiled languages. Others have already suggested SICP and PLAI, and these are great. PLAI is in the manner of what the first course would cover, and SICP does a bit of both. Two more I know of are Scheme from Scratch http://michaux.ca/articles/scheme-from-scratch-introduction http://michaux.ca/articles/scheme-from-scratch-introduction Write Yourself a Scheme in 48 Hours https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_... There was a good video at PyCon US 2013 this year So you want to write an interpreter? http://pyvideo.org/video/1694/so-you-want-to-write-an-interpreter http://pyvideo.org/video/1694/so-you-want-to-write-an-interp... It gives a forty minute, high level overview of what is done to implement an interpreted language.
- tel 13y agoWrite yourself a Scheme is pretty magnificent.
- adamnemecek 13y agoA friend bought this book and it seems pretty great and seems to be exactly what you want. http://createyourproglang.com http://createyourproglang.com
- eliben 13y agoI you want to see some real Python internals (complete with low-level C gore), take a look at Yaniv Aknin's series starting here - http://tech.blog.aknin.name/2010/04/02/pythons-innards-introduction/ http://tech.blog.aknin.name/2010/04/02/pythons-innards-intro... ... and my own series - http://eli.thegreenplace.net/category/programming/python/python-internals/ http://eli.thegreenplace.net/category/programming/python/pyt..., in particular starting with http://eli.thegreenplace.net/2010/06/30/python-internals-adding-a-new-statement-to-python/ http://eli.thegreenplace.net/2010/06/30/python-internals-add...
- vidarh 13y agoFirst question is what type of language are you aiming for, and what your goal is. If you're e.g. aiming for a LISP, or other language with a very small grammar, then you need only very rudimentary understanding of parsing, and so spending lots of time reading about it will be mostly wasted (for the purpose of the interpreter - you'll still get good uses for it). If you're planning on a language with a bigger grammar, then most compiler texts covers that in excruciating detail, but often overly so for the needs of an interpreter. If you want to build and manipulate an AST in particular (but for the love of all that is good don't aim to interpret the AST - it's horribly slow; if you want to go there, at least generate a simple bytecode, in which case all that compiler reading will pay off). But if you "just" want something simple, and the LISP or Scheme implementations are not for you, you might be happier with something like Niklaus Wirth's "Compiler Construction" (PDF: http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf ) - note that this covers building a full compiler for Oberon-0, a subset of the already minimal Oberon. But Wirth's style is a good one to take a look at, because his compilers are extremely small and simple and easy to learn from, and very conservative about what features they use. They won't teach you how to compiler/interpret "fancy" features like closures etc. (Wirth is very much a minimalist) - check out LISP/Scheme and Smalltalk for the fancier stuff (you should) - but Wirth will give you a foundation that is solid for the simpler stuff, and be more applicable to many languages that are more mainstream than the above. And it's quite easy to follow. The compiler described in the book generates code for a hypothetical RISC architecture, and a virtual machine for it is include in ca 1.5 pages of Oberon (easily transliterated to another language - Oberon is similar to Pascal or Modula, and readable for e.g. C programmers relatively easily). It's a simple way of getting started experimenting, for example by letting you modify the architecture and generated code to experiment with simpler instructions or "superinstructions" etc.. And the Oberon-0 compiler itself is "easily" adapted / extended.
- robomartin 13y agoForth. Definitely Forth. Start here: http://www.amazon.com/Threaded-Interpretive-Languages-Design-Implementation/dp/007038360X http://www.amazon.com/Threaded-Interpretive-Languages-Design...