Hacker News new | ask | show | jobs
by m1sta_ 3532 days ago
I'm not debating the point, but how is that possible?
4 comments

I'm not sure how it's possible but it's definitely not rare. Lodash' methods are faster than their respective native implementations (Lodash `map` > `Array.prototype.map`).
As a general answer, doing something simple in pure JS can be more efficient than the overhead associated with making a native call from JS. The costs are going to vary depending on how the JIT handles things. That's probably the best general reason though as to how it's possible.
As I understand it, native promises don't make native system calls. They are still pure js. They are just implemented differently from Bluebird which optimizes for the most common use cases.
http://programmers.stackexchange.com/questions/278778/why-ar...

I'm not sure all of it still stands. Bluebird is in C. Native is in javascript.

Edit: i'm wrong

Bluebird isn't written in C. It doesn't even depend on a compiled node addon.