Kotlin 1.6.0, the latest release of JetBrains’ trendy language for JVM, web, and mobile development, has been released with a new memory manager for native development, still in an experimental phase.
The memory manager for Kotlin/Native, which compiles code to native binaries, brings the language closer to providing a consistent development experience. The memory manager lifts existing restrictions on object sharing between threads and offers leak-free, concurrent programming primitives that are safe and do not require special management or annotations.
The memory manager headlines a long list of capabilities in Kotlin 1.6.0, which was described as primarily a stabilization release and published on November 16. Features previously billed as experimental in Kotlin now are available by default in Kotlin 1.6.0. Installation instructions for the release can be found at blog.jetbrains.com. Users of the JetBrains IntelliJ Idea or Android Studio IDEs can update automatically.
Other features in Kotlin 1.6.0 include:
- For Kotlin/Native, the LLVM dependency has been reworked, bringing the LLVM version to 11.1.0 along with decreased dependency size and other benefits.
- Sealed
when
statements produce a compiler warning if a when statement is not exhaustive. This feature, now in a stable state after being previewed in Kotlin 1.5.30, makes code safer without the need for developers to introduce their own functions. - Support is stabilized for implementing
suspend
functional types as super interfaces. This had been missing from the Kotlin coroutines design. Also, the conversion from regular to suspending functional types is stabilized. Developers now can pass any expression of a suitable regular functional type where suspending is expected as a parameter. The compiler will automatically perform the conversion. This feature fixes an inconsistency between regular and suspending functions in Kotlin. - The compiler’s type inference for generic types has been improved.
typeof
has been stabilized and can be used on any Kotlin platform. It had been available on the JVM in an experimental fashion.- The Duration API has been stabilized.
- For the standard library, the following stdlib functions have been promoted to stable: collection builders, bit rotation operators on integers, and the regex function for splitting a string into a sequence.
- For standard input, new functions are provided for reading from the console.
- The Kover Gradle plug-in, now in an experimental stage, measures coverage for Kotlin code built with the JVM compiler.
- For Kotlin/JVM, the repeatable annotations capability is compatible with Java;
@kotlin.annotation.Repeatable
now accepts any retention and makes the annotation repeatable in both Kotlin and Java. - For Kotlin/JS, developers building on a server without internet connectivity can disable downloading of Node.js and Yarn for Kotlin/JS projects and use instances already in place on the host.