Original Edition 2020-09-16 18:50 GMT-5
(This is a wiki article, and I will update as new information becomes available.)
Let me start by saying that this can be a very emotional, hot topic for some people.
So I want to make it clear that everything I'm posting here is IMO (in my opinion), but based on the actual facts as best I know them.
Having said that, in theory, according to Apple, we should be able to address Mac automation objects/apps equally in both AppleScript and JXA. So the decision should come down to which language do you like best? Which syntax do you like best?
But that's just theory. In practice, there seem to be a few, and I think very few, automation areas where JXA doesn't seem to work correctly. IMO, these are edge cases, that most of us are unlikely to run into. In fact, I can't even name the areas.
For me, this is NBD (No Bid Deal), because if I happen run across one of these JXA problem areas, I'll just code that function using AppleScript, and then call it from JXA, using an AppleScript Library. It is interesting, and notable, that you can use an AppleScript Script Library from JXA, but not vice-versa.
One could probably draw up a list of pros/cons, but I'll just list the big advantages of each language:
Easier to Get Help
- By comparison with JXA, there is a huge amount of scripts, script libraries, example scripts, and people knowledgeable about AppleScript.
- So that means getting help is usually much easier with Mac automation
Developing and Debugging with Script Debugger 7+
- The best available development tool for either AppleScript or JXA, but it only supports AppleScript
- Provides a complete IDE, with excellent debugging, scripting dictionary support, and exploring of app object models
- AFAIK, there is really nothing equivalent to it for JXA -- the Safari Debugger is the best JXA tool available today
Better programming language for programmers (again, IMO).
- The "English-like" language of AppleScript just gets in the way for some (a lot?) of programmers
Extensive Native and Third Party Libraries
- But not much help for JXA, for Mac automation
Support for Each Language
As I read back over what I just wrote, I realize that it might confusing concerning the support available for each language. The main issue here is with support for Mac automation.
- AppleScript has the best support for Mac automation
My Personal Experience and Views
It is hard to tell what Apple is going to do. But I see JXA as being the future of Mac automation. Except for Script Libraries (which are used by both AppleScript and JXA), it seems that Apple is not putting much effort into improving AppleScript: maintaining, fixing bugs, improving documentation, or extending AppleScript.
I know that JXA is a disappointment to a few of the long-time AppleScript developers. It is hard to pin down how much of this is "sour grapes" vs real issues. I'm sure JXA could have been better -- almost anything can be improved -- but it seems good enough to me. As I said above, if I run into something I can't code in JXA, then I'll revert to AppleScript, and call it from JXA.
Both are good tools. Pick the one that works best for you.
The great thing is that KM gives you easy access to run both AppleScript and JXA scripts (and other script languages). So, you can choose either, or both, whatever works best for you. And as of KM 8.0.3+, we have access to the KM Editor scripting model, which is available to both AppleScript and JXA.