Learn Objective-C on the Mac - Mark Dalrymple [163]
PyObjC is included in both Leopard and Snow Leopard, and Xcode even has templates for making application projects using this right out of the box.
MacRuby
On the Ruby front, there are a couple of ways to bridge to Objective-C. For several years, a project called RubyCocoa has been available that works similarly to PyObjC in many ways. However, RubyCocoa seems to have stagnated, with most forward momentum having shifted to a newer project called MacRuby. This Apple-sponsored project aims to bring Ruby syntax to Cocoa in a whole different way. Instead of bridging between similar classes, MacRuby takes a different approach, basically jettisoning all the existing Ruby standard library classes, and using the Cocoa equivalents instead, often giving them new methods whose names match their equivalents in the Ruby world. This means that experienced Ruby developers who jump on a MacRuby project may find that lots of their favorite classes and methods are missing or subtly different.
One interesting difference between MacRuby and both PyObjC and RubyCocoa is that MacRuby goes the extra mile to make method calls feel similar to the way they do in Objective-C, while still working within Ruby syntax. This works is by a smart use of Ruby’s keyed arguments, using the name of the Ruby method being called, and the argument keys, to look for a matching Objective-C method. Returning to our previous example:
When MacRuby hits that second line, it uses the method name (postNotificationName) and the argument key (object) to look for an Objective-C method called postNotificationName:object: in the receiver (center), finds it, and calls it. If we didn’t include a keyed argument for object, or included other keyed arguments that aren’t part of the underlying method we’re shooting for, this method call wouldn’t find a matching Objective-C method, and would fail.
On top of all that, MacRuby offers some other interesting features, such as compilation to native code, both just in time and ahead of time. It has also moved away from the traditional Ruby VM, instead sporting a new runtime built atop of LLVM, which some of you will recognize as the most modern of the compilers that Xcode can use.
All of this is still pretty new. At the time of writing, MacRuby is less than two years old, and hasn’t produced a 1.0 version yet, but it’s definitely something to keep an eye on. http://www.macruby.org is the place to do so.
Nu
Another interesting language in this context is Nu. Unlike PyObjC and MacRuby, here it’s not a matter of interfacing an existing language to Objective-C. Instead, Nu is essentially a whole new language (really a Lisp variant) that is designed specifically for interoperation with Objective-C, so it features the same interwoven method and argument syntax. Let’s bring back that example one more time. Objective-C:
How about that! Of course, it’s not completely identical. Even ignoring the change from square brackets to parentheses, there are lots of other syntax changes when declaring classes, methods, and so on, often stemming from Nu’s origins as a Lisp-based language. However, in general there’s a lot here that’s immediately recognizable to an Objective-C developer.
Apart from the language itself, Nu also includes a command-line shell (nush), a make-like tool (nuke), and more. These tools add up to a package that lets you fire up a shell, and do some ad-hoc scripting using the Cocoa classes you know and love. You can interact with live objects, and take an exploratory approach to the Cocoa frameworks. Head on over to http://programming.nu to download it and see more about this interesting crossover between Cocoa and Lisp.
JavaScript
The odd-man out here, in some sense, is JavaScript. Everyone knows that JavaScript can be used to script web pages, but did you know that you can script your app with it? The WebKit framework included with Mac OS X won’t let you create an entire app in JavaScript, but it does let you build in a scripting layer, with or without a web view, that lets someone