• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful…)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Chris Page <email@hidden>
  • Date: Sun, 14 Dec 2008 06:01:46 -0800

On Dec 14, 2008, at 4:01 AM, Philip Aker wrote:

On 2008-12-14, at 02:51:38, Chris Page wrote:


• 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?).

Do you think this aspect could be made clearer with finer-grained syntax coloring?

As a matter of fact, I do. I've wanted that for years. But I think there's a lot more we could do than that.


In particular the separation of variables and subroutines.

Well, I was thinking the biggest win would be distinguishing command and parameter names.


But more to your point, there is no difference between a variable and a subroutine name in AppleScript. When you define a handler, it just defines a variable whose value is the handler, and you can set that variable to other values:

  on foo()
    "I am foo!"
  end

  foo
    --> «handler foo»

  set bar to foo
  bar()
    --> "I am foo!"

  set foo to 42
  foo
    --> 42
  foo()
    --> «script» doesn’t understand the foo message.

Which is not to say it's impossible, but it does mean AppleScript would have to figure out the current value of the variable to see if it's a handler while decompiling the script. It also means that it wouldn't necessarily be correct at every point within the program.

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"

Well:

mv *.txt 'Text Files'

:-) but I do know what you mean.

Okay, but please forgive me for using this to illustrate a point: This is exactly my other point about clarity versus saving on typing. Shell commands were designed to save on typing, because they're usually entered interactively by the user every time they wish to run a command. That mv shell command looks like gibberish unless you know your way around a Unix shell. And it can take some time to memorize “mv” and how “*” works, and the order of the arguments. But the AppleScript version is probably at least vaguely comprehensible to someone who's never seen AppleScript before in their life. In fact, it's practically exactly how you'd explain in English what the shell command does.


Thanks for the comments. I'm kinda surprised that your remarks are mostly at the "high" level.


Well, at the low level all languages are identical. ;-) What sort of things were you expecting me to address?

--
Chris Page

 The other, other AppleScript Chris

_______________________________________________
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
  • Follow-Ups:
    • Re: What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful…)
      • From: Philip Aker <email@hidden>
    • Re: What's so great about AppleScript, anyway?
      • From: Doug McNutt <email@hidden>
References: 
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: has <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Chris Page <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Philip Aker <email@hidden>)
 >What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful…) (From: Chris Page <email@hidden>)
 >Re: What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful…) (From: Philip Aker <email@hidden>)

  • Prev by Date: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Next by Date: Re: AppleScript's Threadedness…
  • Previous by thread: Re: What's so great about AppleScript, anyway? (was Re: Tell Blocks Considered Harmful…)
  • Next by thread: Re: What's so great about AppleScript, anyway?
  • Index(es):
    • Date
    • Thread