https://kotlinlang.org logo
#announcements
Title
# announcements
v

victoralissont5

06/25/2019, 11:10 PM
Moreover, Kotlin's concept of suspending function provides a safer and less error-prone abstraction for asynchronous operations than futures and promises. Could someone explain why this is true?
s

streetsofboston

06/26/2019, 12:09 AM
Using Coroutines, you can program asynchronous code as if it is regular code, as if your code is not blocking at all and immediately returns the result. This allows you to simply use 'when' statements, 'for' loops, mutable local variables, etc, to program in a familiar sequential way. No more need for callbacks or 'map', 'flatMap', etc.
And with its Structured Concurrency, canceling asynchronous tasks is easier and it helps you prevent from 'leaking' them.
g

gildor

06/26/2019, 12:47 AM
Structured concurrency is indifferent to suspend functions, it's way to manage resources of coroutines builders that are not suspend functions