There is no “the interpreter” in Ruby. Ruby is programming language, a programming language is an abstract mathematical object, a set of logical rules and restrictions.
There is an ISO specification for a subset of Ruby. There used to be a comprehensive set of executable examples written in Ruby, called RubySpec, but unfortunately, it was abandoned by its maintainers because of a lack of buy-in by the language designers of Ruby; however, several implementations still use it internally for their testing, e.g. Rubinius and JRuby. There is also a set of tests that are meant to specify the behavior of the language in the YARV implementation, which is the implementation that most of the language designers are hacking on.
There are several implementations of Ruby, however, none of those implementations is an interpreter, all of them have at least one, some multiple compilers:
- Rubinius, a two-stage mixed-mode implementation consisting of a Ruby-to-bytecode-compiler written in Ruby, a kernel and core libraries written in Ruby, and a VM written in C++ with a bytecode interpreter and an LLVM-based JIT compiler.
- Topaz, a two-stage mixed-mode implementation built with the PyPy framework consisting of a Ruby-to-bytecode compiler and a VM with bytecode interpreter and JIT compiler written in RPython, and a kernel and core library partially derived from Rubinius.
- MagLev, a two-stage mixed-mode implementation built on top of the GemStone/S Smalltalk platform consisting of a Ruby-to-bytecode compiler and a more or less unmodified GemStone/S Smalltalk VM.
- IronRuby, a two-stage mixed-mode implementation built on top of Microsoft’s Dynamic Language Runtime and Common Language Infrastructure, written in C#.
- JRuby+Truffle, a new implementation of Ruby based on JRuby and the Truffle AST interpreter framework.
- JRuby, a two-stage mixed-mode implementation built on top of the Java platform, written in Java.
- MRuby, a small, lightweight, embeddable implementation of a subset of the ISO Ruby specification. (This is the implementation that the creator of Ruby is working on himself.)
- YARV, a two-stage implementation consisting on a Ruby-to-bytecode compiler and a bytecode interpreter, as well as a core library, all written in C.
- Opal is a Ruby-to-ECMASCript compiler, which unfortunately does not 100% accurately implement the semantics of the Ruby language.
I have tried to order them from easiest to hardest readable sourcecode, and incidentally also (almost) from most to least interesting. (I think JRuby+Truffle is extremely awesome and should be right up there with Rubinius and Topaz when it comes to interesting ideas about how to make Ruby blazing fast.)
The reason why I ordered them from easiest to hardest readable sourcecode is because, well, there really aren’t any books that describe the various implementations. Reading the source is probably your best bet. However, the classic Smalltalk-80: The Language and its Implementation (aka the Blue Book) was a heavy inspiration for the design of Rubinius. JRuby+Truffle, being a research project, has had a fair number of papers published, though.
There’s a Ruby Bibliography Page which has some links to papers, mainly about JRuby+Truffle, but also about MagLev and JRuby.
solved Ruby Book recommendations for how it works under the hood? [closed]