I’m not a practitioner, I use Scala, primarily, and just use Kotlin on a bunch of personal projects.
The exciting part is that this is a compiler refactoring that should make it more bullet proof, and improve performance. Kotlin has had some rough edges, and I hope they’ll get fixed, post K2. The release notes already list many bug fixes, improvements to type inference, etc, which should improve development, despite K2 not actually introducing new features.
Also, it unlocks development of features which were postponed until after K2. For example, I hope to see “context receivers” stabilised, as they had unfixed bugs that made them unusable for me (the first time I tried them, I crashed the compiler). And if you take a look at the change logs, K2 does come with several bug fixes for these.
I prefer Scala 3 as a language, but Kotlin wins a lot by taking a more conservative, stability-oriented approach to its evolution — albeit, it could learn from Scala about having more theoretical foundations to build on, in order to avoid big refactorings or breakage in the future. K2 has no big changes or breakage, and all libraries compiled with 1.9.x are compatible with K2. This for me makes it superior to Scala in certain scenarios. For example, I want to build libraries usable from all JVM languages, and I’d rather not use Java — in this scenario, Scala sucks due to its historical policy for backwards compatibility, whereas Kotlin is fine, even if people complain about suddenly having to depend on its standard library (due to okhttp, et al); well, in fairness, Scala 3 has a much saner policy, but I can’t rely on it until everyone is on Scala 3.
K2 isn’t the only exciting thing happening, BTW. Others are the evolution of Kotlin Multiplatform (KMP), as it can now target WASM or iOS, and it’s stabilising. And also, Compose Multiplatform. Google announced that they are putting their weight behind it at Google I/O.
Anyway, Kotlin is a nice language, and I’m glad to see it improved at a reasonable pace — and I’m expecting exciting things to come, as after all, they can’t be too conservative, otherwise Java will eventually eat its lunch :-)
To me the most exciting part is that this is not a very exciting release. “2.0” was used to signify that this is a new compiler and there are backwards incompatible language changes, but the changes are relatively small and upgrading should be quick (though I will actually be testing that theory in the coming weeks).
highlights:
lambdas now use invokedynamic to generate lambda classes at runtime instead of bundling them into your jar as anonymous classes (this was opt in forever but is now on by default)
smart casting / flow-based typing got some upgrades and is smarter with tracking through variables and blocks casts. if you have some weird type casts then what the compiler is inferring your types to be may have changed.
multiplatform fixes with overloading & expect/actual resolution differing per platform.
We are consciously avoiding introducing any new features in Kotlin 2.0. The rewrite of the Kotlin compiler frontend is a considerable change and introduces a number of improvements just by itself. [..]
We’re carefully studying the impact of all the changes in behavior between the old and new K2 frontends and making additional efforts to replicate the old behavior whenever possible, even when we don’t like it, if it might affect a sizable number of Kotlin users.
We are committed to minimizing the impact of migrating your code from Kotlin 1.9 to Kotlin 2.0.
They say post-2.0 stabilization they will be focusing on some newer language features like context receivers.
Kotlin practitioners, what are the exciting parts?
I’m not a practitioner, I use Scala, primarily, and just use Kotlin on a bunch of personal projects.
The exciting part is that this is a compiler refactoring that should make it more bullet proof, and improve performance. Kotlin has had some rough edges, and I hope they’ll get fixed, post K2. The release notes already list many bug fixes, improvements to type inference, etc, which should improve development, despite K2 not actually introducing new features.
Also, it unlocks development of features which were postponed until after K2. For example, I hope to see “context receivers” stabilised, as they had unfixed bugs that made them unusable for me (the first time I tried them, I crashed the compiler). And if you take a look at the change logs, K2 does come with several bug fixes for these.
I prefer Scala 3 as a language, but Kotlin wins a lot by taking a more conservative, stability-oriented approach to its evolution — albeit, it could learn from Scala about having more theoretical foundations to build on, in order to avoid big refactorings or breakage in the future. K2 has no big changes or breakage, and all libraries compiled with 1.9.x are compatible with K2. This for me makes it superior to Scala in certain scenarios. For example, I want to build libraries usable from all JVM languages, and I’d rather not use Java — in this scenario, Scala sucks due to its historical policy for backwards compatibility, whereas Kotlin is fine, even if people complain about suddenly having to depend on its standard library (due to okhttp, et al); well, in fairness, Scala 3 has a much saner policy, but I can’t rely on it until everyone is on Scala 3.
K2 isn’t the only exciting thing happening, BTW. Others are the evolution of Kotlin Multiplatform (KMP), as it can now target WASM or iOS, and it’s stabilising. And also, Compose Multiplatform. Google announced that they are putting their weight behind it at Google I/O.
Anyway, Kotlin is a nice language, and I’m glad to see it improved at a reasonable pace — and I’m expecting exciting things to come, as after all, they can’t be too conservative, otherwise Java will eventually eat its lunch :-)
YMMV, etc.
To me the most exciting part is that this is not a very exciting release. “2.0” was used to signify that this is a new compiler and there are backwards incompatible language changes, but the changes are relatively small and upgrading should be quick (though I will actually be testing that theory in the coming weeks).
highlights:
invokedynamicto generate lambda classes at runtime instead of bundling them into your jar as anonymous classes (this was opt in forever but is now on by default)I greatly appreciate the Kotlin team for communicating how they were trying to break as little code as possible with this update.
They say post-2.0 stabilization they will be focusing on some newer language features like context receivers.