Create full-fledged Mac apps that don't sacrifice performance and let devs enjoy the benefits of using Ruby

Oct 23, 2008 11:00 GMT  ·  By

Apple has posted a tutorial explaining how one can develop Mac OS X applications using MacRuby. The tutorial includes information ranging from installing MacRuby to creating complex applications in Xcode, Apple’s IDE.

“While Objective-C is the de-facto programming language for writing applications on Mac OS X Leopard, Ruby is also supported as a Cocoa development language via the RubyCocoa bridge,” Apple says. “In fact, Ruby and Objective-C share a common ancestor in Smalltalk, making them ideally suited for integration. This is evident in the popularity of RubyCocoa, which has served as the basis for several significant projects including the open source LimeChat IRC client, the commercial blogging application Blogo, and even Apple’s own Podcast Producer technology.”

MacRuby is a version of Ruby 1.9, ported to run directly on top of Mac OS X core technologies, such as the Objective-C common runtime and garbage collector, and the CoreFoundation framework. It is the goal of MacRuby to enable the creation of full-fledged Mac OS X applications that do not sacrifice performance in order to enjoy the benefits of using Ruby. MacRuby's boldest aims are still a work in progress, Apple reveals.

According to Apple, the easiest way to install MacRuby is to download one of the binary installers. You can also retrieve the sources from the source repository and build them manually. A page dedicated to Installing MacRuby will guide you through the process of getting MacRuby up and running on your Mac. MacRuby installs itself as a framework in /Library/Frameworks/MacRuby.framework. The whole project is self-contained there, making it very easy to bundle MacRuby with your application, Apple says.

Xcode and Interface Builder support are built right in MacRuby, as are several code examples in /Developer/Examples/Ruby/MacRuby. Executables are exported (in /usr/local/bin) as symbolic links, and they all start with the “mac” prefix. The only exception is hotcocoa.

“Given that MacRuby is an implementation of the Ruby language, everything that works in 'standard Ruby' should also work with MacRuby," Apple says. “Basic tasks like array manipulation and string processing or even advanced tasks like regular expressions and adding singleton methods to an object should 'just work',” the company adds. Full-fledged Cocoa applications (with all the specific advantages) can be written with MacRuby.

Via TUAW