Experimental Features, Fixes, and Improvements in Latest Kotlin Release
The latest point release of Kotlin, the statically typed dev darling, delivers the expected fixes and performance improvements for existing features, but Kotlin 1.4.20 also comes with new experimental features and a call from the Kotlin team for feedback on those potential enhancements.
“Being open to community feedback is one of the Kotlin team’s basic principles, and we need your thoughts about the prototypes of the new features,” Kotlin team member Pavel Semyonov said in a blog post. Give them a try and share your feedback on Slack (get an invite here) or YouTrack.”
“Experimental” is an official stage in the development of a Kotlin feature. It precedes “alpha” and “beta,” and specifically means “try it only in toy projects.” The “Stability of Kotlin Components” website puts it this way: “We are just trying out an idea and want some users to play with it and give feedback. If it doesn’t work out, we may drop it any minute.”
The list of experimental features in this release includes:
- invokedynamic string concatenation. Kotlin 1.4.20 can compile string concatenations into dynamic invocations on JVM 9+ targets, which improves performance.
- Selective Yarn dependency resolutions. Kotlin 1.4.20 provides a way of configuring Yarn’s selective dependency resolutions through the YarnRootExtension inside the YarnPlugin in Gradle.
- The ability to dissolve granular workspaces. Also available through the YarnRootExtension inside the YarnPlugin in Gradle.
- Ignoring compilation errors with IR compiler. The IR compiler for Kotlin/JS comes with a new experimental mode in which developers can run their code even if it contains errors, so they can do things like try things before the whole application is ready.
- New escape analysis mechanism. This new capability in Kotlin/Native is meant to improve the runtime performance by allocating certain objects on the stack instead of the heap.
- Opt-in wrapping of Objective-C exceptions. This experimental feature allows Kotlin/Native to handle exceptions thrown from Objective-C code in runtime to avoid program crashes.
- Extensions for java.nio.file.Path. Experimental extensions for java.nio.file.Path in the standard library. “Working with the modern JVM file API in an idiomatic Kotlin way is now similar to working wih java.io.File extensions from the kotlin.io package,” Semyonov explained in his post.
This release of Kotlin also marks the beginning of the deprecation of Kotlin Android Extensions. Ever since JetBrains created the Extensions, they have played a huge role in the growth of Kotlin’s popularity in the Android ecosystem, Semyonov said in his post, by providing developers with convenient and efficient tools for reducing boilerplate code.
“Initially, we thought about adding more components to kotlin-android-extensions,” he said. “But this didn’t happen, and we’ve even received user requests to split the plugin into independent parts.
“On the other hand, the Android ecosystem is always evolving, and developers are getting new tools that make their work easier. Some gaps the Kotlin Android Extensions were filling have now been covered by native mechanisms from Google…. Given these two factors, we’ve decided to retire synthetics in favor of view binding and move the Parcelable implementation generator to a separate plugin.”
In 1.4.20, the Kotlin team has extracted the Parcelable implementations generator from kotlin-android-extensions and started the deprecation cycle for the rest of it. They will continue to work “for now,” with a deprecation warning, he said. “In the future, you’ll need to switch your project to another solution.”
Semyonov points to this website for the guidelines for migrating Android projects from synthetics to view bindings. The Parcelable implementation generator is now available in the new kotlin-parcelize plugin. “Apply this plugin instead of kotlin-android-extensions,” he advised. “The @Parcelize annotation is moved to the kotlinx.parcelize package. Note that kotlin-parcelize and kotlin-android-extensions can’t be applied together in one module.”
Since Google announced that it would become a first-class language and began pushing developers to use it for Android development, Kotlin usage has grown, but it has yet to edge Java from the top spot among Android developers
JetBrains, the Prague-based maker of the venerable code-centric Java IDE, IntelliJ IDEA, created Kotlin, unveiled it at the 2011 JVM Language Summit in Santa Clara, CA, and later released it for distribution under the Apache 2 Open Source License.
JetBrains officially announced a new release cadence for Kotlin and the IntelliJ Kotlin plugin in October. According to JetBrains’ Kotlin community manager Alina Dolgikh, users can expect new releases of Kotlin 1.x every six months. These releases will be date-driven, not feature-driven, Dolgikh said in a blog post, which brings the language into what has emerged as something of a standard release cycle for software development tools over the past few years.
John K. Waters is the editor in chief of a number of Converge360.com sites, with a focus on high-end development, AI and future tech. He’s been writing about cutting-edge technologies and culture of Silicon Valley for more than two decades, and he’s written more than a dozen books. He also co-scripted the documentary film Silicon Valley: A 100 Year Renaissance, which aired on PBS. He can be reached at [email protected].