Jetbrains have released a new version of their Kotlin/Native technology. With Kotlin/Native, you can compile Kotlin to native binaries that run without any virtual machine. It can also be used when a developer needs to produce a reasonably-sized self-contained program not requiring an additional runtime.
Kotlin/Native is now available in version 0.8 with the focus on safer concurrent programming, extending the stdlib functionality, and better iOS development support. The version also hosts numerous bug-fixes and performance optimizations. Let us take a look into each one in detail:
Better concurrency support
The version 0.8 improves concurrency support with the addition of shared immutable state and improved atomic values and references. Previously, Kotlin/Native applications kept the singleton object state local to a particular thread of execution. This helped in keeping the state of singleton objects on different threads non-synchronized. Now, the version 0.8 allows freezing on singleton objects. With this, developers now have a shared immutable state. A file will be read once per process execution, and is available to any thread or worker. Once published, the object is frozen, and cannot be modified anymore.
Library improvements in Kotlin/Native
Kotlin/Native has added performance improvements to the existing libraries. The standard library (kotlin.*) is standardized with other platforms using expect/actual mechanism and mostly matches other Kotlin flavors.
The standard random number generator and collection shuffling functions are now available, eliminating the need of platform-specific APIs to obtain random numbers.
Other JetBrains-provided libraries, like kotlinx.coroutines, kotlinx.serialization, and Ktor HTTP client will get experimental Kotlin/Native support. Developers can now write an iOS app and Android application sharing the same REST API-related logic.
iOS support improvements
The version 0.8 fixes bugs that prevent publishing iOS apps to AppStore and solves framework initialization problems. It also adds support for 32-bit ARM iOS, so that older devices can be used with Kotlin/Native as well.