Turn and face the strange: Kotlin 1.5.0-RC showcases ch-ch-changes

Turn and face the strange: Kotlin 1.5.0-RC showcases ch-ch-changes

JetBrains has made available Kotlin 1.5.0-RC, a release candidate for the next version of its open source programming language designed for compatibility with the Java ecosystem.

Kotlin 1.5.0-RC includes all the features planned for version 1.5.0, according to the JetBrains Kotlin blog. This includes new language features, stdlib updates, plus an improved testing library. The Kotlin team said the only changes between this and the release would be fixes, so developers can be sure of feature stability at this point.

One of the main changes highlighted by JetBrains is that unsigned integer types and operations are now classified as stable. They had previously been a beta feature since Kotlin 1.3, but promotion to stable means it is now safe for developers to use them in production projects. The new stable APIs are unsigned integer types, ranges and progressions of unsigned integer types, and functions that operate with unsigned integer types. However, arrays of unsigned integers are currently still in beta, along with unsigned integer varargs.

Another change is that Kotlin now includes a way to use modern non-blocking Java IO in a Kotlin-idiomatic style via the extension functions for java.nio.file.Path. This capability was added as an experimental feature in Kotlin 1.4.20, but is now available without needing an opt-in, while the existing extensions for File API remain available.

There are also updates to the Kotlin test library, adding new features for developers to trial such as a single kotlin-test dependency in multiplatform projects. Once this is specified, the Gradle plugin will infer the corresponding platform dependency for other source sets, according to JetBrains, and the JVM source sets will automatically receive the dependency, allowing developers to write and run tests right away. There are also a number of new assertion functions along with improvements to existing ones.

Other tweaks in Kotlin 1.5.0-RC include a locale-agnostic API for handling changes between uppercase and lowercase text. The experimental duration and time measurement API has had significant changes in both the API and internal representation, such as using a Long value for the internal representation instead of Double.

There are also changes to maths operations, with a floored division for rounding down results, plus a function that returns the modulus that is the remainder of the floored division. There are also new collection functions, firstNotNullOf() and firstNotNullOfOrNull(), the first of which returns the first non-null result of a selector function, plus its counterpart that produces null if there is no value to return.

JetBrians said that binaries created with Kotlin 1.5.0-RC are guaranteed to be compatible with Kotlin 1.5.0, unlike with previous milestone releases. However, it warned that some deprecation cycles of previously announced changes are coming to an end in this release, and developers are advised to check the Compatibility Guide for Kotlin 1.5.0.