4 ms·
Does anyone know how kotlin coroutines compares to async await in rust? And why did they choose async instead of coroutines?
by The_rationalist 7y ago
Does anyone know how kotlin coroutines compares to async await in rust?
And why did they choose async instead of coroutines?
- AlexanderDhoore 7y agoI don't know anything about Kotlin, but if you are interested in the Rust story (history and evolution) this is an interesting talk: RustLatam 2019 - Without Boats: Zero-Cost Async IO https://www.youtube.com/watch?v=skos4B5x7qE https://www.youtube.com/watch?v=skos4B5x7qE
- steveklabnik 7y agoI don't really know Kotlin, but it was discussed while async/await was being designed. https://www.reddit.com/r/rust/comments/83tak7/implementing_kotlinstyle_continuations_on_top_of/ https://www.reddit.com/r/rust/comments/83tak7/implementing_k... is one thread I remember. There's also https://www.reddit.com/r/rust/comments/6zy8hl/kotlins_coroutines_and_a_comparison_with_rusts/ https://www.reddit.com/r/rust/comments/6zy8hl/kotlins_corout... One tough part about digging through history here is that designs change over time...
- pcwalton 7y agoRust doesn't use M:N threading (coroutines) because it was found to be slower than 1:1 threading in practice. Async/await avoids allocation of stacks entirely and can therefore be faster than both 1:1 threading and M:N threading.
- Rusky 7y agoKotlin coroutines are just async/await with different syntactic defaults. That is, when you call a `suspend fun` it is awaited by default, and if you want to get a promise/future/etc from it instead that's when you write an extra annotation. Rust went the way it did syntactically because annotating the await points lets you see them when reading a program, and possibly out of familiarity. Rust went the way it did implementation-wise (stackless rather than stackful) because it's more efficient.