What's the score with jxa

I’m not a very big scripter but have most of my workflows hacked together using Applescript (I’m a photographer). One thing that really bugs me though is that my photoshop scrips will only run on CS3 (they broke on my upgrade to CS5) and all Adobe say is that I should now be doing it in Javascript! Having just heard about jxa is it time to start learning this and porting things over? More specifically, will jxa do everything applescript can do in terms of controlling the finder (I only really use applescript to manage the Finder and Photoshop). Buy the way, I have looked for this information both on this site and the web in general but there seems to be very little information on it - which is worrying in itself.

What Adobe meant was using their JavaScript core engine en write strictly Adobe script being imprisoned to the Adobe environment. JXA makes still use of OSA and the resulting script is the same as AppleScript (whose code is also being compiled to OSA scripts).

The two things don’t necessarily follow. Can you tell us what broke about them?

OK, the scripts that worked while I was running them on CS3 stopped working when I upgraded to CS5. I can’t off the top of my head remember what part of the script didn’t work. Out of interest I spent a lot of time playing email tennis with someone from Adobe that seemed very nice and seemed like he wanted to help me but also seemed deaf to me asking him if he could provide (or would be able to provide in the future) a fix to the applescript. All he kept coming back to me with was with javascript solutions. This was not very useful because I did not have the time to re-write all my scripts in a new language just because of this. I have to be very careful how much time I spend learning about scripting as my business is photography so it was easier to just keep on using CS3 for workflow side of my business.

My question was though ‘What’s the score with jxs’. My thinking being that if I can now script the finder in Javascript without any problems (bugs etc) it might be worth me investing my time learning javascript and slowly re-writtign my work flow scripts with this.

Wonderful answer!

“all Adobe say is that I should now be doing it in Javascript”

Do you have a source for this? Was this official advice from Adobe? I’m aware they’re not huge fans of AppleScript/Apple events (it’s complicated and difficult and expensive, and damn near impossible to find programmers who know how), but if they’re now telling AS users to switch to Adobe’s own embedded JavaScript support then that’s a big deal. I’m trying to persuade Sal Soghoian to pull his head out the sand and realize that Mac Automation is going into the weeds, so if you can provide me with URL/email/other evidence that even Adobe’s telling users to avoid AppleScript then that would be incredibly useful. (You can post it here, or message me directly if you prefer.)

Otherwise, to affirm what Shane et al have basically said: JSX (Adobe’s built-in JS) and JXA (Apple’s JS OSA component) are completely unrelated. JSX has access to all the same Adobe app features as AS, and has the benefit of being cross-platform (very handy if you’re in a mixed Win/Mac shop), but it runs inside of an Adobe app and doesn’t really do inter-process stuff (IIRC, it has a basic runAppleScript command, but that’s all).

JXA was supposed to be a more appealing alternative to AppleScript (JS is also pretty crappy as a language, but it’s a million times more widespread and popular), but the Mac Automation team screwed up JXA’s design and implementation. They’re done nothing to fix it since, nor do they provide any user support or education, so it’s pretty safe to say JXA was Dead On Arrival and not worth wasting your time on.

Stick to AS or JSX - they’re the only options that (usually) work right, and fingers crossed Apple/Adobe don’t get an itch to pull the rug from those too.

/delurk