Kotlin 2 Released With Multiplatform K2 Compiler
Written by Mike James   
Monday, 27 May 2024

Kotlin 2.0 has been released. The new version is a major update with improvements including a stable K2 compiler, which is multiplatform from the ground up, and according to JetBrains understands your code better, and compiles it twice as fast.

Kotlin is the open source language originated by JetBrains and promoted by Google as a first class language for Android to replace or supplement Java.

kotlinlogoThe main highlight of this release, which was announced at KotlinConf 2024, is the stable version of the new K2 compiler that has been completely rewritten based on a new architecture that significantly improves performance according to the developers, who say the compilation time can be twice as fast with Kotlin 2.0 compared to Kotlin 1.9.20. They say the new compiler also behaves more consistently and understands your code better. For example, In Kotlin 2.0.0, the K2 compiler treats inline functions differently, allowing it to determine in combination with other compiler analyses whether it's safe to smart-cast. Another improvement is to exception handling so that smart cast information can be passed on to catch and finally blocks. This change makes your code safer as the compiler keeps track of whether your object has a nullable type.

Alongside Kotlin 2, JetBrains has also announced an open-source Kotlin dataset, together with the 7B Kotlin Language model, to help creators of Large Language Models (LLMs) and AI-based code generation tools improve the quality of the Kotlin code they generate. The dataset and the model are now available for researchers and enthusiasts to experiment with and use in their work. JetBrains will keep it up-to-date by regularly adding new permissive open-source code.

This release also includes Kotlin Multiplatform, which can be used to create Android, iOS, desktop, and server-side applications from a single codebase. With Kotlin Multiplatform, developers can choose to share up to 100% of the code or build a unique native UI for each platform. Google has added Kotlin Multiplatform support to some of its popular libraries for Android developers and has also migrated its own apps, like Google Docs, to Kotlin Multiplatform and recommends using KMP for sharing business logic between platforms.

JetBrains is also offering a single all-in-one tool for Kotlin Multiplatform Development built on the Fleet platform. A development environment preview is available that fully understands Xcode projects and has full support for Swift, including experimental Swift export functionality to get pure Swift APIs for shared Kotlin code. This means developers writing platform-specific code for iOS get full support from the code editor, including inspections, navigation, and refactoring that even work across languages.

Other improvements include an experimental Power-assert compiler plugin that improves the experience of writing tests by including contextual information in failure messages; and a new Gradle DSL for compiler options in multiplatform projects.

Kotlin 2 is available now.

kotlinlogo

More Information

Kotlin Home Page

What's New In Kotlin 2

Related Articles

How High Can Kotlin Go?

KSP2 Adds Kotlin K2 Support

Kotlin 1.9 Adds K2 Compiler

Kotlin 1.8 Beta Adds New JVM Functions

Kotlin 1.7 Unveils New Compiler

Kotlin 1.5 - Mature But Still Growing

Why Do Android Devs Convert To Kotlin?

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


WWII Cipher Machine As Used On D-Day
09/06/2024

To celebrate the 80th anniversary of D-Day there's a new addition to the line up of cryptographic machines on Martin Gillow's VirtualColossus website - a 3D simulation of the Hagelin M-209 cipher [ ... ]



JetBrains Integrates Gemini Into AI Assistant
18/06/2024

JetBrains has integrated Google DeepMind's Gemini language model into its AI-powered coding tool, AI Assistant. AI Assistant will now use the combined power of Gemini and several of JetBrains' proprie [ ... ]


More News

C book

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Monday, 27 May 2024 )