I’ve noticed a number of very serious complaints about JXA in the Stackoverflow.com forum, suggesting that it is very flawed.
I’d be very interested in hearing from any of you that have significant experience in using, or trying to us, JXA. Are you seeing the type of issues described below?
Here’s an example from Stackoverflow:
Like Leopard’s Scripting Bridge before it, JXA intentionally breaks all sorts of stuff that works perfectly in AppleScript. Here is the translation of your original AppleScript command to JXA syntax:
//tell application "System Events" to name of items in folder "/usr" Application('System Events').folders.byName('/usr').items.name()
The AS version works perfectly, but the JXA equivalent just throws a completely meaningless Error -1700: Can’t convert types.
JXA does seem to work if you write diskItems instead of items:
Application('System Events').folders.byName('/usr').diskItems.name() // --> ["bin", "lib", "libexec", "local", "sbin", "share", "standalone", "X11", "X11R6"]
which suggests JXA indulges in much the same internal “cleverness” that causes SB to break on so many apps. (Note that I found numerous such design defects in earlier testing, but gave up reporting them once it was clear the AS devs only cared about imposing their own personal ideology and prejudices on everyone else, crippled capabilities and broken compatibility be damned.)
And so it goes. (e.g. Try testing JXA’s support for range, filter, relative, and insertion reference forms; it’s particularly rotten.)