Matt Neuburg: Replacing AppleScript With Ruby

Matt Neuburg:

My book, AppleScript: The Definitive Guide, describes and teaches the AppleScript language, but it also bemoans that language’s many failings. I won’t enumerate those failings here; let’s just stipulate that for some users, typically those with some experience of other programming languages, scripting Mac applications via Apple events would be a much more pleasant experience if AppleScript weren’t involved. In fact, I happen to be one such user.


The true benefits of using Ruby instead of AppleScript as a base for sending Apple events to scriptable applications emerge when you consider the relative merits of the two languages. You shed the clumsy, tricky verbosity of AppleScript, along with its gaping linguistic holes (such as the paucity of string-handling abilities) in favor of such Ruby elegances as regular expressions, iterators, blocks, and true object-orientation—not to mention all the power of Ruby’s vast built-in classes, libraries, and gems.

Wednesday, 28 February 2007