This article is more than 1 year old

Sick of Java and C++? Google pours a cup o' Kotlin for Android devs

Compatible with 'droid libraries, statically typed language is leaner and safer

Google on Wednesday said it has made Kotlin a first-class language for Android development, alongside Java and C++.

"We did it because Kotlin is a beautiful programing language," said Stephanie Saad Cuthbertson, director of product management for Android, during the developer keynote at Google I/O 2017. "...With Kotlin, there's just so much less syntactical noise between what I want to say and how I can say it."

The addition of support for Kotlin, initially released in 2011 and available as a 1.0 release last year, isn't quite as significant as Apple's adoption of Swift in 2014. Google hasn't had to create a new set of APIs to support Kotlin. And Kotlin isn't being positioned as a replacement for Java or C++.

Rather, as a statically typed programming language that depends on the Java Virtual Machine, it's an alternative to Java, one already used by a fair number of Android developers but not – until now – official supported.

Kotlin's first-class status with Google may make Android development more appealing among those put off by Java's verbosity. An example presented during the developer keynote showed how a single Kotlin line could accomplish the same thing as 87 lines of Java.

That's not to say Kotlin programs will necessarily be that much smaller than equivalent Java code. But Kotlin should let developers write a bit less code with a more readable syntax.

As a statically typed language, Kotlin is "safer" than dynamically-typed languages because it can avoid errors that arise when variables configured for one type of data (eg. an integer) handle another type of data (eg. a floating point number). It's also null-safe, meaning it can handle null references without throwing an exception.

Google's embrace of Kotlin translates into support from Google in the form of documentation, tutorials, and code samples, as well as availability through Android Studio 3.0.

Android Studio 3.0 offers the ability to convert between Java and Kotlin code with a click, making it easy to bring old Java source code into the present. In fact, Kotlin's compatibility with Java makes it possible to call Java code from Kotlin or Kotlin code from Java.

Google made sure to stress that it isn't dumping Java: It noted that Android now supports Java 8 features through the javac compiler. But developers can now dump Java if they wish. ®

More about


Send us news

Other stories you might like