How does Kotlins coroutines fit in here for I/O bound work especially? IIRC, Kotlin has some compile time tricks to create a state machine.
The JEP mentions:
goroutines in Go and processes in Erlang
but nothing about Kotlin's coroutines.
Edit: actually, Kotlin is mentioned at the end:
Most languages that have adopted syntactic coroutines have done so due to an inability to implement user-mode threads (e.g., Kotlin), legacy semantic guarantees (e.g., the inherently single-threaded JavaScript), or language-specific technical constraints (e.g., C++). These limitations do not apply to Java.
At the risk of committing a faux pas by talking Kotlin in the Java subreddit: My understanding is that the two will play well together: it'll be easy to run coroutines on virtual-thread-based executors.
Obviously with virtual threads, coroutines will become unnecessary in some places where they're currently used as a way to run code on multiple threads. But as a language feature, coroutines are more than just a threading abstraction: they're used for dynamic generation of sequences and other things. Those use cases will still be just as valid in a Loom-based world.
It very much sounds like initially loom will only expose Virtual Threads in terms of public API but in a future release offer API for the lower level continuations etc to support use cases like generators (my interpretation from following the mailing list).
coroutines are more than just a threading abstraction
So in time (not first release) this sounds very likely for Loom as well (when the lower level constructs are exposed).
11
u/python_geek Apr 06 '22 edited Apr 06 '22
How does Kotlins coroutines fit in here for I/O bound work especially? IIRC, Kotlin has some compile time tricks to create a state machine.
The JEP mentions:
but nothing about Kotlin's coroutines.
Edit: actually, Kotlin is mentioned at the end: