|
|
|
|
|
by vjerancrnjak
234 days ago
|
|
It's more about how the code ends up evolving. Async-await in JS is sometimes used to swallow exceptions. It's very often used to do 1 thing at a time when N things could be done instead. It serializes the execution a lot when it could be concurrent. if (await is_something_true()) {
// here is_something_true() can be false
}
And above, the most common mistake.Similar side-effects happen in other languages that have async-await sugar. It smells as bad as the Zig file interface with intermediate buffers reading/writing to OS buffers until everything is a buffer 10 steps below. It's fun for small programs but you really have to be very strict to not have it go wrong (performance, correctness). |
|
That being said, I don't understand your `is_something_true` example.
> It's very often used to do 1 thing at a time when N things could be done instead
That's true, but I don't think e.g. fibres fare any better here. I would say that expressing that type of parallel execution is much more convenient with async/await and Promise.all() or whatever alternative, compared to e.g. raw promises or fibres.