Kotlin 2.0 & opinionated Wrap-up of KotlinConf 2024 – JVM Weekly vol. 84
I've come to enjoy writing from airports, and while waiting in Copenhagen to return to Poland, I have a hot-off-the-press report from KotlinConf for you
Today's JVM Weekly arrives a bit late, as I decided to attend KotlinConf this year to meet people and hear the latest buzz from the language's backstage. Conferences are great for this, as they offer a better glimpse into the latest gossip and the "atmosphere of the room". Since I'm here, it was difficult for me to create a standard edition - so I decided to deliver a "hot off the press" report to let you feel the atmosphere of this event through a small window.
Before going to conference, I need to start with the release of Kotlin 2.0, which represents a significant update, featuring the stabilization of the new K2 compiler, which is now the default for all supported platforms, including JVM, JavaScript, Native, and WebAssembly. This update brings substantial performance enhancements and a unified framework that simplifies the development of multiplatform projects. K2 is now fully integrated with the latest versions of IntelliJ IDEA and Android Studio, making it easier for developers to use Kotlin 2.0 without needing additional plugin updates.
In addition to the compiler enhancement, Kotlin 2.0.0 introduces several new features. The kotlinx-metadata-jvm
library has reached a stable status, enhancing how metadata is handled across JVM applications. The update also refines smart casting capabilities, which are now more robust across various coding scenarios including handling null values and more complex type inference situations. Moreover, the introduction of invokedynamic
for lambda generation optimizes bytecode and aligns Kotlin more closely with modern JVM optimizations. The update also stabilizes key APIs such as the enum class values replacement function and the AutoCloseable
interface, extending their availability across common codebases.
Kotlin's multiplatform capabilities have also been significantly enhanced in this release. A new Gradle DSL has been introduced for more intuitive configuration of compiler options across projects. For developers targeting JavaScript and WebAssembly, Kotlin 2.0.0 improves the compilation process, supports modern JavaScript features, and enhances interoperability with JavaScript code.
All the new feature can be found here.
So, this is how we summarized Kotlin 2.0. Now it's time to move on to the conference itself.
Let's start with the Keynote, which was quite unique. Although the release of Kotlin 2.0 kicked off the event, the focus was definitely on Kotlin Multiplatform, which is clearly now the favored child of JetBrains and the future of the Kotlin project.
This was further underscored by my visit to KotlinConf. I'm not saying that Kotlin on the server wasn't highlighted at the conference, but it was mainly in the presentations and voices of partners, not JetBrains itself.
The Kotlin team seems to focus on what they are really good at - mobile - and this was the most discussed topic. Since mobile development is currently outside my sphere of interest, I felt a bit disappointed.
Additionally, there were a few announcements, with the most significant being Uber joining the Kotlin Foundation. I didn't expect the company to be so involved in the ecosystem, especially since its competition, Bolt, was more visible at the conference. I missed big news that we didn't know before the conference - like Kotlin Notebooks. Really, the Keynote scenario was somewhat predictable, yet I like to be surprised at such events. I could include the announcements about the development of the Amber project, but those were made before the conference so I'll leave them for next week.
From my perspective, what I'll remember most about the Keynote is the chance to peek into the internals of AI Assistant. This allows one to realize that JetBrains has many ideas up its sleeve - for example, models specifically fine-tuned for Kotlin.
Something definitely worth watching was Kotlin Language Features in 2.0 and Beyond - essentially a must-see, which helps better understand the changes both in the compiler and the language itself. Finally, we officially have K2 and Kotlin 2.0, so the "early majority" can now start playing with it with a clear conscience.
Kotlin 2.0 introduces several performance optimizations and features improving correctness, particularly no new syntax features, but rather improvements under the hood. A major enhancement is the Front End Intermediate Representation, which simplifies complex language constructs to more basic forms, allowing for more consistent and analytical compiler operation.
As Zareckij explains, the updates extend beyond compiler improvements, including better management of smart casts. Kotlin 2.0 expands the conditions under which smart casts operate, facilitating more intelligent and extensive use of this feature. The ability to handle smart casts after internal functions and logical operations should enable Kotlin to adopt even more dynamic and flexible coding practices.
A significant expected feature is name-based destructuring. These functions offer programmers greater flexibility in error handling and data destructuring, steering clear of the traditional pitfalls associated with order-based destruction in destructuring operations.
Looking forward, Kotlin plans to incorporate more advanced type management and error handling strategies, including the implementation of union types to handle multiple kinds of exceptions.
Overall, this presentation is now available - I invite you to watch:
Of course, it's 2024, so there had to be sessions about LLMs... and I don't know if this wasn't my favourite session on LLMs ever.
Why do we even create programming languages? Because natural ones are insufficient for expressing ideas and instructions precisely. Erik Meijer in Virtual Machinations: Leveraging the Linguistic Bytecode of Large Language Models to Emulate Program discussed how large language models can act as virtual machines, allowing many techniques from programming languages to be transferred to the LLM domain. There were lots of interesting concepts, such as comparing RAG to Virtual Memory, embeddings to hashcodes, hallucinations to typing errors, and LLMs in general to branch prediction in CPUs. And yes, there was some Kotlin, but it definitely wasn't the main dish. In my opinion, this session is a must-see.
Among the very interesting sessions was also one about Flow by Grow with the Flow: How Kotlin Flow Became a Game-Changer for our Business. Coroutines have lost some of their luster in recent years, and it might be hard for them to regain it in the times when everyone has shifted their attention to Virtual Threads (though these two solutions are not equivalent). Therefore, it was nice to see how Peter Urs reminded us how useful the abstraction remains, taking on Flow - Kotlin's implementation of Reactive Streams, which can successfully be used for asynchronous communication between services without any additional components.
I hadn't seen any talk that spoke positively about Reactive concepts like Hot & Cold Flows in a long time, and it was definitely refreshing. And generally, I like that we're slowly coming full circle, from a world where queues became the default method of communication between services, back to a simpler plan of existence, where no messaging middleware is needed - of course, when it's possible (and often, it is).
Finally, there are speakers I could watch over and over, and one of them is Dan North. That's why I really enjoyed watching his The Best Programmer I Know, being the Keynote on the second day. Although if you've seen Dan's earlier presentations, many topics may be repetitive and you might not have many surprises, I still think this type of appearance is the best kind of Keynote. When the recordings appear - I highly recommend it.
As for the exhibitors, KotlinConf is a very unusual conference in this respect. There are few companies, but they are very cool brands, and definitely, every booth is a place where it's worth having a chat. Don't expect recruitment, but if you have a project worth talking about, it's the ideal place. We had several really interesting conversations about kotlin-pulumi.
And definitely, what I will remember the conference for is its Afterparty between. I believe Karaoke should become a standard at these types of events; the audience (including me!) had a great time. I regret that there were so many applications that I wasn't able to perform a solo, but I had to settle for a group session. And still, I had a fantastic time. If any conference organizer is reading this - I'll emphasize it again, Karaoke is a great idea.
Unfortunately, I couldn't stay until the end, but I had a plane at 6:30 PM (wife waiting with daughter), so I had to leave - but fortunately, the conference was streamed the whole time, so each of you could catch up with the sessions.
And I feel a bit sorry because the Q&A session was probably the most interesting (and hilarious) part of the whole conference:
KotlinJS will be supported, but KotlinWASM seems to be the priority for web support.
A question was raised about testing code changes in future versions of the language, which is very interesting in itself, and the developers admitted that with K2 they have much better tooling for this purpose. Additionally, they mentioned EAP Champions, where companies can report bugs at an early stage.
An interesting question also concerned KMP (Kotlin Multiplatform) in the context of whether every library should be Multiplatform. The answer is that there are use cases, such as IO, where different platforms work completely differently, and it doesn't make much sense.
Should we expect a Language Server? On the Kotlin-team side, they will provide the Kotlin Analytics API, but Language Server should not be expected.
New Debugger functions - soon
So in summary... it was nice conference. Thank you JetBrains for organising.
And one final thought, because another thing struck me - how many presentations conveyed the message: "do more with less people". And not in the sense of more efficient machines, but fewer people. That was the pitch for Compose, that was the pitch for Flow, that was the pitch for server Kotlin. It seems that the time of bloated projects is somewhat over, and small, efficient teams are valued. It reminded me of the story of Meta and their Threads, which swept through the industry last year.
Even in the Q&A, when the question was asked about how Kotlin Compose will cope with React's competition, given that React developers are cheaper, the answer was "we need to force Kotlin developers to ask for less money" - despite the general funniness, I don't know how to comment on that 💸
PS: Next week we return to the regular edition, because "unfortunately" I have a pile of releases collected...