5 ms·
Ruby MRI Source Code Idioms #1: Accessing Data Via Macros
- haberman 14y agoMRI is the first language interpreter that I got deeply familiar with and it's a pleasure to read. It was really nice to be able to find the answer to questions like "how does Ruby decide when to trigger a thread switch" by spending just a few minutes going to the source.
- pat_shaughnessy 14y agoAbsolutely - it is a pleasure to read. Someday I'd like to learn how another language is implemented, maybe JavaScript or something like Haskell, but I'm afraid the language source code will be much more difficult to understand than Ruby's is.
- dysoco 14y agoYou can maybe start with a Scheme parser, it's quite simple.
- pat_shaughnessy 14y agoInteresting idea - thanks for the suggestion!
- pimeys 14y agoSICP - chapter 4. http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-25.html#%_chap_4 http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-25.html... One of the best chapters in any book I've ever read. So mindblowing. Or if you prefer the video form, here: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/7a-metacircular-evaluator-part-1/ http://ocw.mit.edu/courses/electrical-engineering-and-comput... http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/7b-metacircular-evaluator-part-2/ http://ocw.mit.edu/courses/electrical-engineering-and-comput...
- pat_shaughnessy 14y agoYup, (re)reading SICP is definitely on my list!
- 1337p337 14y agoOnce you can read some C, I'd recommend reading over another bytecode interpreter, like mawk (Mike's AWK): http://invisible-island.net/mawk/ http://invisible-island.net/mawk/ . Another good read is the TinyCC compiler (originally by Fabrice Bellard, who did QEMU among other things): http://savannah.nongnu.org/projects/tinycc http://savannah.nongnu.org/projects/tinycc . It's a small, mostly readable, fully functional C compiler.
- pat_shaughnessy 14y agoAwesome links - thank you!
- gtani 14y agoGHC (haskell compiler) is very well documented: http://www.haskell.org/haskellwiki/Research_papers/Compilation http://www.haskell.org/haskellwiki/Research_papers/Compilati... http://www.scs.stanford.edu/11au-cs240h/notes/ghc-slides.html#%287%29 http://www.scs.stanford.edu/11au-cs240h/notes/ghc-slides.htm... http://www.aosabook.org/en/ghc.html http://www.aosabook.org/en/ghc.html appendix: http://www.doc.ic.ac.uk/~amc4/Papers/thesis.pdf http://www.doc.ic.ac.uk/~amc4/Papers/thesis.pdf
- danso 14y agoCool work, again, Pat. Makes me wish I was back in school and could justify spending more time on looking at the internals and finding that satisfaction in knowing how things truly work under the hood.
- pat_shaughnessy 14y agoThanks! Yea for some reason learning how things work is often more satisfying to me than building stuff... I guess I'm more of a scientist than an engineer?
- doktrin 14y agoVery interesting indeed, sir. I've personally also found a lot of joy in diving down into C implementations (in my case, the JNI, although Ruby is my language of choice). You've certainly inspired me to take a closer look at the MRI, as well as macros in general. Thanks!