Down with Applescript, up with Javascript!

I've been fiddling with Applescript on and off for about a year, using it in various applications, and home automation tasks. However, I always feel like I'm bashing my head against it. It doesn't seem to always make sense, has an odd syntax, and the Dictionaries? Hah! Unreadable is a good, but incomplete, description.

Anyways, for other projects/work on Windows I've been implementing a Javascript interface to the application's functionality & dark, musty interiors. Javascript, once beginning to go the way of Java, Fortran, or Smalltalk (yes, they're out there, but does anyone learn these anymore?), it has been completely revitalized and now seems to be the cool, modern-way to do webapps/sites (Ajax, Widgets, GreaseMonkey, Firefox Extensions, and more).

Applescript has had a good run, yay. However, it seems antiquated to keep up a proprietary and somewhat odd OS Scripting language. Furthermore, it's not really a scripting language since it is compiled rather than intepreted.

SpiderMonkey is a Javascript-C engine that allows developers to provide an Javascript API to their applications similar to Applescript integration to Cocoa Apps.

Javascript is a pretty nice syntax. I really wonder how many non-programmers really feel more comfortable in the "English-like" syntax of Applescript. I, as a programmer, find it confusing at times. Though Script Editor is a very nice tool even though it apparently hasn't been updated in years.

Javascript enabling OS X apps would prevent widgets from having to do things like:


var obj = widget.system("/usr/bin/osascript -e 'tell application "iTunes"' -e 'name of current track' -e 'end tell'");

print(obj.outputString);

and requiring a widget access to the system to make a call to an app. A better solution may be:


var string = application.iTunes.getCurrentTrack();

or


var string = finder.geApplication("iTunes").getCurrentTrack();

Really, I'm missing decent scripting of apps and the OS in Windows, and Linux. Apple really shines in this respect. Windows has scripting via VBScript and JScript, but I'm looking for something a little less... proprietary and even more arcane.

About this article

written on
posted in TechnologyProgrammingApple Back to Top

About the Author

Andrew Turner is an advocate of open standards and open data. He is actively involved in many organizations developing and supporting open standards, including OpenStreetMap, Open Geospatial Consortium, Open Web Foundation, OSGeo, and the World Wide Web Consortium. He co-founded CrisisCommons, a community of volunteers that, in coordination with government agencies and disaster response groups, build technology tools to help people in need during and after a crisis such as an earthquake, tsunami, tornado, hurricane, flood, or wildfire.