Hey Jean -
Ya, I've been tracking task.js for awhile now - just haven't delved in too deeply since node is realistically the only platform generators are going to be practical on in the near future (browser support is obviously pretty sparse still). On the one hand, task.js is awesome and deserves the hype it's received. On the other hand, I find the promises layer to be a deterrent against using it for Node applications, since the majority of the node ecosystem is based on passing callbacks/continuations, rather than promises. That's probably the most fundamental difference between suspend and task.js: suspend is designed to be
> After much thinking, I came to the conclusion that this flow control issue is not such a big deal, solutions like "promise/a" demonstrates that async activities can be orchestrated in a readable way without threads.
I agree that promises *can* improve the situation, but I think it has to be all-or-nothing. The random hodgepodge of promises use in node modules is problematic - it's not the fault of promises, of course. It's just confusing when/where you need to .then() vs. pass a callback. Regardless of your feelings towards promises, though, it's important to recognize that they're still just an abstraction on top of callbacks - you're either passing a callback to the method itself, or you're passing a callback to some method on your promise/future/deferred/etc. This is why generators are particularly interesting with regards to async code: they're the first *language* level construct in JS that allows this async behavior without relying callbacks.
> I am conducting an experiment about a similar control flow problem
Parole looks really interesting! I'm going to give the source a more thorough reading once I have time, but on first glance I like that it thinks outside of the box, compared to 90% of the other control flow libraries out there.
> This is more concise, does not have the array destructuring issue, runs today everywhere and is readable once you understand that a Parole() is an extended Function suitable as a node.js callback.
Given where destructuring assignment and generators currently stand in V8/node, you're probably right for now, but remember that my goal is to get ahead of the curve here in anticipation of these upcoming language features. I think I would still prefer the following:
var resume = require('resume'), fs = require('fs');
suspend(function* (resume) {
var [err, buffer] = fs.readFile(__filename, resume);
// no callbacks or .on()'s or .then()'s, just use it!
console.log(buffer.toString('utf8'));
});
True, you have to pay the suspend/generator block, but that's a tax you only have to pay once, and you can have as many async calls in there as you'd like with no additional "taxation".
Thanks for the feedback, and I'm looking forward to hacking around with Parole!
- Jeremy