Kotlin
A concise multiplatform language developed by JetBrains
Celebrating Kotlin 2.0: Fast, Smart, and Multiplatform
Today we are excited to release Kotlin 2.0 with a stable K2 compiler, which is multiplatform from the ground up, understands your code better, and compiles it twice as fast.
Kotlin began as a JVM language and quickly gained popularity among developers due to its conciseness and safety. It has rapidly gained traction on the server-side with major companies like AWS, Adobe, Atlassian, and Google adopting it. Kotlin has also become the primary language for Android development, with 95% of the top 1,000 Android apps containing Kotlin code.
We pushed Kotlin’s boundaries even further by introducing Kotlin Multiplatform (KMP), allowing you to share code across server-side, web, desktop, iOS, and Android. The popularity of Kotlin Multiplatform has started to grow immensely and the technology has seen significant adoption among leading organizations, including Forbes, Philips, Square, and McDonald’s. Moreover, Google already uses KMP for developing its own Workspace apps and now officially recommends using KMP for sharing business logic.
Kotlin 2.0 is the next step in Kotlin’s evolution. Let’s take a closer look!
Multiplatform from the ground up
This release introduces the K2 compiler, unifying all platforms that Kotlin supports, as all compiler backends now share a lot of logic and a unified pipeline. This allows us to implement most features, optimizations, and bug fixes once for all platforms, drastically increasing the development speed of new language features. This new architecture also enables further improvements to compilation times for multiplatform projects.
With this new compiler in place, we can make improvements that extend beyond compilation. The team is already actively working on the next-gen format for KMP library distribution that will include some long-awaited features, such as developing and publishing KMP libraries from any host and universal Kotlin libraries. This will help further expand the KMP ecosystem by making multiplatform library development as straightforward as the development of JVM libraries.
Kotlin 2.0 also provides first-party support for Compose Multiplatform projects. The Jetpack Compose compiler, which powers Compose Multiplatform, has been merged into the Kotlin repository and will now ship with Kotlin.
These updates mean that now is the perfect time to start sharing code with Kotlin Multiplatform.
GET STARTED WITH KOTLIN MULTIPLATFORM
Faster compilation speed
Thanks to the new compiler frontend, Kotlin 2.0 improves compilation speed, potentially doubling it. While some projects might compile even faster and others a bit slower, overall, we’re seeing a significant boost in compilation times across real-world projects compared to previous Kotlin versions. Learn more about the Kotlin 2.0 performance improvements.
New K2 mode
The improvements don’t stop at compilation speed. IntelliJ IDEA’s K2 mode, which is currently in Alpha, is delivering promising results. We’re seeing around 1.8 times faster code highlighting and a 1.5 completion speed increase on the IntelliJ IDEA Ultimate codebase, and we’re committed to improving it even further. We expect K2 mode to be more stable and offer faster completion and highlighting in the future.
K2 mode will reach Beta status in the 2024.2 version of IntelliJ IDEA. We still have a few important IntelliJ IDEA features to deliver, and by the end of 2024, we plan to make K2 mode enabled by default. Try it out!
Smarter code analysis and more
The new compiler behaves more consistently and understands your code better, making smart casting even smarter. It has also resolved many long-standing issues, making your code more robust. Learn about all the new features introduced in Kotlin 2.0:
Migrate with confidence
We’ve ensured a smooth migration to Kotlin 2.0 by rigorously testing it with 40 JetBrains and community projects, covering 10 million lines of code. Over 18,000 developers and many companies have tested the K2 compiler in 80,000 server-side, Android, and multiplatform projects, providing valuable feedback. Thanks to these efforts, Kotlin 2.0 is our highest quality release yet, making your migration safe and reliable.
The future of Kotlin
Kotlin 2.0 paves the way for Kotlin’s future. With the new robust, fast, and multiplatform compiler, we can now focus on these major areas of language development:
- Data recognition and deconstruction with improvements for our powerful data flow framework and data classes.
- Increasing abstraction with features like context parameters and explicit backing fields.
- High-performance clear code with value classes and immutability.
- The library author experience, with improvements for opt-in mechanics and signature management.
Learn about these language development directions firsthand from Kotlin’s Lead Language Designer, Mikhail Zarechenskiy:
Kotlin 2.0 significantly boosts your daily productivity. It brings a faster, smarter, and more robust compiler, as well as even better support for Kotlin Multiplatform projects. As a Kotlin developer, you get more than just a modern, concise, and safe language. You also have access to a versatile ecosystem with powerful frameworks such as Ktor and Compose Multiplatform, and combined with JetBrains IDEs, Kotlin 2.0 offers an exceptional developer experience, empowering you to build innovative, performant, and reliable applications for all platforms. We are excited to see what you will build next. Have fun!
What else to read
- What’s new in Kotlin 2.0.0
- K2 compiler migration guide
- The Road to the K2 Compiler
- K2 Compiler Performance Benchmarks and How to Measure Them on Your Projects
- Android Support for Kotlin Multiplatform to Share Business Logic Across Mobile, Web, Server, and Desktop Platforms
- Jetpack Compose compiler moving to the Kotlin repository