JetBrains has released Kotlin 1.4, a significant update to the Google-preferred language for Android development.
Kotlin began as a language targeting the Java Virtual Machine (JVM) but although its core use is for Android development, it can target other platforms including native code.
Redmonk's language rankings place it at 19, with analyst Stephen O'Grady noting how impressive it is that "Kotlin, one spot ahead of Rust this quarter, was fully twenty behind it five years ago at #68", but adding that its upward trajectory has now stalled. JetBrains claims more than 5.8 million Kotlin coders over the past year.
Version 1.4 is perhaps the most significant update since 1.3 in October 2018. The language now supports SAM (Single Abstract Method) Conversions, previously only supported when working with Java methods and interfaces, enabling more concise and efficient use of lambda expressions.
Another change is the ability to mix named and positional arguments, and there are other small tweaks. Type inference is improved so that it applies to more cases, enabling wider use of the
Kotlin Multiplatform lets developers write shared code for a common core, and platform-specific code where needed
Kotlin Multiplatform is a project, currently in alpha, to share code across multiple platforms by defining a core language and libraries called Common Kotlin, that compiles for all targets, and writing platform-specific code separately. A new feature in 1.4 is called hierarchical structure support, and lets you share code between a subset of platforms, such as between different varieties of iOS.
The Kotlin Standard Library has a bunch of new additions, including new functions for arrays and collections, and new functions for bit operations, including the "experimental"
rotateRight(). There is also the first stable version of the Kotlin JSON serialization API.
Kotlin's popularity is based on being an easy transition for Java developers, but with a type system that eliminates most null reference exceptions, and many additional features including extension functions, properties, operator overloading, and more.
The language is well liked – the fourth "most loved" language, according to StackOVerflow's survey – but there is a recent development that may erode its market share.
"I am a big fan of both Kotlin but also Flutter... in terms of multi-platform development I can say that there is no contest, Flutter wins hands down and I am going to lobby to switch our KMP [Kotlin Multiplatform] project to Flutter when we get an initial release out," said one developer.
This is in the context of cross-platform rather than Android development, but with Google's big investment in Flutter it would not be surprising to see some Android-only developers also heading in that direction.
That said, the advantage of Kotlin is that you can use it wherever you can use Java, including for server applications using Spring, Micronaut or JetBrains' own framework for web applications: Ktor. If Kotlin loses some mobile developers to Dart and Flutter, it may still gain by being a better Java than Java elsewhere. ®