Kotlin or Java: Which language should you use to build Android apps?

In the world of Android app development, Java had already established itself as a battle-hardened language that has died a number of times only to be resurrected as many times. But then came the sunny morning of May 17, 2017, and the story changed — bringing Java on a path of decline. That was the day of the 2017 Google I/O Developer Conference where the tech giant announced Kotlin as an official programming language for the Android mobile platform.

This thus-far unpopular programming language that was brought into existence by JetBrains in 2011. However, it suddenly burst onto the scene with this announcement when it became the preferred language of not just Google but also of organizations like Uber, Evernote, Coursera, and Pinterest, among others.

The rate of adoption that spiked then hasn’t gone down even at the present date. The more businesses are exploring the language, the more they are becoming its evangelists.

There are some very real, striking benefits that the language offers over Java and they are exactly what we will be discussing in this article. We will be looking at the reasons why Google chose Kotlin as its official programming language and try to find out if the time for developers to bid adieu to Java has really come.

Without further ado, let’s straightaway get to the reasons behind Google’s choice.

kotlin

Why Google chose Kotlin as its official programming language

1. The language is 100 percent interoperable with the Java programming language

Kotlin has been conceived with the idea of becoming completely interoperable with Java. This means Android app developers can make use of a number of Java libraries for writing code in Kotlin and can generate Java code from Kotlin with the help of converters offered by the language’s developer company JetBrains. What this means for organizations is that they can reuse their existing talent by training developers on Kotlin rather than having to hire a completely new team to develop in Kotlin. This resource utilization is a big considering for enterprises that rely on hundreds or Java developers even today.

2. Safe architecture

One of the biggest problems that developers face while working with Java is that when they access a part of the null reference, they get null reference exception. Kotlin is aimed at eradicating the NullPointerException from the code thus lowering the chances of mobile apps crashing mid-operation.

3. Android apps written in Kotlin run faster

By supporting inline functions, Kotlin is able to increase the execution speed of Lambda functions. Also, since the language has a compact runtime library, the methods added at runtime are a lot less than Java, which enables the apps to run faster on users’ devices.

4. Kotlin is a lot more compact and concise

The fact that a class written in the new Google official language is a lot more compact and concise than Java is one of the prime reasons behind the growing popularity and acceptance of the language. Because the class is compact, the amount of code to be written in Kotlin is also a lot less than Java.

And as any developer would know, less code equates to fewer bugs, quicker development time, and ultimately lower development costs. These are the ripple benefits of Kotlin being a modern alternative to Java.

5. Efficient coding with the help of IDEs

Android app developers are able to write code more efficiently with Kotlin because of the presence of robust IDEs as compared to Java.

Kotlin components like Anko and Android extensions that make it possible for developers to replace the findViewById() function help developers write code that is a lot more cleaner and readable.

Kotlin is powered by features that not just make the Android app developers’ lives easier but also betters the overall user experience. Has the time come for the world to move from Java? Is Java now officially on the track of becoming an obsolete programming language?

Well, not so soon. If anything, the community of Android app developers believes that the future of the two programming languages lies in growing together and not in one supplanting the other.

Even if you look at the present-day scenario, while it is true that Kotlin has managed to find itself a follower base of thousands of Android app developers and has been accepted and adopted by a range of different businesses across industries, there are a number of areas where Kotlin still lags behind Java.

kotlin

Why Kotlin will not be overtaking Java anytime soon

1. High .apk size

Kotlin comes attached with a bigger runtime size compared to Java. Plus, the standard library that the language has increases the size of .apk as well. This means that while Kotlin can support an app size of up to 800KB, the moment this size increases, the app becomes heavy. This is contrary to the trend of lightweight microservice applications that’s become the norm today.

2. Initial difficulty in reading code

Since the code written in Kotlin is lesser than the same code written in Java, it can be a challenge for intermediate-level Android app developers who may prefer verbose code.

3. Language is still fairly new

The number of Java developers is a lot more when compared to those using Kotlin. Because of its maturity, Java has the support of video tutorials, blogs, and articles, which is still not in abundance in case of Kotlin.

4. Apps made in Java are a lot more compact

When it comes to the development of complex apps, the scale of coding that would be needed is something that Java can support a lot better than Kotlin.

As said above, both Kotlin and Java come with their share of strengths and limitations. In a scenario like this, how do you — a business — decide which language to choose from between Kotlin and Java for Android app development?

When to use Kotlin and when to use Java

  • If Your Android app development process is in the development range of 160-200 hours and there is a lack of complex architecture, switch to Kotlin.
  • If the development process would range from five to six months, it is still considered convenient to switch to Kotlin from Java.
  • If the project will last for more than 12 months, avoid migrating it to Kotlin.

In short, if your developers are midway or further in with the project, do not make them switch to Kotlin. In case they are just starting up, it’s safer to go with the trend and take the Kotlin route.

And the answer is …

While the growth trend (in terms of the acceptance rate) that Kotlin has shown is rarely seen in any of the programming languages, we cannot ignore the fact that the language also comes with its share of shortcomings.

So, the answer to “which language to choose” would depend entirely on the stage at which your project is and the experience level of your team of developers. If your team’s Java knowledge is sound, they would not have problems with making a switch to Kotlin, but in case they are at the intermediate level, it would be better for them to stick with Java.

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top