MacRuby 0.5 Beta Brings JIT, AOT, GCD Support, Removes GIL
The first beta of MacRuby 0.5 is available, currently only for Snow Leopard (MacOS X 10.6) machines.
InfoQ talked to the MacRuby core team about the present and the future of MacRuby.
InfoQ: How does MacRuby's new VM use LLVM?
MacRuby compiles everything at demand (when the code is actually meant to be run). The [LLVM] bitcode is sent through optimization passes before compilation.
The release notes for the MacRuby 0.5 beta also mention that LLVM is used to generate stubs for calling foreign functions because that's faster than using libffi, which is used in older MacRuby versions.
InfoQ: MacRuby Ahead-Of-Time (AOT) compiles some of the Ruby standard libraries. What's the reason for that?
The impact is definitely a faster startup time. We are principally AOT compiling them to test the AOT compiler. They are compiled at build time, as part of the main rake task.
InfoQ: What's status of supporting native extensions?
We are able to get some C extensions running, like ripper, digest, socket, zlib, etc. after a few modifications. It is our plan to fully implement the MRI C extensions API in a future release.
InfoQ: One of the big improvements in version 0.5 is the removal of the GIL. Now that's been implemented for a while, what's the experience with your solution?
As far as we know it doesn't bring any significant overhead. Starting a thread is slightly costlier than before but most of the code can run in parallel after.
The GIL-less system was absolutely necessary for MacRuby to become a real Cocoa development platform, since it is common for desktop applications to use threads or more recently grand central dispatch (GCD).
InfoQ: MacRuby allows to AOT compile Ruby code - but is it possible to opt out of the Garbage Collector, ie. is there a way to just use Objective-C's reference counting memory management?
It's not possible yet [..]. But we are considering a mode where the compiler would emit autorelease pools and where the runtime would not use the Autozone GC. If you browse the mailing-list archives you will see a recent discussion on that topic.
The mentioned mailing list thread discusses how to emulate the GC, which is crucial to get MacRuby programs to run on platforms that don't support the Autozone GC, eg the iPhone. Another mail in the discussion explains why porting Autozone to the iPhone isn't a solution, because the iPhone's Cocoa version isn't GC aware.
The final MacRuby 0.5 release will run on Leopard and Snow Leopard, both in 32 bit and 64 bit modes.
See previous InfoQ coverage of MacRuby, and the road towards version 0.5.
Ben Linders May 28, 2015