Promises (Q) vs Callbacks (async)
Recently I've had some free time (well, not complete true--more like I've made some free time) to look into the NodeBB source and plugin system. When I first started a NodeBB forum about a year ago, I hacked together a little plugin that was ok for v0.5.x, but now it's time to upgrade to v0.8.x.
Anyway, last night I was looking through some of the other plugins and even the NodeBB source..and I'm curious why the developers decided to use callbacks and heavily rely on the async library instead of using promises and a library like Bluebird or Q? I'm sure it is relative to the perspective of the developer, but those I have met agree that promises are neater to write and easier to read than callbacks. I definitely think they are easier for tracking errors because instead of keeping track of that pesky error parameter in every callback, you just have a
.catch()at the end of your chain.
I'm not blatantly suggesting a rewrite of the source, just genuinely curious why one approach was chosen over the other. And I like reading more of the history and culture that went into making NodeBB.
I've used async, Q Bluebird and of course callbacks. Sometimes you find one is easier to wrap your mind around than another for each given task. Sometimes when it's a dead heat you lean towards what you're used to.
I've got to say, performance wise and for code readability I've become a big fan of Bluebird. You can always bring Bluebird into the mix for any plugins you write and then .promisify other bits of code that are using callbacks so your new code is new Promise shiny.
Very good points about Bluebird. Its performance numbers are surprising, and the utility it brings with
Promise.promisifyAllmakes it so easy to convert callback code to promises.