Live data from Hacker News

JavaScript as an alternative to AppleScript on OS X Yosemite

developer.apple.com

121–126 of 126 posts

Re: JavaScript as an alternative to AppleScript on OS X Yosemite

#121
post #57

Earlier quoted context omitted.

HyperTalk was surprisingly ok, though.

HyperTalk was brilliant because everything seemed to just naturally work. The grammar and object model were both highly intuitive – you really could just guess the right syntax. AppleScript and HyperTalk are aesthetically very similar but every time I have to write something in AppleScript I get oddball parse errors that I can never decipher and I need to randomly try things until an approach succeeds (for reasons I…

I loved HyperTalk, but my experience with it was that:

A. Almost any English sentence was grammatically valid.

B. Almost none of those sentences did what you expected.

I find AppleScript a more regular language overall. I think the biggest difference is that HyperTalk was built in to the HyperCard environment, and therefore most of the “language” was in fact just HyperCard-supplied functionality, whereas AppleScript has very little built-in functionality, and sometimes this surprises people when they discover that it’s up to some other application to decide what the behavior of the script is.

Re: JavaScript as an alternative to AppleScript on OS X Yosemite

#122

I'm going to miss AppleScript - in both obvious senses of the word. It was a language I used to swear by, and at. I spent hours getting scripts to work, so I've became used to the language's infelicities, but was always frustrated by the lack of tools. Here, for example, is how I gather you're supposed to change the case of a string: on change_case(this_text, this_case) if this_case is 0 then set the comparison_strin…

There has been no statement that AppleScript is going away or being replaced by JavaScript for Automation. This is simply a case of offering users more choices.

AppleScript’s primary target audience is first-time and casual programmers. (Of course, there are professional programmers writing applications and utilities in AppleScript, too.)

Re: JavaScript as an alternative to AppleScript on OS X Yosemite

#123
post #5

AppleScript contains some amazingly powerful APIs, but is nearly impossible to write. Having a Javascript (successor?) implementation is going to unleash its full potential. I could see it becoming much more widely used and supported by third party apps. This is wonderful. In the same cycle that they release a brand new language, they begin the deprecation process for their (only?) other proprietary programming langu…

Others have touched on this farther down, but this always sets me off: AppleScript is not confusing because of its native syntax. It's confusing because of the inconsistent, often contradictory, incomplete, and sometimes just insane dictionaries provided by the various apps you access with AppleScript.

Switching to JavaScript will do exactly zero to fix that. However, there appears to be new functionality inherent in the implementation, including better integration of native code (oddly, the examples are in ObjC instead of Swift), and I assume this will be faster than AppleScript. If this increases the popularity of writing scripts, then perhaps app-writers will improve their dictionaries.

Re: JavaScript as an alternative to AppleScript on OS X Yosemite

#124
post #113

The thing i'm not totally sold on is that for arg-free alloc/inits, you can forego 'calling' those methods at all so you get code like `task = $.NSTask.alloc.init;` but sometimes you have code like `ObjC.super(this).init;`. So although you're actually initializing a new object, casually glancing through the code makes it seem that you're actually just accessing a property on NSClassName. Jstalk/cocoascript i think ge…

> why not use objs for named args? Because then there is no way of conveying the order of the parameters. In this case, it's ambiguous whether the method we are calling is colorWithRedGreenBlueAlpha, colorWithGreenBlueRedAlpha, etc.

Order doesn't matter in the above example. In the method body you'd reference arguments[0].green when you wanted green.

Re: JavaScript as an alternative to AppleScript on OS X Yosemite

#125
post #43

Earlier quoted context omitted.

> I love AppleScript because whenever somebody asks, "Why don't they make programming languages more like English?" all you need to do is show them AppleScript. Yup :-) AppleScript has an interesting history, it used to support multiple "natural languages" (such as French, ...) in addition to English: http://www.cs.utexas.edu/~wcook/Drafts/2006/ashopl.pdf (This is probably why many AppleScript Guides still say "Engli…

For the record, AppleScript is not “natural language programming”; it is merely more similar to English than most programming languages. As with most mainstream programming languages, human terms (usually English) are used for keywords like “if”, “then”, “else”, “while”. It still has a very limited and structured grammar, like most programming languages. In deference to the expressive flexibility demanded by humans,…

Using words instead of punctuation isn't so bad --- I would be willing to learn a creole pidgin in exchange for being able to program without punctuation characters and using Voice Recognition. But three-word keywords like "is equal to" just make it impossible to intuit the AST from the language, and intuiting the AST is ultimately what makes a programmer feel comfortable with the languages. In this regard, AppleScript was like SQL but worse.

Python, OTOH, strikes a decent balance (assuming de-punctuating is your goal), avoiding punctuation by using keywords for 'and' and 'or' and 'not' , without making the grammar incomprehensible.

Re: JavaScript as an alternative to AppleScript on OS X Yosemite

#126

Oh Javascript. This has been said so many times before, but why, oh why, has the world converged on this particular language? Why aren't there saner alternatives to Javascript in browsers? We have so many languages at our disposal, why choose Javascript? Why don't people realize that web programming is not great because of Javascript but despite Javascript? We are bound to Javascript on the web because browsers, for…

Why don't people like you recognize the greatness of JavaScript? Which language would be preferable? Perhaps Lua? Not much else with comparable simplicity comes to mind.

good thing these other nicer languages compiles to javascript: typescript, kotlin, clojurescript
Post reply on HN