Monday, November 22, 2021 [Tweets] [Favorites]

The Unexpected Return of JavaScript for Automation

Armin Briegel:

One reason python became so popular with MacAdmins, was that the pre-installed python on Mac OS X, also came with PyObjC, the Objective-C bridge for python.

[…]

I’ll be honest here and admit that working with JXA seems strange, inconsistent, and — in weird way — like a step backwards. Putting together a Command Line Tool written in Swift feels like a much more solid (for lack of a better word) way of solving a problem.

However, the Swift binary command line tool has one huge downside: you have to install the binary on the client before you can use it in scripts and your management system.

[…]

However, as flawed as it is, JXA can be a simple replacement for the classic python “one-liners” to get data out of a macOS system framework. Other interesting use cases are being discovered, such as JSON parsing.

Python is no longer the favored choice because “Monterey will now throw up dialogs warning the user.”

AppleScriptObjC is built-in, however.

Previously:

Update (2021-11-26): See also: Hacker News.

2 Comments

I am still livid that Apple is removing Python from macOS.

It's only the most popular programming *and* scripting language in the world, and is incredibly useful for app developers even when they're writing native apps. But who needs it!

I know it's not proper to rant, but really, the native scripting infrastructure on modern macOS is a sea of failing mediocrity. I mean, really — am I the only one who finds AppleScript, JXA and AppleEvents do my head in? That their ambiguities, inconsistencies, and frustrations would properly be regarded as broken in any other language? Sure, all for little languages. I love Tcl. But now that Apple have Swift there's no excuse not to modernise, provide proper underlying frameworks, and ease the process of inter-app communication with an included, bundled script language that isn't just a patchwork of prehistoric design failures meant mostly to overcome the limitations of classic macOS and to be "understandable" to the hoi polloi at a time when this was thought to be actually important (as opposed to, I dunno, giving people an actual education and opportunities to learn for themselves). Grrr, etc.

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment