Hacker News new | ask | show | jobs
by tambourine_man 2945 days ago
Yeah, that was my problem with AppleScript. It’s a read-only language to me. It took me years to try other languages and discover I could actually write code.
2 comments

"The experiment in designing a language that resembled natural languages (English and Japanese) was not successful." -- William Cook

Any programming language that tries to do "natural language" should at least reference the AppleScript HOPL Paper[1] and say how they are doing things differently to address the (now) obvious problems.

(Oh, and there is a LOT of good stuff in the paper, definitely worth a read).

[1] http://www.cs.utexas.edu/~wcook/Drafts/2006/ashopl.pdf

I think all experiments of languages that resembled natural languages will never work until one will try to ascend to a more high-level paradigm.

Actuals programming language are based on a "forklift paradigm" : you describe the path of a forklift in a virtual warehouse where data's are in some places and your forklift move them from places to places. So a natural language isn't design to express this kind of semantic.

In PPIG ( Psychology of Programming Interest Group ) 2006 was published a very interesting paper where is studied the metaphors which was shared by the core java library authors, the mental model said in another way. It reaveals very interesting facts : Programmers tend to think the world in term of Belief-Intention agents. Agent are members of a society who trade and own datas and are subject to legal constraints. A method calls is a speech act. The execution is mentalized as a journey in a a spatial world. Etc. There's a lot of metaphors like that, and it reveals tracks to conceive a more high level language.

So there's a lot of work in this field (Behavior-Tree based language, time dimension include inside the semantics, etc.).

Note that it is also possible to express non ambiguigous semantics in natural language : Attempto Controlled English is an exemple [2].

Here an toy example of what you could do with this language :

"MyWebPage is a webpage. MyWebPage contains a textfield which a logical name is-named NameTextField. His label is "Name". MyWebPage contains a button which a logical name is-named SubmitButton. His label is "Submit". If User clicks on Submit and NameTextField is empty then NameTextField ' s css class becomes AlertEmptyInput. "

[1] http://www.ppig.org/sites/default/files/2006-PPIG-18th-black... [2] http://attempto.ifi.uzh.ch/site/

I tried to learn AppleScript at one point because it had to do some automation on a Mac. It is an exceedingly confusing language, because the syntax does not clearly reflect the underlying semantic and processing model. The English-like syntax just obscures what is actually going on. Yeah it is easy to read, and readability is important, but I think they forgot that code have to be written before it can be read.
Just to add another data point, I didn't find it so. I can code up applescript if I want to completely relying on dynamic documentation. In fact, what surprised me was the ease with which I could pick it up after nearly a decade of touching it. The vocabulary explorer is awesome for scripting applications .. if only applications would care about them. Script editor offers coding up using JavaScript as well as applescript, but I'd any day pick AS over JS for its purpose because mental model is clearly established.
The vocabulary explorer is indeed awesome and a great idea. Unfortunately not even Apple is very good at supporting them. And with Sal Soghoian's departure, automation at Apple will probably either change a lot or die.

My problem was the language syntax as a whole. But I'm particularly sensitive and picky on this issue. ObjC and Java's verbosity repel me so strongly I could never properly learn them, for instance, and so on.