Live data from Hacker News

JavaScript as an alternative to AppleScript on OS X Yosemite

developer.apple.com

101–110 of 126 posts

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

#101
post #90

Earlier quoted context omitted.

Genuine answer here. There's no need to apologize for not constantly immersing yourself in the workings of Apple platforms. :-) JavaScript is just another interface to Apple's "Open Scripting Architecture (OSA)." Previously, AppleScript was the only way to use it. The fact that they added another language indicates nothing about whether OSA will ever come to iOS. My guess is it won't; the new extensions APIs will lik…

There are other language interfaces to OSA. Frontier's UserTalk was an early implementation (and much more useful than AppleScript IMO) IIRC, there are also Python and Ruby bindings as well.

Yes and a Perl bridge as been part of OS X for even longer time (just type man PerlObjCBridge form terminal).

Additional refs:

- https://developer.apple.com/library/mac/documentation/Darwin...

- http://www.macosxautomation.com/applescript/features/scripti...

- https://developer.apple.com/library/mac/documentation/Darwin...

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

#102
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…

Applescript was only a front end for OSA, for instance there is/was a working perl front end for OSA. The reason it never really took off is mostly due to OSA itself, and not the scripting language I think.

For instance most of the Adobe product don't care about OSA and offer a Lua extension mechanism instead (even there, I feel they only cared avout filters and publishing modules). Or even iPhoto had severe limitations on what could be done through the scripting interface.

The Finder has perhaps the most useful interface, but anything done there can also be done in the shell IMO. There must be other apps exposing very useful functionalities to OSA, but I haven't see many.

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

#103

Earlier quoted context omitted.

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.

I agree, but I guess .filter or .where could be more difficult to understand for beginners.

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

#104

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.

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

#105

Earlier quoted context omitted.

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.

Agree. Hopefully (?) it's just JS by the point we get to `Mail.outgoingMessages` so it should be fairly straightforward to mix-in underscore's methods into whatever their 'collection' representation is, the same way Backbone does [1] to give you map/filter/which etc.

[1] http://backbonejs.org/#Collection-Underscore-Methods

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

#106
This is cool because as a programmer I found AppleScript difficult to pick-up quickly. However, after a recent foray into writing scripts for iPhoto and iTunes, the api's and documentation of those apps totally turned me off.

I'll be interested once I see some succinct JS to show me most played songs in last week, or recent photos imported from iCloud.

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

#107

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.

Scheme.

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

#108
post #91

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…

JavaScript isn't that bad. It certainly has it's faults but there are much worse languages that could have become ubiquitous than JavaScript. Honestly, I find web programming to be generally terrible. JavaScript is actually one of the better parts of it. Most of the time I work in C++ these days though.

You already know all the good stuff about weak typing and equality.

But let me give you a few recent examples I stumbled over: - Javascript can not format numbers with leading zeros. - Handling binary data is increadibly painful. - Object oriented programming is really convoluted. - Lack of classes and modules makes code structuring hard.

True, it could be worse. But Lua, Ruby, Python, Perl, Scheme, Clojure, and many others are much better languages with very similar feature sets. And then there's a whole host of languages with different features. I just don't see why you would Javascript in an environment where all these other alternatives are available.

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

#110
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_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ" set the source_string to "abcdefghijklmnopqrstuvwxyz" else set the comparison_string to "abcdefghijklmnopqrstuvwxyz" set the source_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ" end if set the new_text to "" repeat with this_char in this_text set x to the offset of this_char in the comparison_string if x is not 0 then set the new_text to (the new_text & character x of the source_string) as string else set the new_text to (the new_text & this_char) as string end if end repeat return the new_text end change_case

I'm assuming that this will be easier using JavaScript... :)

Post reply on HN