Daily Takeaways from KotlinConf 2024
-
Bontouch
Another year and another set of exciting updates to our favourite language Kotlin, kicking it off with the much anticipated announcement of Kotlin 2.0. At Shape and Bontouch, we make extensive use of Kotlin across multiple platforms, primarily for Android and Backend development, and it is always a thrill to see what JetBrains comes up with next. From new language features to community created frameworks this conference was packed with great content we can’t wait to get our hands on.
Without further ado, let’s dive in together and hear from our four developers about which talks and new technologies inspired them most from KotlinConf 2024!
KotlinConf 2024 is now behind us, and we’ve had a couple of days to let all the impressions sink in and reflect upon the experience. While the conference featured great talks by celebrities like Jake Wharton and Erik Meijer, as well as a great inspirational keynote by Daniel Terhost-North, the talk I want to highlight was very niche and held in front of a much smaller audience:
Using C and Native Platforms in Kotlin: Building a multi-platform advanced library
Salomon from KODEIN Koders walked us through the pains of integrating your Kotlin multi-platform app with native APIs and libraries. The talk focused on three different APIs related to cryptography and the different approaches that have to be used to integrate these for each target in your Kotlin multi-platform project. While KMP has come a long way, this task is definitely not for the faint of heart. This talk featured lots of C and JNI code, which I’m sure looked ugly to people mainly used to looking at pretty Kotlin code.
Since the availability of APIs in question varies between platforms, there is no single approach that works. For example, the cryptographic algorithm Chacha-Poly is available as a Java library on the JVM, a Swift library on Apple, and a C library on Linux. Each one comes with its own gotchas and challenges. The phrase “write once, run anywhere” often said about multi-platform technologies, does not apply here.
I dearly hope that I will never need any of the learnings from this talk, but that is beside the point. The main reason I want to highlight this talk is that despite the advanced topic, Salomon was able to keep you interested and entertained with great presentation skills and lots of humor. Yes, there were lots of laughs to be had during this talk about cryptography and C libraries.
The slides used to support the talk were beautiful, with nice animations and transitions. In fact, there were no slides - because, of course, true Kotlin lovers don’t let themselves be limited by tools such as Keynote or PowerPoint. The presentation was actually a compose ui running in a multi-platform app on his laptop. I highly recommend checking this talk out once the recordings become available, and if you don’t, at least check out the slides here!
As some of my colleagues have previously pointed out, this year’s KotlinConf was big on Kotlin Multiplatform. As primarily a backend developer for Shape, where our job is specialising in making the best backends for the mobile app experience, getting additional insight into the different possibilities of app development is always valuable. However, I must admit that the most exciting parts of the conference for me were the sessions focused on the various applications of Kotlin in backend development.
Kotlin 2.0 Launch, Smart Casts, and Backend Development Breakthroughs
First of all, the release of Kotlin 2.0 was announced. It’s impressive to hear about the lengths the Kotlin team has gone to, to ensure that migration from 1.x to 2.0 will go smoothly and is production safe. Not only that, but cool new features were announced, such as vastly improved compiler speed, additional functionality for guards, and context parameters. My personal favorite was the improvements to smart casts, highlighting once again how Kotlin leads the charge in making coding even more fun and efficient.
KotlinConf also brought some of the leading talents from the industry to Copenhagen, and I had the opportunity to listen to a panel discussion moderated by James Ward, developer advocate at AWS, with panelists such as Ty Smith (Uber), Eve Matthaey (Meta), Kevin Bierhoff (Google), and Anton Yalyshev (JetBrains).
In the discussion, the panelists talked about why they decided to migrate from Java to Kotlin, some of the lessons they learned along the way, and briefly presented some of the tools they developed to assist them in this process. Most of the migration techniques revolved around the Java-To-Kotlin converter available in IntelliJ. While this J2K converter is a very powerful tool for automatic code conversion, it’s not flawless, and as the panelists described, it did not always produce idiomatic Kotlin code.
As such, the engineering teams at Uber, Meta, and Google have created several tools of their own to recognise certain coding patterns in their existing Java code and to write custom post-processors to handle these after the J2K conversion. One thing they all agreed on was that before thinking about automatic conversion, ensure your Java code lives up to the null-safety standards of Kotlin - As the moderator James Ward put it, “Get your null ducks in order!”
While Java is still a very powerful language for many use cases, the benefits of using Kotlin when it comes to developing native Android applications are unmistakable. At Shape, we have been Kotlin first for a long time. Not only for writing our Android applications, but also for writing fast and efficient backends for our mobile applications using modern web frameworks like Ktor.
Overall, KotlinConf was a great experience, reaffirming the innovative strides Kotlin continues to make in enabling developers to write fun, efficient, and expressive code, whether in the realm of backend or mobile development. I’m already looking forward to trying out the new features of Kotlin 2.0 and seeing how they will enhance our work on both existing and new projects!
KMP in Action: A Production Case Study
At this year’s KotlinConf it was clear that JetBrains and Google are excited about one thing in particular: Kotlin Multiplatform (or KMP for short). Kotlin Multiplatform allows you to write code in Kotlin that can target multiple platforms, such as Android, iOS, web, desktop, and server-side applications, without restricting how to develop the app’s UI. It’s also now officially supported by Google, which recommends it for sharing business logic across platforms.
In her session, Annyce Davis walked us through her organisation’s journey of adopting Kotlin Multiplatform. The team started off by assessing the potential benefits and downsides of using KMP. The cost benefits of a faster time to market while still using their prior Kotlin knowledge led to the decision to rewrite their existing apps with KMP.
Initially, the team faced a few challenges. The developer experience and tooling were lacking for iOS, and some developers were worried that they would lose autonomy. However, as the team got more used to this new way of working and as the platform itself became more mature, they found that they preferred working with KMP and migrated over to a monorepo to fully commit to KMP's vision of a shared code base. They are even considering using shared code for their views with Compose Multiplatform.
One big takeaway from this session is that many of the technical limitations of KMP that people were initially struggling with have been resolved, and a lot has improved. I'm excited to see how KMP can transform traditional Android and iOS development and also make teams collaborate even closer together. It's also great to see Kotlin taking big steps towards being a more inclusive language and broadening the platforms that it supports. After having learned how successful the final outcome of the project was, I’m looking forward to trying it out on one of my own.
KotlinConf is one of my favourite conferences, and it never fails to inspire me. My history with Kotlin goes all the way back to 2014 when an excitable student who learned Java as a main language got his hands on a beta version of Kotlin and fell in love with it from the first Hello World. Over the years, the language has evolved from a new kid on the block to a powerhouse used by thousands of programmers every day. Anyway, enough fanboying, here are the talks that stood out to me most.
Kotlin Language Features in 2.0 and Beyond
It is impossible not to talk about what is in store for us in 2.0. Michail, however nervous he said he was, gave us a great insight into what the team has been cooking and what could become possible thanks to the new compiler.
Not to spoil everything, but two main upcoming features that I’m very excited about are the improvements to Smart Casting and Guarded Whens.
I’ve lost count of how many times I felt upset when I had to manually cast an instance of a sealed class just because there was no way for the Kotlin compiler to infer it, resulting in, frankly, not the prettiest code. New Smart Casting solves it all, allowing you to write much more comprehensible code with so much less effort that I can't wait to try it out.
The Guarded When is also a feature that I’ve been dreaming of for a long time. Control flows are a big part of your day-to-day life, and back in the day, sealed classes improved them tenfold. However, with the introduction of guards, we now have the opportunity to write even more concise code that is not just functional but also aesthetically pleasing and easily readable at a glance.
Refactoring to Expressive Kotlin
This one might be an unexpected pick, but I believe expressiveness is the mark of a great programmer. I always say to my mentees or in guest lectures, however blasphemous it might sound, that well-written code doesn’t need commenting, and ideally, it should read like a well-written novel. I strive to hold myself up to this mantra as best as I can and this talk is pretty much all about exactly that. By leveraging Kotlin constructs and thinking a little more about the way natural languages work, we can write beautiful and easily understandable code in a language that we speak better than our native one.
Frameworks I'll be keeping an eye on
- DataFrame: Kotlin's Innovative Approach to Data Structures.
- Compose beyond the UI: Molecule at Swedish Railways.
I will be brief about these two as the talks themselves do not need that much more to be said about them to get excited.
DataFrame is a Kotlin way of working with, you guessed it, data. While many data nerds like myself would normally turn to Python or R for this, it’s rather interesting to see what Kotlin will offer us. Automatically generating data structures with integration to Kotlin Notebooks built on top of a strictly typed language is very ambitious, and I’m excited to find out where it will go.
Molecule is an amazing framework that makes you think about composition in a different way. It gives you an impressive and powerful method of combining many complex data streams, and the talk demonstrates it in a practical case that many of us must have faced at some point.