Applescript vs Javascript - Speed - Faster

Hello all,

I have been using Applescript for many years. Ever since I switched over to Leopard I have noticed that my Applescripts seem sluggish when they run from inside an Applescript based App built w/ Xcode. Not sure if this related to Leopard.

Recently I have been exploring Javascript for automation as an alternative to Applescript and I have noticed that it is much faster completing tasks (especially w/ Adobe Creative Suite).

Any thoughts on these two speed issues w/ Applescript would be greatly appreciated.

Thanks,
CarbonQuark

I use both with CS2 but have not put into Xcode app. AppleScript re-draws the screen which may eat-up some time JavaScript does not unless you ask it too. Run a Photoshop JavaScript and you get a white doc on screen. I’ve had no issues with JavaScript when switching between Tiger & Leopard but have with AppleScript but I think this was down to the intel chip and my app version.

I think much as to do with what you want from your script in the first place its all the same DOM.

From the point of Photoshop then Action Manager code is quickest.

Mark67,

Thanks for the info!

CarbonQuark

Adobe makes no secret that the underlying automation framework in the CS Suite is JavaScript (just look at their reference guides), not AppleScript. In fact, they give the impression that AppleScript is just half-arsed bolted on top of JavaScript.

For CS2 for example, I had to buy their JavaScript guides in order to back-figure their AppleScript”they didn’t have an AppleScript guide at that caliber and their AppleScript libraries are a joke. Seriously, despite having ScriptDebugger, I find it easier to look-up what I need to do in the JavaScript guide to get some idea what they call something or how they do something, then look it up in the AS library and try to figure it out.

I found when automating Photoshop it is often better/faster to use their “watcher” plugin (ScriptingListener.plugin) to get the appropriate JavaScript code and execute that with “Do Script” within AppleScript. My script Clorox File Repair uses three watcher-written scripts (tweaked a little by hand) to do the Photoshop work”doing it directly via AppleScript was tedious and too slow.

Just to add to kevin’s Info. Adobe offers the same DOM to AppleScript, ExtendScript (JavaScript based) & Visual Basic for apps PhotoShop, Illustrator & InDesign. Bridge’s DOM is available to ExtendScript only so if you want to integrate this in your work flow you need to use ExtendScript in ESTK. Acrobat uses JavaScript (proper) and you can do a lot more in this app by using this. Only Photoshop has the scriptlistener plug-in and this is what kicks out action descriptor code. Like Actions this has NO logic so you still need to check for conditions using DOM commands in what ever language you want to use before playing out. You can at least double maybe triple what you can do in this app by using this as it has recorded access to tones of things that are just NOT available to the DOM. Inter-application communication in ExtendScript is done thru bridgetalk and it’s bloody hard work and AppleScript comes into it’s own here as its above these apps.

That said it looks like another option may be on the way in when CS5 comes about. There has been some discussion on Action Script although Adobe employee’s are keeping tight lipped about this. ExtendScript could be the one that goes to wayside although this won’t be any time soon and AppleScript out living it.

Look for an InDesign PDF JavaScript Ref for CS3 or CS4 and you won’t find one but there is an AppleScript one.
(InDesign’s documentation is in the ESTK help files) Not very good.

Actually, there is an Acrobat 7.0 (CS3) JavaScript reference guide, right here on my desk. I tried looking for AppleScript guides at the time, never found any (not printed anyway). It is surprising how much the JavaScript guides (“Official JavaScript Reference” in Adobe-speak) help with AppleScript. Expensive books, but worth it, and generally still apply to CS4.

Yeah, ScriptListener only exists for Photoshop, but what a handy tool! And the JavaScript has no logic, but then again neither do Photoshop Actions (via the Actions panel) within Photoshop. As you say, AppleScript comes in here because you can use the JavaScripts and “do script” with AppleScript used for branching/decisions. It feels a little clunky, but it’s effective. And in my experience faster for large batch operations than doing it strictly in AppleScript.

(Which probably sounds funny coming from me because I usually do everything in AppleScript and cringe when I have to resort to the command-line.LOL.)