What features from Kotlin/JVM aren't available in ...
# kotlin-native
i
What features from Kotlin/JVM aren't available in Kotlin/Native?
j
You can see the differences with the colored platform filters in the documentation: https://kotlinlang.org/api/latest/jvm/stdlib/index.html ( at the top and the colored dots) Obviously only the shared features from standard lib are on both platforms. For other things you need to find Multiplatform libraries or write expect actual statements.
i
thanks, i was looking something like that 🙂
g
This link is stdlib, not language features (but it still important of course). I think all stable features are available on K/N
i
@gildor so even courotines and reflection?
g
Coroutines yes
Reflections no, it’s not a core part of the language
Reflections are based on JVM reflections
and are very limited for JS and Native
i
ok, sure, I wonder if there is any possibilities for library like Gson on Native what about multithreading is it production ready on K/N?
g
Coroutines part in the language is tiny, just a few basic types and support of suspend modifier, but it’s available for all the platforms, but most of high level features are parts of kotlinx.coroutines, which are also available for K/N (but not everything, only single-threaded)
Gson is purely JVM, so no way to reuse it on K/N even in theory
but there is kotlinx.serialization which targets all Kotlin platforms
i
ok, sounds great
So coroutines are but single threaded, what about any multithreading? Is it in progress?
g
it requires changes from K/N side, existing threading strategy doesn’t work for multithreaded coroutines You can check discussion here https://github.com/Kotlin/kotlinx.coroutines/issues/462
i
many thanks! no more questions for now 😉
👍 1
n
If you want multi-threading on Kotlin Native then you will have to use Workers instead of Coroutines. This presentation provides a overview of Workers: https://resources.jetbrains.com/storage/products/kotlinconf2018/slides/5_Kotlin-Native%20concurrency%20and%20memory%20model%20(1).pdf
👍 1