AppleScript, the perfect adjunct to iTunes: An open letter to Apple CEO Tim Cook
macworld.com
macworld.com
AppleScript seems to be a valiant effort to design a language for non-programmers, but the English like syntax just adds complexity to writing even simple programs.
See Dijkstra's take on "natural language" programming[1].
[1] https://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/E...
Anyone working on almost any task in Applescript is going to be frustrated. In particular, just the ambiguities in the language for doing simple queries on containers makes writing even simple scripts needlessly painful.
I can't remember what it was like before I learned a programming language. I do vividly recall my fights with compilers, however, and imagining trying to guess what Applescript wants in a particular context without reasonable notions of what was going on under the hood, and I would have become a plumber instead.
Applescript is horrid. Seriously, every time I try to write something in it, it devolves into Googling for whatever weird, stilted 'natural language' variant is needed in a given context in the best case. The worst case is me wracking my brain for odd ways to write subordinate clauses that might make it happier.
Applescript should be used as the definition of a write-only language. People like to bag on Perl, but even if you hate everything about Perl, it is still a vastly more human language than Applescript.
It’s the opposite. Applescript is a read-only language. Very difficult to write, but easy to read code that’s already done. Whereas Perl is easy(?) to write, difficult to read. So it’s a “write-only language”.
I've heard that COBOL was designed with this goal in mind- make the syntax a little more verbose and English-like, and in theory nontechnical business people could understand what it was doing. AppleScript took this concept and ran with it.
The problem is that while this might (or might not) enhance readability, it definitely hurts writability. You end up with a verbose language with lots of extraneous and ambiguous syntax that isn't really well-defined. I've found AppleScript to be much more confusing than other languages, and if I wasn't a developer I would expect that to be 10x worse.
I have met a few people who said they got started with programming by playing with AppleScript, but I can't escape the feeling that they got into programming despite AppleScript, not because of it.
Maybe they picked it up first because it's always been pitched as a language for non-programmers, but it just doesn't seem to scale beyond something good for copying and pasting tiny chunks of code to tell an app to do something that otherwise can't be automated. It's useful as a tool to create and send Apple Events (which is really all it is- a wrapper around Apple Events), but its usefulness speaks more to the occasional usefulness of Apple Events as a part of the OS, than AppleScript itself as a language.
But, who is it for then? For general users they still made it too difficult to discover how to do things. Perhaps, the failing was simply with the documentation and discovery of the language.
Regardless, it's clearly been an area underinvested for quite some time.
Personally, even as an experienced dev, I've found it hard to discover how to do things in AppleScript. The "natural" language can be surprisingly unintuitive sometimes, especially when it breaks down into a program that looks like half OOP / half NLP.
- AppleScript by William R. Cook (http://www.cs.utexas.edu/~wcook/Drafts/2006/ashopl.pdf)
My first programming language was Applescript and I have to say I agree. I'd spend most of my time coaxing the language of my code until the compiler could recognize its grammar. (Also, without an external application like UIElementInspector, just forget trying to figure out the incantations to properly manipulate windows and their buttons) The biggest strength of Applescript was the ability to pipe out to the shell for areas it sucked in. There are also a mountain of gotchas that newbies ha ve to watch out for: making sure the application has focus, escaping quotes properly, posix paths vs aliases, data types (text vs integer), and much more. I have to say the best parts of Applescript were the documentation (APIs exposed as "dictionaries" by each scriptable app), and being able to create "native" apps really easily as well as UIs/dialogs. (though with codesigning its utility to beginners is further reduced)
I think it was a good try but turned out to be not so great.
Yosemite added JavaScript for Automation (JXA)[1]. Very few people actually enjoy writing AppleScript, I think most see it as a noble but failed experiment in human-language syntax. Perhaps this is just a sign that Apple's removing AppleScript altogether in favour of JavaScript?
JavaScript is only useful with dozens of libraries imported, and they introduce their own quirky syntax (I'm looking at you, JQuery).
JavaScript can't "do shell script" (even PHP can do exec).
JavaScript can't read and write files.
JavaScript can't read the selection in one program, pull data from another program, and merge it in with something on the clipboard to piece together what you're actually wanting.
JavaScript can't handle unicode to my satisfaction. Even escaping strings is a pain. AppleScript's string manipulation is so clean. Regex that would be very complicated to put together without a trip to StackOverflow is translated into something super easy ("every word of last paragraph").
It's been a long time since I've ever done any AppleScript so I can't really compare, but it does seem like the JXA environment can do any of those things, since it has an Objective-C bridge[0].
[0] https://developer.apple.com/library/content/releasenotes/Int...
You can use JXA-handbook and its linked resources as a reference. But aside from that the only thing you'll find from Apple is the changelog [1] and the library in Script Editor (open it with shift+cmd+L).
[0] https://github.com/dtinth/JXA-Cookbook/wiki
[1] https://developer.apple.com/library/content/releasenotes/Int...
Or at least that was the case back in the 10.6 days. I wonder if those bindings are still being maintained.
AppleScript is beyond useful for just iTunes - back in the 10.4/10.5 days, I used to use AppleScript for some pretty interesting things, including modifying the 'Extras.rsrc' file to perform some interesting functions like colouring windows and changing font files that OS X simply didn't support at the time.
I also recall making an AppleScript that did some other OS/GUI-level modification, such as choosing to have my icons at the left side rather than the right on the desktop (coming from Windows this was rather annoying)...it's an incredibly powerful and useful tool when utilized correctly and I sincerely hope Apple keeps it around.
EDIT: Damn, I looked around to find that old 'Cloak' program but it looks like macthemes.net has been gone for a long time...makes sense since there's no real 'scene' for that anymore as it's all dynamically-generated now :/
There's choice in the market, you know? I'm pretty happy with my Nexus 6P, for instance.
Apple was never about freedom. Apple has always been about control. They take freedom and control away from consumers to deliver a "better experience" and charge a premium for it. If you don't align with Apple's vision, you are always SOL.
Their whole business model is built on a gamble that they know better then everyone else. no Floppy, iPhone, iPad, no headphone jack... (although the headphone jack is probably a bust)
And macos is based on an open source Kernel (darwin), and does a lot of open source stuff in general.
Their whole business model is about locking you in to their products. They are not the only ones who do this, of course.
But I also had to actually laugh out loud when I read the whole "it's about freedom" paragraph.
The Apple ecosystem is the wrong mothership if you care about these things.
I'd rather have a high quality thing with good defaults than a thousand different things to choose from. Ultimately the best would be a combination where you have high quality software with sane defaults that also allows a power user to make changes when necessary, but in practice it's hard to do both without tradeoffs that cause you to end up with neither.
This doesn't mean I don't like playing around with linux or that everything Apple does is high quality (looking at you Apple Music), but generally reducing choices a user is required to make is a good thing.
You're a one off edge case though. There is a line between flexibility and lack of control.
I'd consider the "quality thing" as a baseline, or a starting point. From there, if something bothers me enough, I can look for an alternative that doesn't have that problem. If nothing bothers me that much, then I guess that the defaults were good for me.
Not so fast youngster. In my PR#6 days you could open the top and add cards to improve your machine. Changed after Woz was relegated by Jobs. Apples historical roots is in open hardware.
QED.
$596B in market capitalization says they had a point.
Does anyone know if it's possible to either build open-source clones of Applescript and Automator? I can see why Apple would be leery of supporting a team of people to support those, but maintaining and supporting the OSA seems to bring a broad set of benefits.
I guess I'm just pissed because Apple's stuff used to be so good, in so many ways. Heck, I was raised on OS9, and later OSX (both PPC and Intel): I couldn't stand Windows, and was an Apple fanatic for years, viewing even Linux is a worse alternative. I only fell into the Linux thing because I was building my own computer, and no way in hell was I installing Windows on it (Yes, really: And what a faithful decision it was).
And now... Jeez. What a mess. Seriously, Apple. Up your game.
Love my SE. Love my Mid 2014 MBP. Don't need a watch.
Speaking of which, have you seen CH's videos mocking this? They're quite funny, especially the one on the iPhone 7:
Apple: Johnny giveth, and Johnny taketh away.On the bright side, at least OSX has a single standard application automation system that still has decent support. For all the moaning about Apple closing up their platform, arguably OSX still has a far more capable and better supported application automation story than Linux. That's one advantage of a centrally planned platform that has actually delivered benefits to users.
Better supported, more consistant, yes. But more capable? I doubt it.
https://twitter.com/hhas01/status/793853777111646213
Message passing vs streams. Both powerful, valuable technologies, but optimized for different problem spaces IMO.
If there are any comparable programs for Linux, I really want to know. I don't trust Apple's direction, and AppleScript is a killer feature tying me to this platform for now.
It's interesting language, but it's not used widely, so when you have to use it, you need to remember syntax, etc, and that's much easier with good IDE. I doubt that I would be happier to use Python, because I used it once or twice in my life and I would google for every bit of language anyway.
I don't know why, exactly. Perhaps it was that HyperCard defined a domain. Applying the same primitives to every app could get clumsy.
A hand-waving example: making every useful procedure a function hanging off of a single Window object. Except for the two functions that are actually in the Application object...
(I don't have specific example at the moment but this sort of thing was discouraging for me.)
http://openradar.appspot.com/29329704 http://openradar.appspot.com/29363517
More duplicate requests = more likely to get Apple's attention.
See also:
http://lists.apple.com/archives/applescript-users/2016/Nov/m...
It's not? It's pretty clear to me…
Unfortunately the effectiveness of this argument is lost in the times. The author gets really caught up in metadata, bur we're in a year where Apple just wants you to subscribe to Apple Music and stop managing music files manually. To be clear, I'm not disagreeing with the author, just echoing why I think the argument wasn't effective.
At least this should free them to focus on their real revenue generators: dongles and "jet white" phones.