Eduard Ruzga
1 min readJun 26, 2024

--

Reason its so controversial is that there are no good alternatives in JS.

We had events before which was not better and hard to do.

We had callbacks too.

Then we had Promises that still had freaking staircases to hell

There are actually memes about it:

https://miro.medium.com/v2/resize:fit:1400/1*iqx2E-trd6wSzZ06EIA4cA.png

Then we had generators that are kinda concurrency, they kinda pause execution.

But writing async code with them is a chore... I only once worked with them extensively with Sagas for Redux

And I would not use them again.

Async/Await is not perfect but its better then what I listed above and it comes from a decade of working in that area.

You mention alternatives in other languages that work very differently.

I would challenge you to write complex example using your alternatives.

By the way, you are wrong that async functions turn functions that use them async. That is not true.

Here is example

async function a(time) {

return new Promise( resolve =>

const time = Math.random()*1000;

setTimeout(() => resolve(time), time)

}

function b() {

Promise.all([a(), a()]).then(console.log);

}

b uses async a, but is not async itself.

Its rare and sometimes anti pattern.

Actually may be its not even rare :D

--

--

Eduard Ruzga
Eduard Ruzga

Written by Eduard Ruzga

We make our world significant by the courage of our questions and by the depth of our answers — Carl Sagan

Responses (3)