AppleScript and Natural Languages

Never been a Mac fanatic myself, I found the story of AppleScript to be an interesting look on the development of programming languages, especially for application scripting. A distinguishing feature of the original version of AppleScript was its support for dialects, including natural languages. For example, the following statements generated the same code:

  • the first character of every word whose style is bold (English)
  • { words | style == bold }.character[1] (professional dialect)

However, support for dialects has been dropped in later versions, and the author concludes that

The experiment in designing a language that resembled natural languages (English and Japanese) was not successful. It was assume that scripts should be presented in “natural language” so that average people could read and write them. This lead to the invention of multi-token keywords and the ability to disambiguate tokens without spaces for Japanese Kanji. In the end the syntactic variations and flexibility did more to confuse programmers than help them out. The main problem is that AppleScript only appears to be a natural language on the surface. In fact is an artificial language, like any other programming language. Recording is very successful, but even small changes to the script may introduce subtle syntactic errors which baffle users. It is very easy to read AppleScript, but quite hard to write it.

I believe this is one of the things “readable” languages like Python and Ruby got right: they (often) do resemble natural language sentences, but avoid greater efforts to work around the latent ambiguity of natural language. This makes them both easier to write and easier to maintain, without sacrificing readability – for programmers, that is.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: