https://github.com/utilise/emitterify/issues/1#issuecomment-...
The way it is now, I defensively await things all over the place. What's worse, it propagates. If any of your function's dependencies are async, your function will also have to be async (or be ok with continuing operation after it's returned) and it turtles all the way down.
It is nicer than having to deal with promises directly though, there is that.
But it still beats promises or callback hell.....
JS async produces Promises like C# produces Task, so you can call an async function and use the result as a Promise.
And then() hell ...
Also notable is that async/await isn't new for node, 7.10 supported it (and previous versions with a flag). It's new for a LTS release. What is new, however, is the in-built util.promisify that can convert callbacks into native promises.
Yeah, a lot of companies won't touch non-LTS Node though, so a lot of users won't use async/await until later this year when the next LTS is released (Oct 2017).
Except in their official release blog posts, it seems :-D
Another fine example of JavaScript trying to be hip and ignoring the lessons learned from countless other languages over the years.
I see this constantly with JS like with the 3+ ways to check for NaN and the object "freeze" system that doesn't actually make objects immutable. They take a solid concept from other languages then put a snazzy spin on it that makes it fucking useless. Then try again in the next version. JS library and syntax is littered with corpses of failed experiments.
At least they finally have a usable ForEach loop after three attempts.
Please typescript save us from this hubris.
Pending the implementation of new language syntax, raw Promises were a practical solution for what they set out to accomplish. If you don't think they improved callback hell at all, I expect that you probably weren't using them correctly (an easy mistake to make without looking at the documentation and/or reading the wrong tutorials / blog posts).
cf.
getAsyncValue1(a =>
getAsyncValue2(a, b =>
getAsyncValue3(b, c =>
doSomething(c)
)
)
);
and getAsyncValue1().then(a =>
getAsyncValue2(a)
).then(b =>
getAsyncValue3(b)
).then(c =>
doSomething(c)
);
Sure, async/await flattens that to zero nested callbacks, which is great, but with that off the table I'd rather deal with code flattened to one level deep (or a few, in some edge cases) than arbitrarily many. And that's just the "callback hell" improvement; don't forget what a nightmare error handling with callbacks can be — you have to handle both synchronous exceptions and error value callback parameters, you have to deal with the possibility of the asynchronous function unexpectedly calling your callback more than once, etc.
Notably, it brings async/await syntax to vanilla JS. This new feature complements callbacks and largely replaces how Promises are currently consumed (opting for sequential-like execution with try/catch blocks instead of Promise chains).
The closest analogue would be Tasks in C#.
EDIT: removing reference to node-v8 to prevent confusion.