Developers
June 18, 2020

Kotlin vs Java: Which Is Better For Android Development?

With two great languages at their disposal, Android developers can choose the one that best suits their needs.

With a market share that hovers around 75% Android is easily the dominant mobile operating system. This all but guarantees that any language officially endorsed by Google for Android development is sure to have a bright future.

As of the time of writing, there are currently two major languages that have Google’s backing: Java and Kotlin. If you’re developing for Android, however, which of these two should you choose?

Java: The Original Language

When Android was first released in 2008, Java was the main language for developing Android apps.

Java was originally developed at Sun Microsystems, being released in 1995 and 1996. The language quickly gained in popularity, thanks to its Write Once, Run Anywhere (WORA) approach. Java developers don’t need to worry about writing for the specific platform they’re targeting. Instead, their code runs on the Java Virtual Machine which, in turn, translates it to Java bytecode. A Just In Time (JIT) compiler in the JVM converts the Java bytecode into native code, ensuring it runs seamlessly on the target platform.

As a result of the benefits and advantages Java offers, the programming language has consistently ranked in the top three most popular languages since 2000. Since 2005, it has remained in the top two.

When Google opted to make Java the programming language of choice for Android, it was a smart decision that immediately made the platform accessible to one of the biggest single groups of programmers in the world. Whereas developers who wanted to create software for the iPhone had to learn Objective-C, a language that has never been all that popular, Android had the backing of one of the top two programming languages in the world.

Kotlin: The Upstart

Compared to Java, Kotlin is a relative newcomer to the development world. Developed by JetBrains and released in 2011, Kotlin is JVM-compatible. It can also compile to JavaScript, as well as native code using LLVM, but was primarily designed to work with the JVM.

JetBrains specifically designed Kotlin to improve on the shortcomings of existing languages, as almost none offered the features JetBrains wanted. At the same time, Kotlin’s creators wanted a language that was interoperable with Java, making it easier for developers to gradually transition to the new language.

The result is a fresh take, eliminating many of Java’s pain points, while still offering full compatibility with the JVM. Not surprisingly, by 2017 Kotlin was officially supported in Android Studio 3.0 as an alternative to the standard Java compiler. By 2019, Google had officially made Kotlin the preferred language for Android development.

Java vs Kotlin For Android: Which Language Is Better?

The fact is, both languages offer advantages and disadvantages for Android developers.

Java

One of Java’s biggest advantages is its longevity and popularity. Because the language has been around as long as it has, and is as popular as it is, there is a vast array of resources available. From third-party libraries to the developer community, any programmer who wants to use Java will have no shortage of help.

Another significant advantage of Java is its portability. Because Java was created with WORA philosophy, it’s the ideal language for Android developers who may want to offer their software on other platforms.

In addition, Java enjoys the benefits of legacy support. Because it’s been the default language for Android development for so long, many APIs and SDKs are still based on Java.

Java also offers a comfort level for many programmers, allowing them to get started on Android using a language they’re already comfortable and proficient with. Although Kotlin is a relatively easy language to learn, it’s still a step a Java developer doesn’t have to take.

Kotlin

The single biggest advantage of Kotlin is its full interoperability with Java. That means it creates the same bytecode, and apps suffer no performance hit bouncing back and forth between Java and Kotlin code. As a result, programmers can gradually rework their apps, adding Kotlin code as needed, rather than doing a major rewrite all at once. Given that JetBrains created IntelliJ IDEA, one of the most popular Java development IDEs, this level of interoperability is not surprising.

Kotlin is also known for having much more concise code, something Java has never been able to claim. Kotlin’s syntax is very readable, making it easier to debug and manage large applications.

Kotlin also benefits from being a modern programming language, built with the benefit of learning from the languages that came before it. As a result, among its many advantages, it solves a lot of problems with error handling, virtually eliminating the dreaded NullPointerException.

Of course, Kotlin’s future is another significant advantage. Now that the language has been chosen by Google as the default language for Android, it’s clear Kotlin is the future of Android development. Therefore, any time spent getting up-to-speed is an investment in the future.

Which Should You Choose?

Java developers, especially those working with a project deadline that doesn’t allow for learning Kotlin, may do well to continue with what they know—at least for now.

For new projects, or projects where developers have time to learn, using Kotlin is probably the way to go. It will provide the necessary backward compatibility and interoperability with Java, but is a more modern approach to Android development and has the brightest future.

TagsKotlinJavaAndroid Development
Matt Milano
Technical Writer
Matt is a tech journalist and writer with a background in web and software development.

Related Articles

Back
DevelopersJune 18, 2020
Kotlin vs Java: Which Is Better For Android Development?
With two great languages at their disposal, Android developers can choose the one that best suits their needs.

With a market share that hovers around 75% Android is easily the dominant mobile operating system. This all but guarantees that any language officially endorsed by Google for Android development is sure to have a bright future.

As of the time of writing, there are currently two major languages that have Google’s backing: Java and Kotlin. If you’re developing for Android, however, which of these two should you choose?

Java: The Original Language

When Android was first released in 2008, Java was the main language for developing Android apps.

Java was originally developed at Sun Microsystems, being released in 1995 and 1996. The language quickly gained in popularity, thanks to its Write Once, Run Anywhere (WORA) approach. Java developers don’t need to worry about writing for the specific platform they’re targeting. Instead, their code runs on the Java Virtual Machine which, in turn, translates it to Java bytecode. A Just In Time (JIT) compiler in the JVM converts the Java bytecode into native code, ensuring it runs seamlessly on the target platform.

As a result of the benefits and advantages Java offers, the programming language has consistently ranked in the top three most popular languages since 2000. Since 2005, it has remained in the top two.

When Google opted to make Java the programming language of choice for Android, it was a smart decision that immediately made the platform accessible to one of the biggest single groups of programmers in the world. Whereas developers who wanted to create software for the iPhone had to learn Objective-C, a language that has never been all that popular, Android had the backing of one of the top two programming languages in the world.

Kotlin: The Upstart

Compared to Java, Kotlin is a relative newcomer to the development world. Developed by JetBrains and released in 2011, Kotlin is JVM-compatible. It can also compile to JavaScript, as well as native code using LLVM, but was primarily designed to work with the JVM.

JetBrains specifically designed Kotlin to improve on the shortcomings of existing languages, as almost none offered the features JetBrains wanted. At the same time, Kotlin’s creators wanted a language that was interoperable with Java, making it easier for developers to gradually transition to the new language.

The result is a fresh take, eliminating many of Java’s pain points, while still offering full compatibility with the JVM. Not surprisingly, by 2017 Kotlin was officially supported in Android Studio 3.0 as an alternative to the standard Java compiler. By 2019, Google had officially made Kotlin the preferred language for Android development.

Java vs Kotlin For Android: Which Language Is Better?

The fact is, both languages offer advantages and disadvantages for Android developers.

Java

One of Java’s biggest advantages is its longevity and popularity. Because the language has been around as long as it has, and is as popular as it is, there is a vast array of resources available. From third-party libraries to the developer community, any programmer who wants to use Java will have no shortage of help.

Another significant advantage of Java is its portability. Because Java was created with WORA philosophy, it’s the ideal language for Android developers who may want to offer their software on other platforms.

In addition, Java enjoys the benefits of legacy support. Because it’s been the default language for Android development for so long, many APIs and SDKs are still based on Java.

Java also offers a comfort level for many programmers, allowing them to get started on Android using a language they’re already comfortable and proficient with. Although Kotlin is a relatively easy language to learn, it’s still a step a Java developer doesn’t have to take.

Kotlin

The single biggest advantage of Kotlin is its full interoperability with Java. That means it creates the same bytecode, and apps suffer no performance hit bouncing back and forth between Java and Kotlin code. As a result, programmers can gradually rework their apps, adding Kotlin code as needed, rather than doing a major rewrite all at once. Given that JetBrains created IntelliJ IDEA, one of the most popular Java development IDEs, this level of interoperability is not surprising.

Kotlin is also known for having much more concise code, something Java has never been able to claim. Kotlin’s syntax is very readable, making it easier to debug and manage large applications.

Kotlin also benefits from being a modern programming language, built with the benefit of learning from the languages that came before it. As a result, among its many advantages, it solves a lot of problems with error handling, virtually eliminating the dreaded NullPointerException.

Of course, Kotlin’s future is another significant advantage. Now that the language has been chosen by Google as the default language for Android, it’s clear Kotlin is the future of Android development. Therefore, any time spent getting up-to-speed is an investment in the future.

Which Should You Choose?

Java developers, especially those working with a project deadline that doesn’t allow for learning Kotlin, may do well to continue with what they know—at least for now.

For new projects, or projects where developers have time to learn, using Kotlin is probably the way to go. It will provide the necessary backward compatibility and interoperability with Java, but is a more modern approach to Android development and has the brightest future.

Kotlin
Java
Android Development
About the author
Matt Milano -Technical Writer
Matt is a tech journalist and writer with a background in web and software development.

Related Articles