Kotlin 1.9: K2 Compiler Enters Beta Phase

Kotlin 1.9 programming language sends K2 compiler into beta phase

JetBrains has released version 1.9 of its Kotlin programming language, bringing several updates and improvements. One of the notable changes is the stabilization of existing functions like the property entries. Additionally, Kotlin 1.9 introduces the experimental class HexFormat, which allows for conversion between numeric values and hexadecimal strings.

Another significant update is the beta release of the K2 compiler. This compiler has been in development since 2021 and aims to accelerate the development of new language features, improve performance, and provide an API for compiler extensions. The K2 compiler also offers basic support for Kotlin/Native and Multiplatform projects.

To try out the new K2 compiler, developers can use the Gradle property kotlin.experimental.tryK2=true or run the command “./gradlew assemble -Pkotlin.experimental.tryK2=true”. However, it’s worth noting that there are some limitations when using Gradle versions lower than 8.3, such as compiling source code from buildSrc or creating Gradle plugin dependencies. The development team recommends setting the language version for buildSrc, Gradle plugins, and their dependencies and updating to Gradle 8.3 when it becomes available.

In terms of language features, Kotlin 1.9 introduces the HexFormat class as an experimental feature. This class and its associated extension functions allow for converting between numeric values and hexadecimal strings. Users can configure formatting options using the HexFormat Builder, such as displaying hexadecimal characters in lowercase or uppercase.

Another stabilized feature in Kotlin 1.9 is the entry property, which was introduced in Kotlin 1.8.20. This property serves as a more modern and performant replacement for the values() function.

Furthermore, Kotlin 1.9 reportedly brings improvements to WebAssembly projects, making them significantly smaller compared to the previous version. Additionally, there is a preview of a user-defined memory allocator, which aims to enhance the runtime performance of the Kotlin/native memory manager.

For more information about all the changes and updates in Kotlin 1.9, developers can refer to the official announcement.

Leave a Reply