Kotlin 1.9.0, the latest version of JetBrains Static Typed Language which has become critical in Android mobile development, offers a beta version of the K2 compiler which improves performance for the JVM.
Also with Kotlin version 1.9.0, unveiled July 5, basic support is offered in K2 for Kotlin/native and cross-platform projects. K2 was designed to improve performance, unify all Kotlin-supported platforms, speed up the development of new language features, and provide an API for compiler extensions. K2 should become the default stable compiler in Kotlin 2.0.
Starting 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. Gradle configuration cache, which speeds up the build process, is supported in cross-platform libraries.
Kotlin 1.9.0 also stabilizes a number of language features, including:
- Replacement of enum class values function. Kotlin 1.8.20 introduced the
entriesproperty for enum classes as an experimental feature.
- Stabilization of data object declarations introduced in Kotlin 1.8.20.
- Added support for secondary constructors with bodies in inline value classes.
Kotlin 1.9.0 follows Kotln 1.8.0which introduced support for Java 19 and experimental functions to copy or delete directory contents on the JVM. Instructions for getting started with Kotlin are available at 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.
- Size and performance optimizations are shown for the Kotlin/Wasm (WebAssembly) target. Kotlin/Wasm no longer supports
Dynamictypes. This was deprecated in favor of a universal
- The standard library API for working with open ranges is now stable.
- A common function is provided to get a regular expression capturing group by name.
- The layout of the Android source assembly is the default layout. This replaced the previous naming scheme for directories.
- A new extension function
createParentDirectories()is presented to create a new filename with all necessary parent directories.
Copyright © 2023 IDG Communications, Inc.