4 ms·
Async being a “default” function type doesn’t make much sense unless you’re doing io. If you’re just computing, you often can’t proceed without the result and w
by drb91 8y ago
Async being a “default” function type doesn’t make much sense unless you’re doing io. If you’re just computing, you often can’t proceed without the result and want to proceed as soon as you have the result—i.e. blocking. Both are critical to getting good performance.
I’m curious if discerning which is the best type is possible to tool automatically with static or tracing analysis.
- gpderetta 8y agoGenerators, a-la python for example, are completely equivalent to async functions and have nothing to do with IO.
- drb91 8y agoTrue! However, I believe rust has a separate, distinct yield/generator functionality coming that should address those needs separately. I think off-hand it’d be pretty easy to wrap them in a stream, or to join a stream into a generator, if you did want to compose them.
- steveklabnik 8y agoThat’s correct; async/await uses Generators under the hood, but we haven’t stabilized them yet. It’s the plan to though!