Last week, Google just launched free online courses on kotlin and Android to teach developers how to build Android applications with kotlin. Soon, the Google home team demonstrated the benefits of kotlin development through their own experience.

Google home app can be used to connect and manage a variety of smart home devices. Like many apps affected by Google’s “kotlin first” initiative, Google home has chosen to include kotlin in its code base. As of June this year, about 30% of the application’s code was written in kotlin, and future new features are encouraged to be developed with kotlin.

the Google home team mentioned that with kotlin, the jetpack open source UI toolkit, which is also promoted by Google, combines the simplicity and ease of use of the reactive programming model and kotlin programming language to simplify UI development.

although only one third of the code has been migrated to kotlin, its efficient and concise features have made the Google home team feel deeply. They cite the use of data classes and the parcel plug-in: classes made up of 126 lines of handwritten code in Java can be represented in only 23 lines in kotlin – 80% less code. In addition, some function methods in kotlin simplify many nested loops and filter checks.

on the other hand, kotlin’s nullability has also been praised. Compared with Java, the Google home team pointed out that “when the usage of nullability annotations in Java is inconsistent, some bugs may be missed.”. Since the adoption of kotlin, Google home’s nullpointerexceptions have decreased by 33%, which is the most common type of crashes on Google play console. The reduction in the number of crashes caused by this may significantly improve the user experience.

from the initial support of kotlin to “kotlin first”, Google has been supporting kotlin in in various aspects. It has successively launched kotlin free online courses and courses using kotlin to build Android applications. At the same time, it has continuously improved the relevant ecology. For example, in April this year, grpc kotlin / JVM was opened to allow developers to use grpc more easily in kotlin projects.

with the vigorous implementation of Google, kotlin’s attention has been increasing. According to the latest JVM ecological report, kotlin has become the second popular JVM language. In an interview with open source China, Android development expert Shen zhe mentioned that some domestic companies have begun to use kotlin to develop Android projects. “More and more developers will choose kotlin as the preferred development language for native apps.”.

as a JVM language, it is compatible with or even considered to replace Java. Kotlin’s appearance is often accompanied by a comparison with Java. Google even launched an official guide to migrating from Java to kotlin. Some Android developers are still hesitant to switch to kotlin, and some have already moved from Java to kotlin and back to Java. In a survey released by dice a year ago, 85% of respondents almost fell flat and chose to still use java to build Android applications.

but in fact, in the eyes of Google engineers, there is no need to draw a clear line between the two. Jeffrey Van Gogh, technical director of Android studio, once said that Java and kotlin are highly interoperable, so they can coexist in the same project. At present, many of Google’s own applications such as Google home adopt this integrated approach, and kotlin is more used to write new functions.

so, back to the question of “kotlin or Java”, which may have bored Android developers, the conclusion obviously does not exist. The key is to choose the most appropriate way.