MacRuby 0.5 Will Have Faster VM Based on LLVM,
After the MacRuby 0.4 release brought a new graphics library and improvements such as a Threaded GC, the next version of MacRuby will feature improvements in performance.
A blog entry now explains the new LLVM based VM, which will replace YARV, in an experimental branch of MacRuby:
The new VM transforms the abstract source tree (AST) directly from the parser into LLVM's intermediate representation (IR), which is then compiled into optimized machine code. A number of other key optimizations have also been completed, such as fast fixnum arithmetic, cached method dispatch, zero-cost IA64 exceptions, fast instance variable access, constants caching, fast break/next, cheap local variables, tail call optimization and much more.
The source for Roxor, the new VM, is available in an experimental SVN branch. The
compile_node method basically takes the Ruby AST and turns it into LLVM instructions consisting of either primitives or calls to the Ruby runtime.
While MacRuby is based on Ruby 1.9.1, some of the changes such as the new experimental VM and use of Objective-C types can cause compatibility issues. To keep compatibility in check, MacRuby's integrated with RubySpec (from the blog entry):
The current experimental branch is already able to pass most of the language specifications and will be a standard part of our regression test suite. We are also actively working on upgrading the specifications to match the Ruby 1.9 behaviors.
RubySpec is an executable spec for the behavior of Ruby implementations, and was started by the Rubinius project.
Antonio Cangiano ran a few language feature microbenchmarks on the experimental MacRuby version, which yielded very good results compared to MRI and standard 1.9.1. It remains to be seen how the performance develops over the next release(s). Antonio also points out some of the advantages of MacRuby:
Rather than relying on a mix of Objective-C and Ruby (through a bridge like RubyCocoa), developers can use MacRuby which integrates with Mac OS X core technologies and acts as an alternative language to Objective-C. To be exact, Objective-C's runtime and generational garbage collector are at the heart of MacRuby, but from an API standpoint, programmers can write code in Ruby, instead of in the more verbose and low level Objective-C.
Considering the long list of GUI libraries and abstractions for Ruby, developers targeting OS X can simply MacRuby to build applications that tightly integrate with the Cocoa libraries, instead of having to use Objective-C.
Charles Nutter (jRuby) responds ..
Stephanie Davis (nee Stewart) Dec 21, 2014