llvmruby: A Compiler Toolkit Available to Rubyists
If you've ever investigated how to build your own compiler, you might be familiar with LLVM (Low Level Virtual Machine), a "compiler infrastructure" that makes it easy(ish) to create virtual machines, code generators, and optimizers of your own. It also has its own intermediate representation language that's architecture independent and the instruction sets and typing system available are similarly language independent. In theory, if you want to build your own programming language and a compiler for it, LLVM will get you most of the way.
llvmruby is an attempt to bring LLVM's power into the grasp of Rubyists. LLVM is typically used from C++, but llvmruby lets you use the LLVM compiler infrastructure directly from the Ruby interpreter. It's still pretty new and only a subset of LLVM is currently usable, but it's under semi-active development by Tom Bagby, and as well as a blog, there's also a Github repository you can check out.
On the topic of LLVM, Miura Hideki has developed YARV2LLVM, a YARV (Ruby 1.9's VM) to LLVM translator. While it currently only accepts a tiny subset of Ruby, it's interesting because it uses LLVM's power to compiler YARV into very fast native code. The page is in Japanese, but one of Miura's early benchmarks is not hard to decipher.
November 28, 2008 at 10:22 am
Also note that there is ruby-libjit which is based on libJIT. libJIT is currently under GPL (there are plans to release under LGPL).
November 28, 2008 at 2:36 pm
Bonus points to anyone who gets the relevance of the picture on this post to the topic.. :)
Jan: Thanks!
November 28, 2008 at 2:44 pm
@peter Umm... Aho & Ullman’s baby? “Compilers: Principles, Techniques, and Tools”, aka the Dragon Book?
(Incidentally, I met Ullman last year at CUSEC; what a cool guy.)
November 28, 2008 at 2:49 pm
Wow - you are very quick! You now have "bonus points". Unfortunately, I do not know how to redeem them, but at the very least I am impressed :)