Has AppleScript Lost Its Luster?

Peter Cooper at the RubyInside blog has a great post on the feasibility of using the Ruby scripting language as an AppleScript replacement. Putting the fact that I'm a Ruby fanatic aside, Peter makes a good case for making the switch to Ruby for scripting OS X. The post links to a series of tutorials that demonstrate OS X scripting using the rb-appscript Ruby gem, which is a high-level Apple Event Bridge written in Ruby. Using rb-appscript, the following AppleScript code:

tell application "TextEdit"
get paragraph 1 of document "Read Me"
end tell

Can be written as the following one-liner in Ruby:

app('TextEdit').documents['Read Me'].paragraphs[1].get

We already know that Ruby got the royal treatment in 10.5 with the inclusion of Ruby on Rails and other Ruby niceties. Perhaps rb-appscript is a natural step in the Rubification of OS X.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Don't forget though-

Don't forget though- AppleScript is pretty user friendly to use as it is similar to English.
Although it could be written in one line with Ruby, generally you would have to know the language, or learn it.
AppleScript is easy - if you need something more powerful, then you can learn it. Replacing it with Ruby would be a bad idea, in my opinion.

About time

I never get the correct syntax for AppleScript. Back in the day when most good application were recordable, the situation wasn't that bad, but these days it seems only BBEdit can be recorded, and you really have to write the code.

I do like python better, but there is also appscript for python, so that isn't too bad. It would be nice if apple could admit defeat, and support python and ruby for scripting right out of the box, in the script editor.


Comparison between python and AppleScript

I posted back in December on using Python for scripting in Leopard. I provide a direct comparison between some AppleScript code, and the equivalent Python. I'll leave it up to you which you prefer....


Drew McCormack