Thoughts on KotlinConf 2019

At John Lewis & Partners, we have been writing server-side Kotlin since 2016, and are now very heavily invested, with all new server-side applications being written in Kotlin and also new code for our Android application. We love the language, finding it productive, flexible, expressive and a joy to work with.

This year, the third annual conference dedicated entirely to the Kotlin programming language was hosted by the language developers, JetBrains, at the Bella Center in Copenhagen. I have been lucky enough to attend both this year and last year and would thoroughly recommend the event to any Kotlin developers.

This year there were 1700 attendees, and the venue was much more suitable for the number of people. There were 4 tracks and 9 sessions on the first day, and a similar number on the second day, meaning there were a broad number of topics covered, and that everyone would have a very different conference experience. In this post I’m going to share my experience and the themes that I picked up. I’m a server-side developer, but aimed to just go to anything that sounded interesting!

Opening Keynote

Andrey Breslav at the Opening Keynote

Andrey Breslav (the lead language designer) opened the conference by giving an overview of Kotlin’s growth and what’s coming up in the next release (1.4). There continues to be an almost exponential growth in Kotlin usage, and Andrey spoke about Kotlin as an open ecosystem with many contributors, even just turning on usage stats in your IDE! He said that the aim is to make Kotlin a ‘default’ language — for any platform, application, scale and level of programmer experience.

Moving on to what’s coming next, the highlights for me were:

Quality and performance improvements

  • A complete rewrite of the compiler (partially complete in 1.4), which is targeting a 5x improvement in compilation speed
  • Improved Kotlin plugin performance in IntelliJ — targeting auto-complete results in 500ms

Multiplatform

  • Kotlin can be compiled to target JVM, Javascript and native platforms
  • Current gaps in core libraries (present on all platforms) are being plugged — notably a serialisation library, DateTime, IO and an HTTP client. This should massively reduce the barrier for writing common code to target all platforms.
  • Kotlin/Native now supports Apple tvOS and watchOS, and Android Studio will allow running, debugging and testing Kotlin iOS apps
  • Optimisations to compiled JS size, and tools for auto-reload of front end Kotlin/JS
  • Working with the developers of WebAssembly as they develop a managed runtime, to make sure that Kotlin can become a well supported language

Language features

  • Function interfaces — which are true types rather than aliases, where a lambda can fulfil the interface:
fun interface Action {
fun run()
}
fun runAction(a: Action) = a.run()runAction { println("Hello KotlinConf!") }
  • Trailing commas in parameter lists! (Although this wasn’t actually mentioned in the Keynote)
  • Unfortunately no plans for a ternary operator — this was joked about a couple of times over the two days!
KotlinConf ‘19

Multiplatform

I was interested in the state of Kotlin Multiplatform, and specifically if any progress had been made which would help share large portions of applications between iOS and Android.

There is a lot of effort going into multiplatform, both from JetBrains and also from people keen to write software once to work on multiple platforms.

For the specific use case of sharing code between Android and iOS, I went to talks covering three different approaches:

  • Your Multiplatform Kaptain has Arrived — Ahmed El-Helw from Careem talked about how they are using Kotlin/Native to share a library of business logic between their Android and iOS apps and gave a lot of interesting details of how they were able to achieve this culturally within their organisation, including getting buy-in from their iOS team, and also lots of practical hints about what has and hasn’t worked. He also summed up with a poem, which was a bonus!
  • Lona: Scaling Server-driven UI — Laura Kelly and Nathanael Silverman from AirBnB talked about Lona, their server driven UI. Essentially they design their screens as row components, and implement these in their web, iOS and Android applications. They then have a server-side API which tells the apps which rows to render, in which order, and with what data. As there are lots of challenges about versions of components and versions of application that are deployed, they have invested significant engineering effort in creating a Kotlin DSL called the Lona Spec to make all of this manageable. A very interesting, different approach.
  • Going Native — Ana Redmond talked about how she ported 60+ educational 2D games from Android to iOS in 6 months (with a 2 developer team), by using Kotlin/Native. Multiplatform provides an expect/actual interface so that you can write common code which then calls a platform-specific implementation. As the games were not using native widgets, she created an SDK layer for the common code, which had abstract methods to draw screen elements, and then mapped to the 2D drawing libraries on Android and iOS in platform specific implementations. It was a really impressive achievement to port these over so quickly, and I believe that this level of sharing is a real step forwards for mobile development.

Erik Hellman talked about Building Progressive Web Apps in Kotlin, and it sounds like things are coming along well, but I got the impression that this isn’t yet ready for us to start seriously looking at.

I also attended MPP in 1.3.X and Beyond by Dmitry Savvinov and Liliia Abdulina, which was mainly giving an overview of what is available and talking about some of the hard work that JetBrains are doing to abstract away the underlying platform details so that developers don’t need to worry about them.

In Copenhagen you can drive the Metro!

Best of the Rest

What’s new in Java 19 — Jake Wharton gave an overview of the new features planned in Java over the coming years and compared them to Kotlin. As someone who hasn’t used Java since version 8, this was a bit of an eye-opener. Java is doing a lot of catching up, in fact some features do have slightly nicer implementations than Kotlin, and the bytecode generated is quite often more optimal. The thing that seems to hold Java back though is the fact that the language needs to remain backwards compatible. Definitely worth a watch if you’re a bit out of touch with the Java world.

Coroutines Case Study — Cleaning Up An Async API — Tom Hanley from Toast gave a really interesting overview of how they had used coroutines to wrap the SDK provided by a card reader device manufacturer to create much more readable code. He gave a great overview of the problem and then talked through the experiences of where the team had issues — e.g. around debugging, and some best practice that they had decided upon.

Bootiful GraphQL with Kotlin — Dariusz Kuc and Guillaume Scheibel, creators of graphql-kotlin gave a good overview of GraphQL and then demonstrated how to use their libraries with Spring Boot to create GraphQL applications using a simple syntax. If you haven’t dug into GraphQL before and you are a Kotlin developer, this talk would be a great place to start.

The best runtime for Kotlin is obviously GraalVM, isn’t it? — Oleg Šelajev, developer advocate for GraalVM gave an overview of what GraalVM is. The goal of the project is to allow developers to write high level abstractions, but still achieve optimised performance. It also allows mixing of languages too (Python, Javascript, Java, Kotlin, etc.) It supports both JIT and Ahead of Time compilation. There are different trade offs — JIT currently gives higher throughput, but AOT gives you faster startup and less memory overhead. The small demoed (AOT) microservice used ~15MB of total RAM, and started in ~25ms. Also CPU usage on startup is much reduced. Reflection is supported in AOT mode, but you have to configure the application to say which classes need to be able to use reflection. AOT is basically like Kotlin/Native, but is better in some ways because it supports using Java libraries (including the stdlib) and also can mix in other languages.

Failure is not an Option — Nat Pryce and Duncan McGregor gave an overview of error handling strategies, including checked exceptions and why they fell out of fashion (in their opinion checked exceptions weren’t such a bad thing), and also give some options about alternatives to using exceptions, including using null, and using different types to represent success or failure. We are currently using Nat’s result4k library in my project, which is implemented as a sealed class, and this talk gave a great background into some of the trade-offs and when it is more appropriate to use different types of error handling.

Kotlin Puzzlers — as at the previous KotlinConf events, Anton Keks gave a mind-bending talk where he showed the audience Kotlin code samples, and gave multiple choice answers for what the result would be. Most of the time Kotlin behaves itself, but watching these examples might change your mind! During the talk the compiler crashed more than once and there were quite a few inconsistent results between Kotlin/JS and Kotlin/JVM.

Conclusions

The event is a brilliant way on catching up with the fast pace of development of the Kotlin language, gaining an insight into the JetBrains roadmap, and also find out some cool stuff that other people are doing with Kotlin.

I think my favourite talk of the whole event was the AirBnB talk about server side UI, because it was such a straightforward idea, that was a very different approach than I had seen before.

Unfortunately, as with any kind of event like this, you have to pick the sessions you would like to attend, and cannot attend everything. Fortunately all the sessions were professionally recorded and I’m definitely going to be going back to watch more of the sessions on coroutines.

--

--

Andrew Worley
John Lewis Partnership Software Engineering

Server-side developer working for John Lewis & Partners, currently mostly with Kotlin.