Received: by 10.224.108.68 with SMTP id e4mr9525293qap.4.1332745326344; Mon, 26 Mar 2012 00:02:06 -0700 (PDT) X-BeenThere: nodejs@googlegroups.com Received: by 10.224.44.65 with SMTP id z1ls6308944qae.7.gmail; Mon, 26 Mar 2012 00:01:50 -0700 (PDT) Received: by 10.224.184.70 with SMTP id cj6mr9551591qab.3.1332745310378; Mon, 26 Mar 2012 00:01:50 -0700 (PDT) Received: by 10.224.184.70 with SMTP id cj6mr9547184qab.3.1332744977788; Sun, 25 Mar 2012 23:56:17 -0700 (PDT) Return-Path: Received: from mail-qc0-f180.google.com (mail-qc0-f180.google.com [209.85.216.180]) by gmr-mx.google.com with ESMTPS id b22si6483665qcs.3.2012.03.25.23.56.17 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 25 Mar 2012 23:56:17 -0700 (PDT) Received-SPF: pass (google.com: domain of axk...@gmail.com designates 209.85.216.180 as permitted sender) client-ip=209.85.216.180; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of axk...@gmail.com designates 209.85.216.180 as permitted sender) smtp.mail=axk...@gmail.com; dkim=pass header...@gmail.com Received: by mail-qc0-f180.google.com with SMTP id d15so3098118qcs.25 for ; Sun, 25 Mar 2012 23:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=FoDrJOfwOZ/8QvTwpS9an3bZ9K9P+seOe54s8tc9s88=; b=CrwsHs+lmnJ3a/mSWfUjtwTFO2w4MzW9uY9g3O1taa1YNwo7KQZECGy3395M6h2V9H PwUXNldFioUapeRnb4+5YtDOhjn5OZRkSoJgYVAcGjF7UPwx9p/s/h/Z8cSirO80R/EI 8Ozs0dACD8aA8zh+Y6HOa0yM9G3NHrLgZjfu8PtjB7F1IlNlXSS1/KhSqtJI7sET9PBG TMmRZ9WoyZXn1Bkc32W0B3Vhq/ZxbrLqQXUv9BGT745w1zt/6Ts6rwdyQQha1qh8Si1T jXB1jXGhAFYGLCbdsiWxvvoBzeq4Mvo7sb+1iC1F/vkgSW/2g7q5vYp2S6AkjgFNcn/I fIdw== Received: by 10.224.223.76 with SMTP id ij12mr26314088qab.11.1332744977611; Sun, 25 Mar 2012 23:56:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.50.9 with HTTP; Sun, 25 Mar 2012 23:55:57 -0700 (PDT) In-Reply-To: <6543823.1059.1332664952796.JavaMail.geo-discussion-forums@pbnt10> References: <6543823.1059.1332664952796.JavaMail.geo-discussion-forums@pbnt10> From: Axel Kittenberger Date: Mon, 26 Mar 2012 08:55:57 +0200 Message-ID: Subject: Re: [nodejs] trying to wrap my head around "promises" - async vs Q To: nodejs@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 AFAIK they should be working together, but why would you need two times the same thing with differnt dependencies? Also note that there isn't an established vocabulary what is a "promise", "future", "flow control" and the differences. There are even far more libraries just like this, and even yet more solutions approaching the problem from different . This is the usual experience, "node.js oh so great" --- a day later, "OMG I can't handle all that callbacks, statemachine logics etc.". One Week later: yet another syncronisation library has been submitted to teh repository. On Sun, Mar 25, 2012 at 10:42 AM, 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 > (duh) but I also found the horribly named but seemingly very popular 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 nodejs@googlegroups.com > To unsubscribe from this group, send email to > nodejs+unsubscribe@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en