1.4.30 Is Released With a New JVM Backend and Language and Multiplatform Features
Kotlin 1.4.30 is now available. This is the last 1.4 incremental release, so we have lots of new experimental features that we plan to make stable in 1.5.0. We would really appreciate it if you would try them and share your feedback with us. We hope you enjoy testing out all these new updates, and please let us know what you think.
What’s changed in this release:
- Language features and compiler
- Build tools
- Standard library
Language features and compiler
We’ve decided to cover two of the significant updates in separate blog posts so that we can provide more details on these features.
The new JVM backend reached Beta, and it now produces stable binaries. This means you can safely use it in your projects.
More details about the update, ways to enable the new JVM IR backend, and how you can help stabilize it can be found here.
New language features preview
Among the new language features we plan to release in Kotlin 1.5.0 are inline value classes, JVM records, and sealed interfaces. You can read more details about them in this post, and here’s a brief overview:
Inline classes. Inline classes were previously a separate language feature, but now they have become a specific JVM optimization for a value class with one parameter. Value classes represent a more general concept and will support different optimizations in the future. They currently support inline classes, and they will support Valhalla primitive classes when project Valhalla becomes available.
Java records. Another upcoming improvement in the JVM ecosystem is Java records. They are analogous to Kotlin
data classes, mainly used as simple holders of data. Interoperability with Java always has been and always will be a priority for Kotlin. Kotlin code “understands” the new Java records and sees them as classes with Kotlin properties.
Sealed interfaces. Interfaces can be declared sealed as well as classes. The sealed modifier works on interfaces the same way: all implementations of a sealed interface are known at compile time. Once a module with a sealed interface is compiled, no new implementations can appear.
So now we kindly ask you to give these language features a try and share your feedback with us. We would like to know what expectations you have for them, the use cases where you want to apply these features, and any thoughts or ideas you have about them.
You can find a detailed description of the new language features and instructions on how to try them out in this blog post.
Configuration cache support in Kotlin Gradle Plugin
As of Kotlin 1.4.30, the Kotlin Gradle plugin is compatible with the Gradle configuration cache. This speeds up the build process. For example, Square, which uses Kotlin for Android, has a build (Android, Java, Kotlin) of 1800 modules. Its team reports the following numbers:
- The very first build took 16 minutes 30 seconds.
- The second one was much shorter; it took 5 minutes 45 seconds.
More specifically, for Square, Configuration Cache saves 1 minute 10 seconds of configuration and task graph creation per build.
When you run the command, Gradle executes the configuration phase and calculates the task graph. Gradle caches the result and reuses it for subsequent builds, saving you time.
Please note that this feature is still in Alpha for multiplatform.
Compilation time improvements
We’ve improved compilation time in 1.4.30. The time taken to rebuild the KMM Networking and data storage sample framework has been reduced from 9.5 seconds (in 1.4.10) to 4.5 seconds (in 1.4.30).
We plan to continue optimizing the compiler, you can follow the issue in YouTrack.
64-bit watchOS simulator support
With the 1.3.60 Kotlin release in October 2018, we introduced support for building Kotlin apps for Apple Watch simulators. Last November the Apple Watch simulator architecture was changed from i386 to x86_64, creating issues for developers working on this feature. The new Kotlin/Native
watchosX64 target can be used to run the watchOS simulator on 64-bit architecture and it works on WatchOS starting from version 7.0.
Xcode 12.2 SDK support
Kotlin/Native now supports Xcode 12.2. The macOS frameworks that have been added to the Xcode 12.2 release can be used with this Kotlin update. For example, the MLCompute framework is now available for users developing applications for macOS.
Prototype lazy initialization for top-level properties
Locale-agnostic API for upper/lowercasing text
This release introduces an experimental locale-agnostic API for changing the case of strings and characters. The current
decapitalize() API functions are locale-sensitive, which is not obvious and inconvenient in some cases. In the case of different platform locale settings it affects the code behavior – for example, in the Turkish locale, when the string “kotlin” is converted by
toUpperCase it results in "KOTLİN", not "KOTLIN". Now it uses the root locale, so it will work as expected.
Unambiguous API for Char conversion
The current conversion functions from Char to numbers, that return its UTF-16 code expressed in different numeric types, are often confused with the similar String-to-Int conversion returning the numeric value of a string.
To avoid this confusion we’ve decided to separate Char conversions into two following sets of clearly named functions: functions to get the integer code of
Char and to construct
Char, and functions to convert
Char to the numeric value of the digit it represents.
Find more about all the updates for 1.4.30 in What’s new and New JVM Backend and Language Features blog posts.
How to update
IntelliJ IDEA will suggest updating the Kotlin plugin to 1.4.30 automatically, or you can update it manually by following these instructions. The Kotlin plugin for Android Studio Arctic Fox will be released later.
If you want to work on existing projects created with previous versions of Kotlin, use the 1.4.30 Kotlin version in your project configuration. For more information, see the docs for Gradle and Maven.
You can download the command-line compiler from the Github release page.
The release details and the list of compatible libraries are available here.
Before updating your projects to the latest version of Kotlin, you can try the new language and standard library features online at play.kotl.in.
We want to thank all of our external contributors whose pull requests were included in this release: