Re: What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful )
Re: What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful )
- Subject: Re: What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful )
- From: "John C. Welch" <email@hidden>
- Date: Sun, 14 Dec 2008 18:38:02 -0500
- Thread-topic: What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful)
On 12/14/08 5:51 AM, "Chris Page" <email@hidden> wrote:
> • Very low barrier to entry. Useful scripts can be written with very
> little overhead. Despite its famous verbosity, there really isn't a
> lot of semantic overhead. You don't have to write a bunch of
> declarations before you write code. You don't even have to write a
> single function signature, because of the implicit “run” handler.
This was something that made my initial exposure to C et al frustrating.
"What do you mean I have to tell the complier about screen I/O? What, I have
to explain binary to it as well?"
If I kept in mind that C was never designed for much of what it's used for,
it made more sense, but just barely.
>
> • Supporting the previous item: The language has a certain minimum
> level of verbosity, forcing scripts to have a certain degree of
> readability.†
Another thing that is frustrating about other "real" languages, is the
amount of hay that a single misplaced character can create on compile. It
made sense that missing a semi-colon or <statement end char> would mess up
that statement. But it takes people a long time to learn that when you get
90248 compile errors, fix the FIRST ONE ONLY, and then recompile, because
depending on what it was, you may have all of them go away.
AppleScript is not *completely* innocent here, but it is better than most.
>
> • Despite its weaknesses (which I believe are addressable without
> radical alterations) the English-like syntax is quite clear from a
> typographical and human factors standpoint, and avoids the overuse of
> language-specific arcane punctuation. Its weakness is primarily one of
> ambiguity (is “path to desktop” one, two or three terms?).
It is also nice to know that transposing a single letter in a command, or
using the wrong case will not cause things to execute rather differently
than you expected. AppleScript is far kinder to the neophyte in the "less
likely to go off and do weird/dangerous stuff" sense.
>
> • AppleScript has syntax designed to directly express the Apple Event
> Object Model. Again, despite its weaknesses, I don't believe the
> possibly higher precision of other languages beats being able to write:
>
> tell application "Finder" to move (every file whose name ends with
> ".txt") to folder "Text Files"
I don't know about precision, but assuming you read english well enough, the
*clarity* of that statement beats shell by a mile.
> • It's a high-level language, which covers a lot. Garbage collection
> eliminates whole classes of errors and simplifies code. Does not
> expose raw memory pointers, eliminating whole classes of errors and
> simplifying code. Strong, dynamic typing eliminates whole classes of
> errors and simplifies code. High-level types like string, list,
> integer and real mean you don't have to worry about the byte-by-byte
> format of data, and eliminates whole classes of errors (like
> misinterpreting an unsigned integer as signed). These may not sound
> terribly exciting these days in contrast to, say, Python, but they're
> enormous wins compared to mid-level languages like Pascal, FORTRAN, C
> and C++, which were the most commonly used PC programming languages at
> the time AppleScript was invented.
I can live with a lot of the things AppleScript won't do, because of the
things it does for me, so I don't have to think about them. It's like one of
the scientists told me, (when I worked for a weather science company), after
asking her why she used FORTRAN instead of C. She said that while C was much
faster on execution time, FORTRAN was faster for writing code, because it
just handled a lot of details that C made her do manually. She appreciated
the fact that FORTRAN let her spend more time on the meat, and less time on
the prep. Also, as she put it, "I'm not watching it execute. That's
happening on the compute machines. If it takes 12 hours or 16, it really
doesn't matter to me, unless I shaved my deadlines too fine, and that's my
fault."
So the biggest advantage of the lower level language was a nonissue to her,
because she wasn't watching it execute. The greater ease of writing the
program, and having mundane details handled for her far outweighed execution
speed, because the coding and debugging was where she spent more of "her"
time.
Personally, I would be happy to see Automator gain capabilities even faster,
to the point where a lot of the basic language constructs were easier to
use, but that would require a major overhaul to Automator and the Automator
IDE, and I can't fully convince myself that it's worth it, much less anyone
else.
>
>
> † In contrast, languages with lots of syntactical abbreviations
> enable programmers to write abstruse code, whether they intend to make
> it difficult for others to read or not. Reducing the amount of typing
> is not a language design goal--it's a development tools goal. Making
> it easier to read and write correct code is a language (and library)
> design goal.
Yeah...at that point, I have to wonder, exactly when typing "move" instead
of "mv" because some form of torture. Yes, I understand that the resource
limitations at the dawn of Unix made such things necessary, however, other
platforms managed to avoid the...relentlessness...of small commands, even
with similar resource restrictions, so I question the necessity of never
opening things up a bit. (There's nothing that would prevent you from using
both "move" and "mv" other than the screaming of traditionalists.)
--
"She was not, herself, hugely in favor of motherhood in general.
Obviously it was necessary, but it wasn't exactly difficult.
Even cats managed it. But women acted as if they'd been given
a medal that entitled them to boss people around. It was as if, just
because they'd got the label that said 'mother', everyone else got
a tiny part of the label that said 'child'..."
Agnes Nitt's thought process in Terry Pratchett's Carpe Jugulum
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden