https://kotlinlang.org logo
#coroutines
Title
# coroutines
t

Tower Guidev2

01/27/2023, 11:50 AM
Hi are Coroutines days numbered now that LOOM is on the way?
nope 12
r

reformator

01/27/2023, 12:10 PM
Coroutines are still necessary for Android, native and JS. And Loom is in preview so far.
k

kevin.cianfarini

01/27/2023, 12:32 PM
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

reformator

01/27/2023, 12:41 PM
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

kevin.cianfarini

01/27/2023, 12:52 PM
Interesting! TIL, thanks for sharing.
c

CLOVIS

01/27/2023, 1:04 PM
Coroutines are also not just concurrency. See the
sequence
builder for example.
k

kevin.cianfarini

01/27/2023, 1:07 PM
and deeplyRecursiveFunction
r

reformator

01/27/2023, 1:07 PM
sequence
can be implemented with Loom.
c

CLOVIS

01/27/2023, 1:08 PM
@reformator of course, but it will be extremely slow.
r

reformator

01/27/2023, 1:11 PM
why?
c

CLOVIS

01/27/2023, 1:11 PM
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

reformator

01/27/2023, 1:15 PM
Which Loom can do either. Give me 15 minutes, I'll write simple Sequence with Loom.
No, Loom is not just virtual threads.
c

CLOVIS

01/27/2023, 1:55 PM
Nice, thanks 👍
s

streetsofboston

01/27/2023, 1:56 PM

https://youtu.be/1qezCNVWpHc

a

Arjan van Wieringen

01/27/2023, 7:58 PM
Kotlin isn’t only JVM. So coroutines are here to stay
12 Views