A hill I will die on: There is no good reason to use `async/await` in JS/TS/Flow. - Specialized to thenables, not overloadable due to wrapping vals in promises - Tries to mask declarative async code as procedural sync code - No perf benefits vs 3rd party Promise implementations
-
-
Replying to @_joshburgess
angelo 🦊 Retweeted Mathias Bynens
Some time ago there was this: https://twitter.com/mathias/status/1062000234203496449?s=21 … True? Not true?
angelo 🦊 added,
2 replies 0 retweets 1 like -
Replying to @AngeloGulina
I've seen people talk about how V8 optimizes it, and I, admittedly, don't know much about that, but when I last checked I saw that Promise libs like Bluebird & Creed, and other async libraries, like Most (streams) are significantly faster than native promises. Wasn't even close.
2 replies 0 retweets 2 likes -
Replying to @_joshburgess @AngeloGulina
The gist of it is that every time you use `then` a new Promise object is created, even if it's in a `then` chain where that particular Promise itself is never assigned to anything. When you use async/await, V8 is able to optimize these "intermediate" Promise objects away.
1 reply 2 retweets 6 likes -
Replying to @mvaldesdeleon @AngeloGulina
Does that really matter in practice though? I mean, if you start off with a library that's already much faster, like Bluebird or Creed, or skip promises altogether in favor of a fast streams library, does that async/await optimization make any meaningful difference?
2 replies 0 retweets 1 like -
Replying to @_joshburgess @AngeloGulina
Honestly, I don't think any of the code micro-optimizations matter in practice, at least in 99% of the cases. A promise chain should not be your performance bottleneck.
2 replies 1 retweet 2 likes
It is a bottleneck if you’re running a Node.js server that uses promises heavily, which is not an uncommon thing to do. But the good news is that perf is now on par!
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.
JavaScript performance advice:
1. prefer `async`/`await` over hand-written promise code
2. prefer native promises over userland implementations