Title
n

ninjasudo

05/18/2017, 9:15 PM
Coroutines vs Promises: differences, benefits of one over the other, etc? I haven't touched Kotlin much yet, so I'm curious if there are some more experienced voices who could weigh in...
u

umar

05/19/2017, 12:01 AM
ninjasudo: Look at #coroutines channel In short, coroutines are like light weight threads. You can launch 100000 coroutines at once and don't get out of memory error. How you will use it depends on framework you chose. So, promises, rx, forkjoin, all can be wrapped by coroutines. Also, Kotlin has first class syntax for coroutines. You can write sequential nonblocking code as it was synchronous code, without nesting tons of callbacks. https://kotlinlang.org/docs/reference/coroutines.html#experimental-status-of-coroutines https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md
n

ninjasudo

05/19/2017, 12:07 AM
Thanks for the synopsis, I'll certainly look into it more. We're about to do a 3 day hackathon writing an app from scratch in Kotlin. I'm already used to Promises and asynchronous code flows. It's good to hear this is first class in Kotlin.
u

umar

05/19/2017, 12:28 AM
b

blakelee

05/19/2017, 4:40 AM
@umar So it's coroutines < threads < processes?
u

umar

05/19/2017, 5:01 AM
I don't understand what you mean. Can you explain?
b

blakelee

05/19/2017, 7:29 AM
Coroutines are very portable. Threads have a little overhead, and processes a lot of overhead
u

umar

05/19/2017, 12:27 PM
Yes, they have very very small overhead
Understood you