What's the latest update in Kotlin

Programming language Kotlin 1.5: stability at every nook and cranny

JetBrains has released Kotlin 1.5. The first major release of the programming language in 2021 brings hardly any innovations, but stabilizes numerous language features introduced in Kotlin 1.4.x. The new JVM (Java Virtual Machine) backend is now also considered stable. For Kotlin / Native, the release includes compiler caches in debug mode for Linux and iOS, which are intended to accelerate the compilation of debug projects.

Stable record classes and sealed interfaces

Java has known records for storing immutable data since version 15, which are similar to the classes in Kotlin. Version 1.4.30 of JetBrain's programming language initially introduced annotation for classes as an experimental feature. The annotation ensures that the compiler generates the required record methods to access the poperties. The implementation is considered stable in Kotlin 1.5.

The same applies to sealed interfaces: Kotlin was already familiar with sealed classes before they were also introduced as a preview in Java 15. The labeling of interfaces as previously marked as preview is considered stable in Kotlin 1.5. Subclasses of sealed classes, whether or not they are also sealed, must be in the same package and compilation unit, but not necessarily in the same file.

Kotlin introduced the concept of inline classes in version 1.3 as alpha, and promoted it to beta in Kotlin 1.4.30. In the current release, they are also considered stable. Inline classes have nothing to do with the nested inner classes, but can be used as a wrapper for a value to enable compiler optimizations. Both primitive types and reference types such as are permitted as values.

Unsigned standard library

The standard library stabilizes the APIs for unsigned integer variants. Kotlin now knows the unsigned integer types (8 bit), (16 bit), (32 bit) and (64 bit). Associated array types exist for all four, but they are still marked as beta in version 1.5.

The Duration API has recently started using values ​​as an internal representation and offers properties for accessing this value. JetBrains has also redesigned the APIs for processing strings and characters. Among other things, there is now an API that takes the associated locale for the locale into account when converting between upper and lower case.

The test library only needs a single dependency for a common set of multi-platform projects. In addition, the library now automatically selects a testing framework for Kotlin / JVM sources. Finally, there are improvements for the standard and test library in conjunction with non-blocking I / O (NIO).

New backend for the Java Virtual Machine

In Kotlin 1.4, JetBrains introduced a new backend, and in version 1.4.30 the JVM backend was marked as beta. In the current release it is now considered stable and is activated by default. The new JVM IR backend (Intermediate Representation) presented in a separate blog post is primarily intended to accelerate the development of new language features, as there is a common intermediate level for all multi-platform goals: for the JVM, JavaScript and native applications.

The new JVM-IR compiler uses a common pipeline with the compilers for native projects via Kotlin / Native and JavaScript code with Kotlin / JS. According to the blog post on the release of Kotlin 1.5, a good 25,000 developers have already used the new JVM-IR compiler in IntelliJ IDEA in the beta phase. With the new backend, you can also define your own transformations and processing processes that work uniformly in multi-platform projects.

In October, JetBrains announced a new release cycle after a feature release with version 1 every six months.x appears. Incremental releases with version number 1.x.y0 (1.5.10, 1.5.20, ...) should appear every two to three months, and bug fix releases appear with version 1.x.y as requiredz (1.5.11, 1.5.12, ...).

Further details can be found on the Kotlin blog. IntelliJ IDEA should automatically suggest an update to Kotlin 1.5.0. The same applies to the IntelliJ IDEA-based Android Studio, but only from the fresh version 4.2.