The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
MacRuby 0.2

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ruby MacOSforge

Posts: 26
Nickname: rubymac
Registered: May, 2008

Mac OS X related Ruby News from Apple
MacRuby 0.2 Posted: Jun 6, 2008 5:51 PM
Reply to this message Reply

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.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Ruby MacOSforge
Latest Posts From Mac OS X related Ruby News

Advertisement

After 3 months of development, here comes the second release of MacRuby, 0.2! Check it out while it's still hot!

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.

a=[]; 100_000.times { |i| a.insert(0, i) }
MacRuby version 0.2 (ruby 1.9.0 2008-06-03) [universal-darwin9.0]
    0.326057
    0.318714
    0.314731
ruby 1.9.0 (2008-06-03 revision 16762) [i686-darwin9.0.0]
    4.308484
    4.382623
    4.36368
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
    4.608796
    4.595334
    4.581045

Regarding hashes, searching for a specific value (which isn't something that is typically done) reveals to be faster.

h = Hash[*(1..10000).to_a]; 10000.times { |i| h.has_value?(i) }
MacRuby version 0.2 (ruby 1.9.0 2008-06-03) [universal-darwin9.0]
    0.965304
    0.955293
    0.950316
ruby 1.9.0 (2008-06-03 revision 16762) [i686-darwin9.0.0]
    3.790461
    3.804271
    3.815217
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
    4.225632
    4.225457
    4.239244

And to finish with strings, it turns out that manipulations on multi-byte strings are faster in MacRuby than 1.9, thanks to CFString.

$ cat t3.rb
# -*- coding: utf-8 -*-
s = "わたしはロランです。" * 2000
s.length.times { |i| s[i] }
$ ruby b.rb t3.rb
MacRuby version 0.2 (ruby 1.9.0 2008-06-03) [universal-darwin9.0]
    0.180019
    0.180165
    0.177425
ruby 1.9.0 (2008-06-03 revision 16762) [i686-darwin9.0.0]
    1.624943
    1.633502
    1.62767

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!

Read: MacRuby 0.2

Topic: MagLev handles trees like a monkey Previous Topic   Next Topic Topic: Write your javascript in ruby with rubyjs

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use