Hacker News new | ask | show | jobs
by andsoitis 1098 days ago
> you can't code anything without async

I'd like to understand what you mean by this. As soon as you introduce network requests in a system, don't you need to deal with asynchrony?

2 comments

You can just wait for the network request to finish before continuing. Many actions require it anyway.

Asynchronous code should be intentional and deliberate in my opinion, but in modern JS/Node it is the default which leads to all kinds of crazy workarounds, callback hell and race conditions. Node has the same issue PHP had now, where green devs will crank out code without realising they need to be watching out for these things.

Is it cool that a .forEach loop could be async? Heck yeah, should it be the default? The shit people write around .forEach loops suggests, maybe not!

What's not deliberate about marking a function as `async`, and marking calls that need to be awaited with `await`?

Callback hell? When was the last time you gave an honest effort into JavaScript?

He still has a point. Go code and similar languages hide the concurrency. You write synchronous looking code most of the time, but underneath, libraries and runtimes ensure you’re running concurrently.
Most libraries are async and some standard lib stuff is unexpectedly async as well, so you are often handling async concerns even if what you're writing is better syncronous.

My team and I don't write callback hell, it's just a very common pitfall and you still see it all the time. You can't bubble wrap everything I suppose.

Everything in JS started with callbacks, then promises came on to the scene with libraries like Bluebird, then the async/await syntax was added to the spec. The language was always able to handle concurrency but it was a long road to the current state.