3 ms·
Next year I will have been programming for half a century; in this time I've used a few dozen languages (counting things like awk, m4, and SQL in addition to or
by todd8 10y ago
Next year I will have been programming for half a century; in this time I've used a few dozen languages (counting things like awk, m4, and SQL in addition to ordinary programming languages). AppleScript has to be near my least favorite language. It's so called natural language syntax is verbose, unintuitive, and ambiguous to me. Almost any real programming language would be better: bash, python, Lua, JavaScript, tcl, ruby, whatever.
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/EWD667.html https://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/E...
- tedmiston 10y agoYou're also not the audience that AppleScript's natural language programming was designed for (similar with Automator). Don't get me wrong, I feel the same pain points, but AppleScript never was a programming language for developers.
- todd8 10y agoYes you're right. Perhaps something like Automator or even Scratch might work for non-programmers instead of AppleScript. I find both of those quite intuitive (although slower to code in for a trained programmer).
- seanp2k2 10y agoIMO just use Lua as it's easy to embed and well-suited for the task of ad-hoc scripting. There's also a large community and plenty of library support to help get weird interactions working.
- CountSessine 10y agoI think its a lot worse than this though; it isn't realistically a language for anyone. 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.
- __jal 10y agoThis. 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.
- function_seven 10y ago> Applescript should be used as the definition of a write-only language. 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”.
- mwfunk 10y agoI agree 100%. Various attempts have been made to design "human readable" programming languages, where someone who wasn't familiar with the syntax (or with programming in general) might be able to read some code and get a sense of what it was doing. 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.
- josho 10y ago> AppleScript never was a programming language for developers 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.
- tedmiston 10y agoGiven that it was introduced 20 years ago on System 7 and has survived through Mac OS 8/9/X, it's kind of hard to address the audience question over that timespan. But I think it was always intended to be accessible to end users. 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.
- supernintendo 10y agoAppleScript was originally intended as a way for non-programmers to develop applications, hence the "natural language" syntax. You could think of it as the spiritual successor to HyperTalk / HyperCard. Aside from that, the language served an important purpose in classic Mac OS which lacked preemptive multitasking and thus true IPC. AppleScript was used to allow multiple applications to communicate with one another using a pub-sub model.
- cooper12 10y ago> The main problem is that AppleScript only appears to be a natural language. In fact [it] is an artificial language, like any other programming language. [E]ven small changes to the script may introduce subtle syntactic errors which baffle users. It is easy to read AppleScript, but quite hard to write it." - AppleScript by William R. Cook (http://www.cs.utexas.edu/~wcook/Drafts/2006/ashopl.pdf 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)
- scarface74 10y agoAppleScript is just an implementation detail. The power of scripting with MacOS has always been the underlying Apple Events. There have always been a number of languages that work on top of Apple Events to allow scripting.
- jbpetersen 10y agoI think Dijkstra's gonna get some comeuppance on this one when it comes to audible computing. What are spoken commands if not NLP one liners in a REPL?
- maxxxxx 10y agoThey did this at the same time when Microsoft was localizing VBA. I still remember writing German VBA code which was horrible ("Wenn... Dann"). I think it was a good try but turned out to be not so great.