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.
Meh. Like async, coroutines will be a rarely used niche feature once Loom lands. Virtual threads appear to give 95% of the performance benefit while letting you write "normal" code. Very rare you need that extra 5%
There is small speed advantage not managing stack frames for async. And compatibility layer that makes Virtual Thread look like real thread has some cost. But this is also a huge debugging and ergonomic advantage, and if Oracle is to be believed the cost for these convience is minimal.
Maybe in low-level places like inside Netty for instance async Java will survive. But at application level the advantage of virtual thread well worth the cost.
14
u/koreth Apr 06 '22
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.