After 5 months of development, we are happy to announce the immediate availability of MacRuby 0.7.
This release does not bring any significant features but consolidates the existing functionality of MacRuby by improving its Ruby compatibility, concurrency, Cocoa support, and overall stability and performance.
You can download it from here. Please note that this package only runs on Snow Leopard (10.6). Older Mac OS X versions are no longer supported.
Please give it a try and let us know of any problems you find!
You can check out the complete release notes of this release, or continue with most visible changes here.
MacRuby’s previous release, 0.6, announced that support for Cocoa development was now stable. As a matter of fact, the Cocoa layer of MacRuby hasn’t changed much in this release, which confirms us that it is indeed stable.
A long-awaited enhancement to MacRuby’s Cocoa layer, support for C blocks, has been implemented in this release. You can now pass a Ruby Proc object to an API that expects a C block, similarly if this API expected a C function pointer. However, this new change requires additional BridgeSupport metadata which will be installed from our new, upcoming BridgeSupport release.
$ cat t.rb
framework 'Foundation'
a = [1, 2, 3, 4, 5]
a.enumerateObjectsUsingBlock(Proc.new { |obj, index, stop|
p obj
stop.assign(true) if index == 2
})
$ macruby t.rb
1
2
3
The sandbox facility is now exposed in MacRuby via the Sandbox class, and can now be used to restrict access to certain facilities in the current process and therefore limit potential damage that can happen if a vulnerability is exploited. It is a good companion to the Ruby standard $SAFE functionality, also supported in MacRuby, because it can constrain access to all system services used by the process, including by C extensions or Cocoa APIs, not just from pure-Ruby APIs.
Sandbox.no_internet # TCP/IP networking is prohibited.
Sandbox.no_network # All sockets-based networking is prohibited.
Sandbox.no_writes # File system writes are prohibited.
Sandbox.temporary_writes # File system writes are restricted to temporary folders.
Sandbox.pure_computation # All operating system services are prohibited.
Sandbox#apply! # Apply a given sandbox. Once a sandbox is applied,
# it can not be removed and no other sandbox
# can be applied on top.
In this release we also reduced the memory and disk footprint of the runtime.
The dispatcher has been rewritten to use a per-thread cache, which is a more efficient approach compared to the previous release. All reported race conditions and deadlocks have been fixed. We have been successfully running Sinatra applications under the ControlTower HTTP server in a concurrent fashion for the past weeks.
The MacRuby kernel, which contains the primitive functions called by the code generated by the compiler, is now pre-compiled into bitcode and included in the program’s module. Further optimization passes can now be applied and result in a significant runtime performance improvement.
A basic interpreter has been implemented and is now used to evaluate cold paths, determined at compilation time using simple heuristics. As an example, simple #eval statements creating code, a common pattern in Ruby libraries, now run significantly faster.
Further minor optimizations have been implemented, such as optimized code generation, faster instance variables access, and symmetric multiple assignments simplification.
A lot of work has been put in this release to increase the level of compatibility with existing Ruby programs and libraries. MacRuby 0.7 is the first release of MacRuby that targets the 1.9.2 version of Ruby, and therefore a number of new features have been re-implemented or backported.
This release passes an average of 90% of total RubySpecs, from about 82% for the previous release.
As always, Ruby compatibility is a work in progress, and MacRuby is still not able to run Rails out of the box. We believe that the next release of MacRuby will eventually implement the missing pieces.
We hope you enjoy this release and thank you for helping us converging MacRuby to a first stable release!