With the newly released Kotlin 2.0.0 language, JetBrains offers the K2 compiler for improved performance and the open source Kotlin dataset for large language (LLM) model creators.Kotlin 2.0.0 was announced on May 23. With this release, K2 reaches the stable state, having been completely rewritten based on a new architecture. The rewritten compiler boosts performance and daily productivity, JetBrains said. Compilation time is as much as two times faster with Kotlin 2.0.0 versus Kotlin 1.9.20. The new K2 compiler is more consistent with an improved ability to understand code, according to JetBrains.With the 2.0.0 release, JetBrains also announces an open source Kotlin dataset, which together with the 7B Kotlin Language model helps builders of LLMs and AI-based code generation tools improve the quality of Kotlin code generated. The model and dataset now are available for researchers and others to experiment with and use in their work. Kotlin 2.0.0 also features the ability to monitor GC performance in Kotlin/Native with signposts on Apple platforms. Kotliin/Native compiles Kotlin code in native binaries that can run without a virtual machine. Additionally, Kotlin 2.0.0 introduces a default method for generating lambda functions via invokedynamic. The change reduces the binary size of applications compared to the traditional anonymous class generation.Kotlin plugins that support Kotlin 2.0.0 are bundled in the latest JetBrains IntelliJ IDEA and Google Android Studio IDEs. Kotlin itself is perhaps best known for its use in Google Android mobile application development. Other features in Kotlin 2.0.0 include:
A new JetPack Compose compiler plugin for the Gradle build tool has been merged into the Kotlin repository, to help projects transition to Kotlin 2.0.0.
The kotlinx-metadata-jvm library, providing an API to modify metadata of binary files generated by the Kotlin/JVM compiler, is now stable.
With support for named exports in Kotlin/Wasm, developers can import each Kotlin declaration marked with @JsExport by name. Named exports make it easier to share code between Kotlin and JavaScript modules. Also, developers can use unsigned primitive types inside external declarations and functions with the @JsExport annotation that makes Kotlin/Wasm functions available in JavaScript code.
The Kotlin/Wasm toolchain now applies the Binaryen tool during production compilation to all projects, as opposed to the previous manual-setup approach. This should improve runtime performance and the size of project binaries.
The common AutoCloseable interface is now stable, allowing developers to easily close resources. It also comes with functions such as the AutoCloseable() constructor function.
Along with its Kotlin 2.0.0 unveiling, JetBrains said it had improved the tools experience for Kotlin Multiplatform, for developing cross-platform projects, by offering a single all-in-one tool for Kotlin multiplatform development. A preview of the development environment is available. It understands Apple’s Xcode and supports the Swift language.
Copyright © 2024 IDG Communications, Inc.
Source link