Hi are Coroutines days numbered now that LOOM is o...
# coroutines
t
Hi are Coroutines days numbered now that LOOM is on the way?
nope 12
r
Coroutines are still necessary for Android, native and JS. And Loom is in preview so far.
k
Also coroutines aren’t exclusively useful for IO related things (which loom is). Things like bridging callbacks to a flow to ensure cleanup happens properly will not be obviated by loom.
r
I don't agree, everything which can be done using coroutine can be done with Loom API. Cause Loom is not just virtual threads, it's also coroutines implementation on JVM.
For example, it's usage of Loom for Swing UI operations. https://gist.github.com/Anamorphosee/9a6436b9093b597ea69be405443f33ad
k
Interesting! TIL, thanks for sharing.
c
Coroutines are also not just concurrency. See the
sequence
builder for example.
k
and deeplyRecursiveFunction
r
sequence
can be implemented with Loom.
c
@reformator of course, but it will be extremely slow.
r
why?
c
Because virtual threads create a new execution context, the
sequence
doesn't, it just exploits the state machine generated by the compiler
(I'm not an expert, I could be wrong on this, but I understood Loom as purely "cheap-threads" oriented whereas
suspend
doesn't require threads at all)
r
Which Loom can do either. Give me 15 minutes, I'll write simple Sequence with Loom.
No, Loom is not just virtual threads.
c
Nice, thanks đź‘Ť
s

https://youtu.be/1qezCNVWpHcâ–ľ

a
Kotlin isn’t only JVM. So coroutines are here to stay