Android: What does Kotlin first mean? Java or Kotlin?

Android development will become increasingly Kotlin-first,” Google writes in today’s announcement. “Many new Jetpack APIs and features will be offered first in Kotlin. If you’re starting a new project, you should write it in Kotlin; code written in Kotlin often mean much less code for you–less code to type, test, and maintain.

It was only two years ago, at I/O 2017, that Google announced support for Kotlin in its Android Studio IDE. That came as a bit of a surprise, given that Java had long been the preferred language for Android app development, but few announcements at that year’s I/O got more applause. Over the course of the last two years, Kotlin’s popularity has only increased. More than 50% of professional Android developers now use the language to develop their apps, Google says, and in the latest Stack Overflow developer survey, it ranks as the fourth-most loved programming language.

Why Google chose Kotlin as a primary language for android app development?

The collaboration and support for kotlin from both Google and JetBrains ensured that Android developers could easily migrate from Java to Kotlin without any hiccups. Soon, Android developers began to realize the benefits of Kotlin over Java for Android app development, some of which were:

  1. Developers could write concise, yet expressive codes in comparison to the verbosity in Java coding.
  2. One major complaint with Java for Android app development was the NullPointerException. Kotlin addressed this issue by forcing developers to explicitly allow variables to be null and negate any such problems.
  3. It is generally hard for developers to migrate to new languages, especially when you’re used to developing android apps on a language as old as Java. This issue was easily addressed by the Android Studio’s Java to Kotlin conversion feature which let developers convert Java code directly into Kotlin.

The road ahead for Android app development with Kotlin

Google does not intend to replace Java by introducing Kotlin and promoting its use in android app development. But it simply needs something to run along with the former.

Kotlin is a statically typed programming language for Java Virtual Machine (JVM) and JavaScript. Described as a general purpose language, Kotlin introduces functional features to support Java interoperability. The Kotlin project was born out of the aspiration for heightened productivity. The goal was to improve the coding experience in a way that was both practical and effective.

You can see that functions are defined with the fun keyword, and that semicolons are now optional when newlines are present. The valkeyword declares a read-only property or local variable. Similarly, the varkeyword declares a mutable property or local variable.

Nevertheless, Kotlin is strongly typed. The val and var keywords can be used only when the type can be inferred. Otherwise you need to declare the type. Type inference seems to be improving with each release of Kotlin.

Have a look at the function declaration near the top of both panes. The return type in Java precedes the prototype, but in Kotlin it succeeds the prototype, demarcated with a colon as in Pascal.

Key Differences Between Java vs Kotlin

Both Java vs Kotlin are popular choices in the market; let us discuss some of the major Differences Between Java vs Kotlin:

  • Kotlin has the support of smart cast which identifies immutable types and performs implicit cast by compiler whereas in Java we need to identify and perform the casting.
  • Kotlin has the support of type inference which means we don’t need to specify the data type of variable explicitly whereas in Java we need to specify explicitly.
  • In Kotlin, we don’t have checked exceptions, which is a disadvantage as it leads to error prone-code whereas Java has support for checked exceptions by which we can perform error handling.
  • Java compilation time is 15–20% faster than Kotlin compilation time but in perspective of incremental build compilation, Kotlin will also take same compilation time as Java.
  • In Kotlin, we can’t assign null values to variables or return values, if we really want to assign then we can declare a variable with special syntax whereas in Java we can assign null values but when we try to access objects pointing to null values raises an exception.
  • Kotlin is interchangeable with Java irrespective of difference between Java vs Kotlin. We can call Kotlin code in Java and Java code in Kotlin. So we can have both Java vs Kotlin classes side by side in a project and compiles without any issues. After compilation we unable to find which class written in Java or Kotlin.

Conclusion — Java vs Kotlin

Finally, its an overview of comparison Between Java vs Kotlin. I hope you will have a better understanding of these Java vs Kotlin languages after reading this Java vs Kotlin article. In my view, we can proceed with Kotlin for Android application development without worrying about the compilation time even though Java has few advantages over Kotlin.

Thanks for:



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store