What are Coroutines
I'm reading the Kotlin documentation, and the question arises. What are coroutines actually? The keyword
suspend is used in the syntax and I think that's a clue. I believe Coroutines are blocks of code that can suspend the execution. Meaning that the thread working on the things in the thread could do some of the things in the coroutine, and then suspend the work to work on other things. How would this be working?
Scala. The idea here is that code execution is happening by scheduling function calls onto a queue, and then there is an
Akka, where you have an actor system who's execution also basically occurs through an event loop. This turned out to be a very powerful paradigm for code, since it allows web servers to handle loads of requests at the same time, because of this suspending of execution, a service can tend to many requests in parallel without having to have an expensive thread working for each request.
My belief is that this is the idea that Kotlin has now taken and integrated into the language. You could, as I said, already do this in Scala, because it's not really built into the language. You need to create an
ActorSystem that can handle tasks etc.. In Kotlin you only seem to need to use the