MacRuby 0.5 Will Have Faster VM Based on LLVM,

| by Werner Schuster on Mar 29, 2009. Estimated reading time: 2 minutes |

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.

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

MacRuby by Matt Aimonetti

Great article! For latest MacRuby news you can also follow @macruby on twitter.

Charles Nutter (jRuby) responds .. by Cameron Purdy

Re: Charles Nutter (jRuby) responds .. by Werner Schuster

Yeah - but be sure to read the comments on Antonio's article, for some clarifications/rebuttals (in particular Rich Kilmer's).

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

3 Discuss