Replacing AppleScript with Ruby
Subject:   Performance?
Date:   2007-03-01 07:18:19
From:   mattneub
Response to: Performance?


You raise two unrelated issues.

First, there's the question of actual timings. I haven't done formal tests, but rb-appscript sure feels a faster to me than running an AppleScript script. Of course most of the time in a real script is spent in communicating with and waiting for the target application, so the source language doesn't matter. But quite aside from the AppleScript compilation issue, AppleScript is full of hidden speed traps. Just the other day I wrote an AppleScript script that required accessing information in a List of 2000 Lists; the mere size of the list caused the script to bog down, plus the lookup involved looping through the whole LIst because AppleScript has no hashes. So basically my response would be that as soon as you need to get anything done other than talking back and forth with the target application, Ruby is faster and more liberating because you don't have to dance around and tweak in order to get decent performance.

As for maintainability of complex code, I'm sorry, I don't agree at all. I can't maintain or even read an AppleScript script of any size. Ruby's object-orientation is all about maintainability, plus, as I say in my book, I find AppleScript's verbose English-likeness, and the bizarre verbal dances you have to do in order to perform simple string manipulation, completely illegible.