Main image of article Google's Android SDK Tweaks Will Improve Kotlin Programming
Kotlin is an increasingly popular programming language, especially with tech professionals who work frequently with Android apps. Growth in usage began long before Google named Kotlin a “first class” supported language for Android development, according to a 2018 survey by Pusher. Another recent survey, by Stack Overflow, placed Kotlin second on the list of “most loved” languages, just behind Rust and ahead of Python. Given all that, it’s not surprising that Google is adjusting the Android SDK in a very specific way to facilitate Kotlin-based development; if anything, it’s shocking that the company hasn’t taken this step before. In order to make the SDK more “Kotlin friendly,” Google has tweaked how it handles nullability. From Google’s developer blog:
“When using the Java programming language, one of the most common pitfalls is trying to access a member of a null reference, causing a NullPointerException to be thrown. Kotlin offers protection against this by baking nullable and non-nullable types into the type system.”
When Kotlin calls APIs written in Java, it needs annotations in order to figure out the nullability of various parameters and return types. The new SDK facilitates this by including nullability annotations for frequently used APIs. As the blog adds:
“This will preserve the null-safety guarantee when your Kotlin code is calling into any annotated APIs in the SDK. Even if you are using the Java programming language, you can still benefit from these annotations by using Android Studio to catch nullability contract violations.”
Although Google has only annotated a “small percentage” of potential APIs so far, it will continue to add them over the next several releases. Pusher’s survey found that some 79.5 percent of tech pros who use Kotlin do so in the context of Android, while 31 percent rely on it for backend/server work. Another 30.5 percent interact with Kotlin the context of libraries, and 5.5 percent for “other” activities. In other words, Android is clearly driving the ecosystem right now, which makes anything Google does to facilitate Kotlin development a good move.