Andy,

They are related by the fact that both are trying to help remove some of 
the pain of developing asynchronous code. They are different in the way 
they go about implementing this. 

Check out the articles on the How to Node blog that Tim Caswell runs, there 
are some good examples with explanations on why and how you can use each of 
these.

 - http://howtonode.org/control-flow
 - http://howtonode.org/control-flow-part-ii
 - http://howtonode.org/control-flow-part-iii
 - http://howtonode.org/step-of-conductor
 - http://howtonode.org/promises

After you have tried some of these different approaches, you will probably 
find that one or the other works best for you, so you will want to do most 
of your development that way. 

It is not to say that you might not use both from time to time, but you 
probably will want to minimize switching mindset from one to the other 
since they work different.

All the best,

Jeff

On Sunday, 25 March 2012 03:42:32 UTC-5, Andy wrote:
>
> *Note, I am not asking which tool is better, I am simply trying to 
> understand the differences.
>
> *I'm trying to wrap my head around promises in node. Right now I'm 
> writing all my code in callback soup. I am researching libraries and I 
> found async <https://github.com/caolan/async> (duh) but I also found the 
> horribly named but seemingly very popular q<https://github.com/kriskowal/q>
> .
>
> What I am trying to figure out is if these libraries are mutually 
> exclusive. The async page mentions nothing about "promsies" and instead 
> talks about "flow control." But it seems like both libraries are sugar for 
> handling async function flow and callbacks. Do they both solve the same 
> problem, or can / should they be used together?
>
> Take this example:
>
> async.waterfall([
>     function(callback){
>         callback(null, 'one', 'two');
>     },
>     function(arg1, arg2, callback){
>         callback(null, 'three');
>     },
>     function(arg1, callback){
>         // arg1 now equals 'three'
>         callback(null, 'done');
>     }
> ], function (err, result) {
>    // result now equals 'done'    
> });
>
>
> vs:
>
> Q.call(step1).then(step2).then(step3).then(step4).then(function (value4) {
>     // Do something with value4}, function (error) {
>     // Handle any error from step1 through step4}).end();
>
>
> Both libraries are doing things in a series, and both are passing their 
> results to the next function. Is there really any difference between the 
> two results other than Q returning a promise that you can chain to with 
> .then? 
>
> Is async really just a more versatile q? Or are there reasons to use one 
> and the other and they could be used together?
>
> And can you do parallel functions with promises? Or is that not what 
> they're used for? (And if not, should you use async + q, or is there too 
> much overlap?)
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to