Kotlin 1.9.0, the latest version of JetBrains’ statically typed language that has become critical in Android mobile development, features a beta of the performance-boosting K2 compiler for the JVM.
Also with the Kotlin 1.9.0 release, unveiled July 5, basic support is offered in K2 for Kotlin/Native and multiplatform projects. K2 has been geared to boost performance, unify all platforms Kotlin supports, speed up development of new language features, and provide an API for compiler extensions. K2 is due to become the default stable compiler in Kotlin 2.0.
Beginning with Kotlin 1.9.0, developers can test the K2 compiler with the
kotlin.experimental.tryK2=true Gradle property. In Kotlin 1.9.0, Gradle build system reports now show whether K2 or the current compiler was used to compile code. The Gradle configuration cache, which speeds up the build process, is supported in multiplatform libraries.
Kotlin 1.9.0 also stabilises a number of language features including:
- Replacing the enum class values function. Kotlin 1.8.20 introduced the
entriesproperty for enum classes as an experimental feature.
- Stabilising the data object declarations introduced in Kotlin 1.8.20.
- Adding support for secondary constructors with bodies in inline value classes.
Kotlin 1.9.0 follows Kotln 1.8.0, which introduced support for Java 19 and experimental functions for copying or deleting directory content on the JVM. Instructions on getting started with Kotlin can be found on the project website.
Other new features and improvements in Kotlin 1.9.0:
- A custom memory allocator is being previewed, to improve the performance of the Kotlin/Native memory manager.
Dynamictypes. This has been deprecated in favor of a universal
JSAnytype, for better interoperability.
- The standard library API for working with open-ended ranges now is stable.
- A common function is offered to get a regular expression capture group by name.
- The Android source set layout is the default. This replaced the previous naming schema for directories.
- A new extension function
createParentDirectories()is featured to create a new file name with all the necessary parent directories.