In kotlin it’s always to move blocking calls onto ...
# coroutines
In kotlin it’s always to move blocking calls onto a separate dispatcher where as in go - you just launch
go funcs
and put whatever you want in it and let the scheduler deal with it
Which scheduler do you have in mind? Kotlin coroutines are not fixed on one way of dispatching task or another. You can use single thread dispatcher or default work-stealing pool, or even custom dispatcher of your own choice.
Kotlin has to work with the jvm, which already has such things as threads and thread-blocking calls. It also has to integrate with existing frameworks that may have specific threading requirements (eg most UI frameworks). Go has its own runtime, and so they have full control over everything in it. It's pretty much impossible to "block" a thread in go like you would on the jvm because the runtime can interrupt the execution of any function at any point and schedule something else. All IO functions in go are effectively suspending functions. Kotlin can't do that because it could be calling out to java code that blocks the thread, and Kotlin has no control over that code. Once the jvm gets fibers, this might change since the jvm will natively support a form of coroutines, but that's a long way off and I'm not sure what impact that will have on kotlin's coroutine runtime.
👍 2