3

I see a lot of NodeJS articles recommending the Bluebird library for promisifying your code and avoiding callback spaghetti.

Is there any value in using such a library when using Node 4.2.4+ given that ES6 has native Promises? What can I do with Bluebird that I can't do with ES6 promises?

The Bluebird documenation is sparse and only really helps if you already "get" promises. Do I really need another library which might confuse the issue and introduce bugs?

3
  • "avoid asking subjective questions where … your question is just a rant in disguise: “______ sucks, am I right?”" (help center) – gnat Feb 6 '16 at 11:30
  • 3
    I am not given to rants. I have toned the question down a bit. I don't feel it is a rant in disguise. It is a genuine question which I would like an answer to from someone more knowledgeable on the subject than me. – codecowboy Feb 6 '16 at 11:32
  • 3
    I believe there was a time when ES6 promises were newly implemented and were surprisingly much slower than bluebird promises. But I believe that's no longer the case. And that illustrates why we don't normally take questions asking us to evaluate specific implementations of various tools/languages: even in the unlikely event we get it right, our answers would inevitably go out of date. – Ixrec Feb 6 '16 at 11:56
3

Here's a good answer by the bluebird author about the speed issue with ES6 promises. Obviously, he has a bias, but he's also looked at the problem in quite some detail. Those issues that slow down ES6 promises are because of the way they are specified, and therefore are still present. I don't think it's drastic enough for speed to be your deciding factor, unless speed is really critical and you've verified the promises are your bottleneck, but it is there.

Much more importantly, ES6 promises are an extremely bare bones implementation, essentially the minimum you can do and still call it a promise. You're talking 6 methods compared to bluebird's 70 or so. Sure, you can make do with those 6, but when you start using promises in depth, you start running into the same kinds of problems over and over again. How do I implement a timeout? How do I easily convert existing functions to use promises? How do I compose and manipulate groups of promises more easily? These are the sorts of problems bluebird solves that ES6 makes you implement yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.