In HyperTalk you could write something like put 4 + 4, get it; or set fred to 4 + 4; or put 4 + 4 into fred. You could leave quotes off a string, or put quotes on a number, and it would usually "just work". This made HyperTalk easy for non-programmers to write, yet still easy for programmers to write well (and debug). AppleScript allows even more syntactic constructs than HyperTalk, but they all turn out to be semantically different in incompatible ways. (It's very much like they map directly onto C++'s . -> * and & directly.) So if you can set fred to 4 + 4, you probably can't put 4 + 4 into fred. (I'm pulling these examples out of my ass without looking up actual syntax because I can't be bothered.)
I went from being a competent HyperTalk programmer to "godlike" thanks to a book by Danny Goodman (The HyperTalk Bible, I think). When AppleScript came out, Apple commissioned Goodman to write the definitive book on AppleScript -- I read it and still couldn't get anywhere. AppleScript is kind of like Blender. I can eventually figure out how to do anything, but knowledge of how I did it evaporates almost instantly. It's perhaps the worst programming language I have ever actually tried to master.
Danny Goodman later wrote books on JavaScript and DHTML which, for their time, were just as great as his HyperTalk stuff, but no-one has ever been able to make AppleScript not suck (for me, anyway).
I'm still surprised no one's made a small open-source HyperTalk clone. A compile-to-JS-and-run-in-the-browser version would be pretty cool.
An open source HyperTalk (modernized and improved in many ways) https://github.com/kreativekorp/openxion
I've used OpenXION for shell scripting once or twice, on a lark, and it was a pleasant blast from the past.
app('Mail').outgoingMessages[its.subject=='JavaScript']
Appscript also had bindings for Ruby and ObjC.Unfortunately, Apple deprecated the underlying API in 10.6 that made appscript possible and never provided a suitable replacement[1].
As always though, the problem wasn't Applescript, but rather limited support for Apple Events by applications. Unless that problem is fixed, adding Javascript support to the OSA isn't going to help much.
[0] http://appscript.sourceforge.net/index.html
[1] http://appscript.sourceforge.net/status.html
Edited to add: I see the author of appscript has additional criticism linked to elsewhere from this thread - https://news.ycombinator.com/item?id=8329408
As Larry Wall said: "The potential for greater good goes right along with the potential for greater evil."[1]
[1]: http://www.wall.org/~larry/pm.html
PS. I always wanted to quote this :-)
The main thing I'm curious about is the quality of the bridge with the native APIs. AppleScript had so many never-fixed areas where bugs in the underlying implementation produced nonsensical error messages (e.g. `A scripting error has occurred: Can't make «class ppth» into a «class ppth»`) which required you to get out a debugger to figure out what was really going on. Be helpful to novices right up until you pushed them over a cliff…
1. Inherently imprecise.
2. Not true natural language processing, so it's not as forgiving of
syntax errors as you'd think - making it even more difficult
to try to say what you want to say.Unless you had a parser that could truly read it like english.
ObjC.import('Cocoa')
And then you get stuff like
task = $.NSTask.alloc.init task.running == task.isRunning
The AppleScript version
if application "iTunes" is running then --- Do stuff... end if
It may just be me, but in some cases the AppleScript version is easier and better.
Mail = Application('Mail')
if (Mail.isRunning) { ... }English (more specifically, JavaScript) is the Lingua Franca for the majority of programming, and we've all come to accept that, for better or worse, in good times and in bad, in sickness and in health.
Here is some of the new JavaScript syntax:
Here is what it looks like in AppleScript While the AppleScript sounds logical, the JavaScript syntax just feels so comfortable and familiar (obviously).