MacRuby Marches Onwards
Tháng Tư 2, 2009
It was just several months ago that we first began to mention MacRuby on Ruby Inside, but it’s been coming on by leaps and bounds since then. MacRuby is a Mac OS X-based Ruby implementation that works on the Objective C runtime. It’s based on Ruby 1.9 and uses the YARV VM (as Ruby 1.9 does) but will be switching to LLVM at the next major release. MacRuby is attempting to make Ruby a first class OS X development language.
The developments so far have been very promising and a lot of MacRuby news has come out in the past few weeks, which I’ll try to summarize:
MacRuby 0.4 Released
MacRuby 0.4 was released a few weeks ago. Lots of new goodies too: a threaded garbage collector, full 64 bit support, DTrace probes (DTrace being a rather cool tracing feature in Solaris, FreeBSD and OS X), an Objective C API (so that MacRuby can be controlled from other Cocoa apps), and new Xcode templates.
MacRuby’s samples are now particularly compelling. You can put together a fully(ish) featured OS X application in Ruby (using MacRuby), use Cocoa, and look fully native, but without the downsides of RubyCocoa (horrendous method names, for one). It’s also possible to package up MacRuby based apps into regular OS X applications without too much difficulty, since MacRuby’s runtime can be bundled as a framework. You should also check out HotCocoa::Graphics – an easy-to-use graphics library that comes along with MacRuby.
MacRuby has signalled its transition into implementation adolescence by getting a snazzy new official Web site at http://www.macruby.org/
It’s not just a snazzy design though. This is probably my favorite Ruby implementation site already (although ruby-lang.org is pretty good) in terms of actually being useful. Relevant events, install instructions, blog posts, and download links are right there on the front page, along with the obligatory code example.
The design was by John Athayde.
Experimental 0.5 announced and.. the controversial benchmarks
MacRuby 0.5 has yet to arrive but it’s already causing a stir..
The biggest change is that MacRuby will be switching to an LLVM-based JIT compiler (layman’s translation: it should be super fast) and a new IO subsystem. The early performance benchmarks in the alpha of all alphas of 0.5 were so exciting that Antonio Cangiano wrote a blog post with lots of benchmark results and cool graphs and (with some disclaimers) stated “that at this stage of the game, MacRuby 0.5 is the fastest Ruby implementation around.” This caused, as most benchmarking tends to, a little bit of controversy to say the least.
I can’t blame Antonio’s enthusiasm, however. The early benchmarks show a generally positive picture of MacRuby’s potential performance with just a few benchmarks working out slow than Ruby 1.9.1 and the majority coming in at between 1.1 to 8 times faster than Ruby 1.9.1 (though with a very high standard deviation). Charles Nutter rightly pointed out that it’s wrong to call MacRuby the fastest anything just yet, since it still crashes for a lot of scripts and it’s a long way from being mature. He cites MagLev as an example of why premature performance parading can backfire.