
Of the two programming languages named after islands, Kotlin at 13 years old is a relative newcomer compared to Java at almost 30 years old. Despite its relative youth, however, Kotlin has made rapid gains as a preferred development language, particularly in the context of building Android apps and services.
Google estimates that 70 percent of the top 1,000 apps on the Play Store are written in Kotlin, including 60 of Google's own apps, such as Maps and Drive. JetBrains, the developer of Kotlin, reckons that 95 percent of the top 1,000 Android apps include some Kotlin code.
On programming language surveys, Kotlin shows up between 15th place (RedMonk), 17th (Stack Overflow survey) and 19th (TIOBE Index), while Java tends to be in the top five, but that is likely only because the latter has been around so long and is used extensively in the context of enterprise software development.
What's New in Kotlin?
In mid-May, Kotlin hit version 2.0. There's a stable K2 compiler that supports multiplatform and is twice as fast at compiling. Multiplatform lets you share Kotlin code between platforms while using native UI. Compose Multiplatform is a declarative framework for sharing UI between Android, iOS, Web and desktop; it was previously Jetpack Compose, but as of Kotlin 2.0, it's now Compose Multiplatform.
Compiler support for smart casting has been improved. Smart casting is where the Kotlin compiler can automatically cast an object to a type in specific cases, saving you the trouble of having to explicitly specify it yourself. This makes your code more robust.
Other version 2.0 improvements include changes for Kotlin/Native on Apple and to Gradle interaction (Gradle is the open-source build tool used to build Kotlin and Java projects).
Kotlin Covers Many Bases
There are four platforms supported by Kotlin: JVM, Native, Wasm, and JS.
JVM is the Java Virtual Machine; i.e. anything that Java code runs on, Kotlin code can also run on. Kotlin/Native is more interesting: it's a technology to compile Kotlin to native binaries, running without a virtual machine on Linux, MacOS, Windows, Android NDK, and iOS. This makes it slightly different as the standard library for Kotlin/JVM is not available for Kotlin/Native. Instead, it uses C libraries. Meanwhile, Kotlin/JS is an alternative to TypeScript with both generating JavaScript. Wasm is yet another option.
While Kotlin is heavily associated with Android development, it’s also heavily utilized in server-side applications. The Spring framework has supported Kotlin for some years in enterprise software development, but there are other frameworks for web development with half a dozen toolkits and frameworks.
Decline of Java?
Oracle owns Java, and changed the licensing policy for JDK 8 back in 2019. You could pay for support before then, but otherwise Java was free. After that, free public updates for Java 8 were no longer available and companies had to pay for commercial support or look for an alternative to Oracle Java.
With version 17, Java no-fee terms and conditions were introduced, which lasted for three years. Then, in January 2023, a new model for Java SE Subscriptions came into play. This could be quite expensive, and the number of firms using Oracle's Java has been declining year-on-year. You can switch to the Open JDK, for example, and obtain far cheaper support from third party companies.
A big change coming in Java is Project Valhalla, which will augment the Java object model with value objects, combining the abstractions of object-oriented programming with the performance characteristics of simple primitives. This should improve performance significantly, because accessing variables as references (i.e. accessing via pointers) on modern hardware is a lot slower nowadays compared to 1995 when Java first appeared. Java uses pointers internally for accessing data stored in heap memory.
Will this allow Java to maintain its lead as a programming language? That’s a tough question. Given the sheer amount of legacy Java code out there, the language isn’t going anywhere for the near future—but Kotlin is gaining fans pretty rapidly.
Conclusion
There appears to be something of an ongoing divergence between Java and Kotlin; not so much in the technical aspects of the languages but in their uses. Kotlin's Multiplatform brings it to platforms where Java doesn’t have a presence. However, Java still maintains its market-share in the enterprise. If you’re interested in Android and/or server-side programming, and you haven’t yet explored what Kotlin can do for you, give it a try.