Memory Manager for Kotlin/Native Lifts Restrictions on Object Sharing Between Threads and Offers Leak-Free, Concurrent Programming Primitives
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:
- Reworked LLVM Dependency: For Kotlin/Native, the LLVM dependency has been updated, bringing the LLVM version to 11.1.0 along with decreased dependency size and other benefits.
- Stable Sealed When Statements: Sealed
when
statements now produce a compiler warning if awhen
statement is not exhaustive, making code safer without the need for developers to introduce their own functions. This feature, now stable after being previewed in Kotlin 1.5.30, enhances code safety. - Suspend Functional Types: Support has been stabilized for implementing suspend functional types as super interfaces. This addition addresses a missing aspect of Kotlin coroutines design, allowing automatic conversion from regular to suspending functional types.
- Improved Type Inference: The compiler’s type inference for generic types has been enhanced for better accuracy.
- Stabilized
typeof
: Thetypeof
operator, previously experimental on the JVM, is now stabilized and usable across all Kotlin platforms. - Stable Duration API: The Duration API has been stabilized for consistent time interval handling.
- Standard Library Updates: Several standard library functions, including collection builders, bit rotation operators on integers, and the regex function for splitting strings, have been promoted to stable.
- Enhanced Standard Input Functions: New functions for reading from the console have been introduced.
- Kover Gradle Plug-in: Now in an experimental stage, the Kover Gradle plug-in measures coverage for Kotlin code built with the JVM compiler.
- Repeatable Annotations: For Kotlin/JVM, repeatable annotations are now compatible with Java;
@kotlin.annotation.Repeatable
accepts any retention and is repeatable in both Kotlin and Java. - Kotlin/JS Enhancements: Developers working 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.
Kotlin 1.6.0 represents a significant step forward, integrating a host of new features and improvements designed to enhance the developer experience and streamline the development process.