Kotlin 1.9.0 features beta of advanced K2 compiler

Release also stabilizes language features including replacing the enum class values function.

Java / coffee
Robert Shunev (CC0)

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 stabilizes a number of language features including:

  • Replacing the enum class values function. Kotlin 1.8.20 introduced the entries property for enum classes as an experimental feature.
  • Stabilizing 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.
  • Size and performance optimizations are featured for the Kotlin/Wasm (WebAssembly) target. Kotlin/Wasm no longer supports Dynamic types. This has been deprecated in favor of a universal JSAny type for better JavaScript 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.

Copyright © 2023 IDG Communications, Inc.

InfoWorld Technology of the Year Awards 2023. Now open for entries!