Developing Cocoa Apps with MacRuby

Appleis Developer Connection recently posted a tutorial on developing Mac apps with MacRuby. The advantage of MacRuby is that it bypasses the technology of the Ruby-Cocoa bridge and sits directly on top of core Mac OS X technologies such as Objective-C runtime, the generational garbage collector, and CoreFoundation.

As the tutorial explains, "Creating a bridge between two languages can be complex and come with certain costs in performance and true integration. Appleis open source project called MacRuby aims to address these problems.

"RubyCocoa is implemented as a bridge between the Objective-C runtime and the official Ruby interpreter. Because of this, the bridge must be crossed every time you talk to an Objective-C object from Ruby, and vice-versa. All objects must be converted from one typing system to another and messages must be forwarded, the cost for which can be prohibitive if done too often."

The introduction notes that MacRuby is re-entrant -- which means that it can be called from multiple threads safely. Also, garbage collection is conducted in a separate thread and doesnit interrupt the current process.

Ruby is a relatively new language that has gained enormous popularity in the Apple world lately. Itis companion system, Rails, allows for very fast Web development, and that has also contributed to the popularity of the language.

However, the RubyCocoa bridge that came before MacRuby isnit the only bridged language. Developers can also write native Mac applications with the PythonCocoa bridge, which is officially supported by Apple, as well as the PerlCocoa bridge, called CamelBones.

The Apple tutorial is extensive, technical and aimed primarily at developers who have experience with Ruby. Apple pointed out that MacRuby is a project still in development and progress can be followed in the MacRuby blog.