3 ms·
> Is that actually useful ? You can have "BlockingLongCall()" without async and it could block your thread from progressing for minutes - or you could have "awa
by piaste 4y ago
> Is that actually useful ? You can have "BlockingLongCall()" without async and it could block your thread from progressing for minutes - or you could have "await FunctionThatResumesImmediatelyOnTheCaller()" and it doesn't even context switch.
Very much so. Async is - I would guess 95% of the time - a proxy for IO operations.
Error handling is different: a pure function can and should be bug-free, while an IO function can always crash due to external factors. Performance tuning is different: a slow pure function needs optimization, parallelization, and worst case a faster CPU, while a slow async function usually needs you to dive into the plumbing part of your code to see if you're using an API wrong or something like that.
- moonchrome 4y agoBut in imperative OO style you're touching IO all over the place - this is why people complain about Task/Promise proliferation. And especially if you have something like interfaces where some implementation could require IO while other might not. In my experience you can't really use it to narrow down anything.