Also disagree about "What is asynchronous programming, and why is it so damn awkward?"
It's not awkward in the least. Either you write your code to remember the things you need to remember, or you use something like continuations which will be pretty inefficient and ugly (IMHO).
Overall, I think this is a win for clarity. But I think the author should also transform functions that take a callback argument, and implicitly convert them to continuation style. Perhaps this could by adding the callback parameter automatically and transforming 'return' into a callback invocation?
async function (x) { return x; } =>
function (x, callback) { callback(x); }
I plan to write a follow-up shortly that discusses possible approaches of doing this sort of thing, and your suggestion is one of the ideas I'm going to explore. Thanks for reading & commenting :)
continuations may well be inefficient, it depends on the runtime. `defer` does not implement real continuations, so that's largely irrelevant - there is no runtime overhead that you don't already have by writing your own callback functions.
As for ugly, do you refer to the compiled output, or the source code? gcc outputs some pretty ugly assembly code; does it matter?
I've written a large amount of async code now, both in js and in java. I don't ever feel it's awkward, do you have an example of this awkwardness?
Apart from the fact that both compile to JavaScript, CoffeeScript and Objective-J don't really sit together in the same boat. Objective-J is an actual runtime and interpreter: every single method you call is intercepted and handled by "objj_msgSend", so that things like method_missing are possible. See:
http://ejohn.org/blog/javascript-language-abstractions/#comm...
CoffeeScript limits itself to current common patterns of JavaScript in practice, and (in a perfect world) would compile 1-to-1 into the JavaScript you would have written. Unlike an implementation of Ruby or Python in JavaScript, where even simple things like numbers work quite differently, the semantics of CoffeeScript are just JavaScript semantics -- so there shouldn't be anywhere for the abstraction to leak.
As to sticking to a single common syntax -- that's a very good argument, and I'd have hesitations introducing CoffeeScript into a team project. But if you just want to play around with a fun way to write JS. I encourage you to give it a spin. For an example, take a peek at this implementation of the Buddhabrot fractal (the render will peg your CPU, so use Chrome):
http://jashkenas.s3.amazonaws.com/misc/buddhabrot/buddhabrot...
Here's the CoffeeScript that runs it:
And here's the compiled JS (not too different):
Considering the unstructured default nature of JavaScript and its flexibility, I would say that you can get much farther of the trodden path by just using certain libraries. Adapting to a different syntax that just expresses things slightly different/shorter than you'd usually do things isn't as hard as actually doing things a different way. Straightforward jquery written in Coffeescript should be easier to understand than code that heavily uses wu.js, underscore and/or js.class.
Of course, Objective-J has both syntactic additions and a huge Library tacked on. It's more meant to people who already work with Cocoa, so that their adjustments have to be minimal than for people coming from JavaScript.
Coffeescript doesn't really compare to that. It's actually pretty minimal, and you shouldn't have trouble using it with JavaScript libraries, unless they depend too much on certain syntactic stylings (I bet fab.js won't play nice).
Wu.js (thanks for the link) still looks like Javascript to me and won't cause any problems with Firebug or Emacs. Coffeescript and Objective-J have a completely different syntax. I can believe that Coffeescript is easier to read but it doesn't seem like enough of a win to break tool support and to work in two completely different syntaxes (inevitably there will still be plain js to deal with in most projects).
Objective-J seems even riskier. I can see the appeal for Cocoa people but you're really going all-in with that kind of framework.
Despite this, because stack frames are first class objects in Smalltalk, it's very easy for the user to implement continuations. You just traverse the stack to capture the continuation, and switch stack frames with the continuation's in order to invoke it. The resulting Continuation class is almost improbably literal in its implementation.
This is what frameworks like Seaside do.
Part I: http://github.com/jashkenas/coffee-script/issues/issue/241
Part II: http://github.com/jashkenas/coffee-script/issues/issue/287
Part III: http://github.com/jashkenas/coffee-script/issues/issue/350
If you have a suggestion for how to handle the bits of "defer" that are still undecided, such as how to handle the "return" statement, and enforce a callback parameter, please feel free to add it to the third ticket.