I am writing a sizable Node app myself. In the end, you just get used to the callback style.
I am writing a sizable Node app myself. In the end, you just get used to the callback style.
From what I can tell, CoffeeScript - and the Javascript/Node world - would really benefit from something like F#'s workflow/computation-expression syntax, which will take a fairly straight-forward readable statement and behind the scenes de-sugar the hell out of it into a bunch of closures.
http://en.wikibooks.org/wiki/F_Sharp_Programming/Computation...
EDIT: search for "De-sugared syntax" on this page for an example.
Deferreds are * Mostly monadic (creating a deferred is "return", the "then" method is "fmap" and "bind"). * Can be implemented as a library, without a separate compilation step or having to patch the runtime. * Avoids most of the CPS inversion of control madness. You can return and store promises and you can also add callbacks after the fact so code is much more flwxible. (writing sequential async loops is still annoying though)
I liked this article that discusses three different solutions to callbacks with different compromises: http://blog.willconant.com/post/7523275566/continuations-in-...
Jeremy discusses #350 and tamejs here: http://news.ycombinator.com/item?id=2777196
Tamejs have a great writeup about the callback spaghetti problem here: http://tamejs.org/