This post originated from an RSS feed registered with Ruby Buzz
by Ruby MacOSforge.
Original Post: MacRuby 0.2
Feed Title: Mac OS X related Ruby News
Feed URL: http://www.macruby.org/feeds/posts/macruby/index.xml
Feed Description: Ruby news related to Mac OS X, from Apple.
This is an important release, addressing many bugs, but also re-implementing parts of the runtime using the CoreFoundation framework.
In MacRuby 0.2, all strings, arrays and hashes are now native Cocoa types, respectively NSString, NSArray and NSDictionary objects.
The entire String, Array and Hash interface was rewritten on top of the Cocoa equivalents, using the powerful CoreFoundation framework.
The previous implementation, inherited from MRI, is not used anymore. The rationale behind this change is simple.
It is not necessary anymore to convert Ruby primitive types to Cocoa, or vice-versa. For example, a String created in MacRuby can be passed as is, without conversion, to an underlying C or Objective-C API that expects an NSString. And vice-versa, any method of the Ruby String class can be performed on an NSString that comes from Objective-C.
Interestingly, the CoreFoundation implementation that MacRuby now uses reveals to be stable and perform very well.
We did not work on any performance improvement in MacRuby 0.2 (we will take care of this for the next upcoming release), but we noticed some dramatic performance gains, in some cases.
For example, inserting elements in an array is faster in MacRuby than the original 1.9 implementation. Mostly because CFArray switches on the fly its data structure to an implementation that performs well according to the current number of elements.
But MacRuby is still slower in many cases, including very important ones such as objects allocation and methods dispatch. And there are also too many areas in String, Array and Hash where we perform very bad.
We plan amongst other things to address this in the next release, 0.3, so stay tuned!