Home > Net >  Does Node.JS include JS Promises?
Does Node.JS include JS Promises?

Time:06-25

I watched an interview with Ryan Dahl (the author of Node.JS) in which he regretted that he made the decision not to include Promises in Node.JS - and that this fact was among his motivations for including Promises in Deno, which conceptually seems a lot like Node.JS. However, from what I can see, Node.JS does include Promises, and I cannot see why it would not, since it is based on V8. Am I missing something?

CodePudding user response:

A bit of research and/or more consistent interview watching will give you the answer.
Dahl said that he did introduce the promises to Node in 2009 but later in fabruary 2010 he foolishly removed them. Here is the link with timecode:
https://www.youtube.com/watch?v=M3BM9TB-8yA&t=309s

Later in 2012 Dahl made a step away from Node which means that subsequent updates were no longer associated with him.
Surely Node.JS nowadays has promises but it's not straight Ryan's merit.
That's it nothing more, nothing less.

CodePudding user response:

Ryan Dahl was speaking of a period long before promises became part of the ECMAScript specification. He talked about this in this presentation "10 Things I Regret About Node.js" (at 5:40), with this slide:

Regret: Not sticking with Promises

  • I added promises to Node in June 2009, but foolishly removed them in February 2010.
  • Promises are the necessary abstraction for async/await.
  • It's possible that unified usage of promises in Node would have sped the delivery of the eventual standardization and async/await.
  • Today Node's many async API's are aging badly due to this.

This was a time when Node was in its first year (when version numbers started with 0), and although the concept of promises was long known, it was not yet included in the ECMAScript standard. It was only with ECMAScript 2015, that promises got included, and since Node version 4 in 2015, Node has had this native promise support.

If Node had not abandoned promises in 2010, many modules would have used it, and we would not have ended up with so many async modules which are either obsolete or needed awkward tailoring (with backwards compatibility) to make them work with promises.

  • Related