Live data from Hacker News

JavaScript as an alternative to AppleScript on OS X Yosemite

developer.apple.com

31–40 of 126 posts

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

#31

You know what's pretty cool? This potentially allows native MacOS applications to be written in JavaScript... Not that I can see any reason to do that.

(Downvoters of parent, please stop, it's a perfectly reasonable comment.)

While you're correct that JS can now be used to write Mac applications without an Obj-C wrapper, that's not really the point of this.

Anyway, you can already write Mac applications in JavaScript. And iOS applications! This has been true since iOS 7 and Mavericks. http://strongloop.com/strongblog/apples-ios7-native-javascri...

You can build double-clickable "applets" in AppleScript and JavaScript, but the OSA interface isn't really made for app development, just automation.

However, they do expose all Cocoa and Obj-C APIs to JavaScript, so anything is possible! They even do a demo of a standalone temperature converter at the end of the WWDC session.

https://developer.apple.com/videos/wwdc/2014/#306

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

#32

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. The functionality exposed by OSX apps via AppleScript is often incredible, but the language itself is annoying. The question is whether or not applications will support it. With the emphasis shifting away from OSX desktop applications to cross-platform and clou…

You show them AppleScript and SQL and they say "Wow, what was I thinking, english is a terrible basis for a programming language."

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

#33

"Because JavaScript is the language of the web browser, and because the web browser has become the dominant application delivery system, and because JavaScript isn't too bad, JavaScript has become the World's Most Popular Programming Language. Its popularity is growing. It is now being embedded in other applications and contexts. JavaScript has become important. It is better to be lucky than smart." - Douglas Crockfo…

Could not have happened to a better language! It's about time Javascript finally has its chance to shine.

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

#34

> Scripting additions (plugins for scripts) can be used to enhance the functionality of applications. The OS has a set of standard scripting additions available. These offer things like speaking text and user interaction dialogs. app.say('This is exciting')

Scripting additions have always existed...

I used work for a living in AppleScript nearly 20 years ago. Heavy drinking helps block out the memories.

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

#35
A lot of people in this thread have misconceptions about what AppleScript is and what it means for JavaScript to be an alternative. I recommend watching the WWDC session [1] if you can, and skip to 16 minutes in (through minute 20) for a quick explanation of what this actually is.

TL;DR shell scripting for the GUI, not a way to build Mac applications (which you can already do with JS).

Edit: video link

Double edit: Looks like I'm slightly wrong about using JS to build apps this way. You can bundle scripts as applications, and OSA can create windows and controls, so you could hypothetically build whole apps this way. But I'm not sure I would want to.

[1]: https://developer.apple.com/videos/wwdc/2014/#306

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

#36
post #14
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…

As braindead as the language was, the real problem with AppleScript was the bizarre object model, so the Object help doc was full of nonsense methods that did nothing useful. Finding the one method doExactlyOneSpecificThing that matched what you need was always a low-probability event. The opposite of the UNIX philosophy and modular design.

Yep. Script Debugger was almost a requirement for doing any serious AppleScript hackery. You can explore an open application's exposed objects and tell Script Debugger to paste the path to it into your current script. Way better than guessing when you need to `tell x` in order to expose its properties or whatever.

The most underrated thing to me that made it all worthwhile, though, was Remote Scripting. I think the full potential of it has yet to be realized, and hopefully JavaScript will allow some impressive future developments.

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

#37
post #14
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…

As braindead as the language was, the real problem with AppleScript was the bizarre object model, so the Object help doc was full of nonsense methods that did nothing useful. Finding the one method doExactlyOneSpecificThing that matched what you need was always a low-probability event. The opposite of the UNIX philosophy and modular design.

is this going to be solved by writing it in javascript though?

Looking at the sample code in this page:

   Mail.outgoingMessages.whose({subject:'JavaScript'})
is doesn't look much better.

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

#38

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. The functionality exposed by OSX apps via AppleScript is often incredible, but the language itself is annoying. The question is whether or not applications will support it. With the emphasis shifting away from OSX desktop applications to cross-platform and clou…

You show them AppleScript and SQL and they say "Wow, what was I thinking, english is a terrible basis for a programming language."

SQL makes sense, but at its core, it's a query language, not a programming language. You can do lots of arbitrary computation with it if you want and use it for things it's not good at, but for its intended purpose, it works pretty well.

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

#39
post #33

"Because JavaScript is the language of the web browser, and because the web browser has become the dominant application delivery system, and because JavaScript isn't too bad, JavaScript has become the World's Most Popular Programming Language. Its popularity is growing. It is now being embedded in other applications and contexts. JavaScript has become important. It is better to be lucky than smart." - Douglas Crockfo…

Could not have happened to a better language! It's about time Javascript finally has its chance to shine.

That's the whole point, it could've happened to a much better language.

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

#40
post #14

Earlier quoted context omitted.

As braindead as the language was, the real problem with AppleScript was the bizarre object model, so the Object help doc was full of nonsense methods that did nothing useful. Finding the one method doExactlyOneSpecificThing that matched what you need was always a low-probability event. The opposite of the UNIX philosophy and modular design.

is this going to be solved by writing it in javascript though? Looking at the sample code in this page: Mail.outgoingMessages.whose({subject:'JavaScript'}) is doesn't look much better.

Looks pretty straightforward to me. Do you know what the equivalent AppleScript is?

Edit: found a stack overflow question/answer [1]. It's doing a little additional work beyond searching for mails with a particular subject, but even just the searching functionality is much larger and more convoluted that the single line of js you referenced.

[1]http://stackoverflow.com/q/8156120

Post reply on HN