https://kotlinlang.org logo
Title
v

Vincent Williams

11/04/2019, 5:13 PM
This may be a stupid question, but does anyone know why coroutines in kotlin were designed the way they are? It seems like concurrency in other languages is much simpler with easier to understand syntax (im thinking async await). To me it seems coroutines in kotlin have a higher learning curve than what I have seen in other languages and im wondering if this was something done on purpose or if it will get better as time goes on.
z

Zach Klippenstein (he/him) [MOD]

11/04/2019, 5:15 PM
The way Kotlin has implemented coroutines is more flexible, because you can do more than just `async`/`await`. See the
sequence
builder. Async/await are just implemented as a library on top of coroutines.
m

magnumrocha

11/04/2019, 5:18 PM
I really recommend you take a look in the Kotlin coroutines API and the possibilities that it can achieve, then compare with the others languages that you have use coroutines, then you will know...
v

Vincent Williams

11/04/2019, 5:19 PM
So far I have only used it to run db and network operations asynchronously. I have also taken a look at Flow and Channels but those seem to just be an Rx abstraction on top of coroutines
p

pg

11/04/2019, 5:20 PM
There is amazing talk about designing coroutines by Roman Elizarov, who works on kotlin coroutines and libs. https://twitter.com/relizarov/status/1157398580170252300?s=19
v

Vincent Williams

11/04/2019, 5:22 PM
Thank you! I will definitely watch that!
p

pg

11/04/2019, 5:28 PM
Btw, in the talk async await was mentioned if I remember correctly, so I think you should get answers for most of your questions :)
v

Vincent Williams

11/04/2019, 5:29 PM
ya that talk looks like it answers my question. I will check it out. Btw I assumed there was a good reason for the way they were designed, I just wasnt sure what the reason was xD
e

elizarov

11/04/2019, 7:21 PM
This might a better intro talk, also has async/await comparison

https://www.youtube.com/watch?v=hb0hfHVWCS0

v

Vincent Williams

11/04/2019, 7:22 PM
Thank you Roman! I will watch both
s

Stephan Schroeder

11/06/2019, 9:26 AM
s

Simon Kågedal Reimer

11/06/2019, 7:21 PM
@Stephan Schroeder Wow, that blog post is amazing
s

Stephan Schroeder

11/07/2019, 10:36 AM
yeah, I’m pretty sure that’s the fundational article on structured concurrency.