Live data from Hacker News

JavaScript as an alternative to AppleScript on OS X Yosemite

developer.apple.com

51–60 of 126 posts

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

#51
post #44

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: L…

What video?

http://devstreaming.apple.com/videos/wwdc/2014/306xxjtg7uz13...

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

#53

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 doub…

After a quick search I couldn't (readily) find any links about writing Mac apps in Javascript. The Strongloop seems to be for iOS7 only. Where would I find out more about this?

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

#54

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 doub…

Yeah, I suspect I was a bit unclear there!

I'm pretty familiar with ObjC-Javascript integration and have been working with it for a while. This change offers a nice direct system interface for automation, and one that has access to all of Cocoa.

I also didn't intend to put Javascript down at all - its more that the more complex part of building a MacOS app is working with Cocoa, and Javascript will make that more complex, rather than simpler, just because of the impedance mismatch.

I'm not sure there's a compelling use case for building such apps, but it's still pretty cool!

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

#55

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 doub…

[deleted]

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

#56
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.

You're not actually supposed to have doExactlyOneSpecificThing methods in AppleScript. Instead, you are supposed to have a small number of verbs that can operate on a large number of objects and their properties. It was REST before there was REST. Unfortunately, this design principle was often misunderstood by those writing scripting interfaces for applications.

It also didn't help that Apple provided very little support for implementing the language's rich query model, which led to many applications only implementing one or two ways to access objects, often with bugs. That was the source of most of the annoyances with AppleScript.

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

#57

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…

HyperTalk was surprisingly ok, though.

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

#58

Earlier quoted context omitted.

(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 doub…

Yeah, I suspect I was a bit unclear there! I'm pretty familiar with ObjC-Javascript integration and have been working with it for a while. This change offers a nice direct system interface for automation, and one that has access to all of Cocoa. I also didn't intend to put Javascript down at all - its more that the more complex part of building a MacOS app is working with Cocoa, and Javascript will make that more com…

I think you were being downvoted because some people (myself included) roll their eyes when they hear about Javascript yet again. It goes double when there is a good language already out there (I accept Objective C with its warts. Swift actually has me excited to make something).

It actually kind of cool. And the Temperature Converter example showed a lot of the dynamic nature of the objective C runtime. This one presentation actually piqued my interest in looking at os x scripting.

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

#59
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.

I never understood the cutesy naming schemes. What's wrong with .filter or .where.
Post reply on HN