When Google announced Kotlin its next official programming language for Android, its popularity in some regions saw a more than sixfold increase. The language has drawn the attention of brands like Amazon, Netflix, and Pinterest and broke into the elite of the programming world. It has been steadily gaining ground since then. Some people predicted the death of Java, at least on mobile devices. We’ve done a little research to see how those two languages compare in terms of Android app development. Learn about how Java gave rise to Kotlin, their relations, code lines stance, communities, performance issues and more in our step by step matchup.

What is Java

Java is an object-oriented statically-typed programming language and computing platform. It was released by Sun Microsystems in 1995 (later acquired by Oracle Corporation). Today, most major elements of Java are accessible as open source, and those that do not mostly have open replacements for them.

Sun, the original developers of Java, placed much of it under the GNU General Public Licence in 2006. Java is employed in the development of Android apps, server apps, web apps, websites, embedded systems. 

It is especially popular in financial software development.

What is Kotlin

Kotlin is a statically typed programming language that targets the JVM, Android, JavaScript, and Native. Kotlin is open source developed under the Apache 2.0 license. The source code is available on GitHub. The language combines both object-oriented and functional programming features. You can use it in both OO and FP fashion, or blend elements of the two.

Kotlin boasts the support of all major Java IDEs including IntelliJ IDEA (the brainchild of JetBrains), Android Studio, Eclipse, and NetBeans. It can be used for most kind of apps, be it server-side, client-side web or Android.

Kotlin/Native, that is currently in the pipeline, will provide support for other platforms such as embedded systems, macOS, and iOS.

Java to Kotlin story

Although Kotlin v1.0 was released only on February 15, 2016, the history of this programming language dates back to 2011. Kotlin was created by JetBrains out of their practical needs. The company had 70% of its products build on Java but started to realize its shortcomings - mainly excessive verbosity. They wanted a language that would be Java-compatible since rewriting everything into a completely new language seemed a no-go option. They started experimenting with Scala but were not satisfied. That is when the concept of a new language, Kotlin, was born.

Another motivation behind Kotlin is fairly straightforward:

‘We expect Kotlin to drive the sales of IntelliJ IDEA.’
Dmitry Jemerov, one of the Kotlin blog contributors

Java vs Kotlin: Market situation

The influence of Java on the development world is huge, which is backed up by the reputable Tiobe Index. As of July 2019, Java has maintained its number one spot compared to July 2018. Kotlin, though still a young language, has made it to the top 50 of the rankings, setting down at number 43.

Google  I/O 2017 conference was marked by the promotion of Kotlin to the ranks of its “first-class” programming languages for Android app development. It joined the good old Java and C++. The announcement has fueled up the interest over Kotlin, causing the spectacular growth in its popularity.

Kotlin popularity Source: realm.io

‘Android developers have an official guarantee that the language will be supported, which will lead to further adoption of Kotlin.’
Andrey Breslav, the lead language designer of Kotlin at JetBrains

Square, Pinterest, Basecamp, Netflix, Amazon, Uber, Trello, and Twitter have already declared their conversion to Kotlin.

AppBrain offers the following numbers for the share of Kotlin apps in Google Play as of July 30, 2019.

Kotlin apps in Google Play

Java vs Kotlin: Painless transition

Kotlin was designed with a strong focus on its interoperability with its elder sibling Java. It means you can translate any Java code into Kotlin or vice versa without changes in their operability.

There may be certain features for which you’d prefer Kotlin or some, where Java seems a better option and it’s ok. Since both Kotlin and Java codes compile to JVM bytecode, end users will not be able to tell where the one ends and the other continues.

‘One of the key focuses of Kotlin has been interoperability and seamless support for mixed Java+Kotlin projects.’
Andrey Breslav in his blog post

Java vs Kotlin: Verbosity

The verbosity of Java has long been its major shortcoming and a source of frustration for the developers. Kotlin is designed to reduce the number of boilerplate code one needs to write.  

Verbosity of java Source:quiita.com

Kotlin conciseness helps to increase a cut in the lines of code by approximately 40 %, according to JetBrains. Real tests show that after converting “App Lock” app from Java into Kotlin, the number of code lines reduces by 30% (from 12,371 lines of Java, to 8,564 lines of Kotlin).  

Kotlin also provides a heap of nice-to-use features that Java does not have, like:

  • Extensions, that help to extend a class functionality;
  • Coroutines, aimed at avoiding thread blocking, thus minimizing the risk of errors;
  • Null-safety, that ensures no null references occur, thus reducing the risk of an app going faulty

and more.

As a result, a more robust and safe code can be written with fewer efforts. The time needed for the amount of the output generation and bugs fixing cuts down.

Perfect cat code

‘Kotlin isn't revolutionary (with the possible exception of its null-handling) but feels like a very careful amalgamation of some of the best features of other languages. Its approach is very pragmatic and emphasizes interoperability with Java and a lack of surprise.’
Rob Fletcher, a senior software developer at Netflix

Mobile app development (Android and iOS) is one of our specialties. Let us know how we can help.

Java vs Kotlin: Android Studio 3.0 Support

Java implementation in Android ecosystem seems to lag behind the demands of the developers’ community. Though the latest version of Java is SE 10, Android Studio 3.0 and later supports Java 7 and only some of Java 8 features. Thus, developers that are denied the opportunity to embrace the full potential of the latest versions are starting to shift more towards Kotlin.

Bearing in mind that Android Studio is based on the JetBrains’ IntelliJ IDEA, it is easy to predict its excellent support for Kotlin.

‘For Android developers, Kotlin support is a chance to use a modern and powerful language, helping solve common headaches such as runtime exceptions and source code verbosity.’
Maxim Shafirov, JetBrains’ CEO, commented in his blog post

Java vs Kotlin: Adoption Costs

Kotlin is open source, thus you can bring it into play for free. You can start exploring the language simply by translating it via Java-to-Kotlin converter.  Kotlin is compatible with all Java libraries and frameworks, even those that rely on annotation processing. It also perfectly integrates into building tools like Gradle, Maven, Ant, or Kobalt. All you need is to install a Kotlin plugin.

‘Kotlin is easy to get started with and can be gradually introduced into existing projects, which means that your existing skills and technology investments are preserved.’
JetBrains' CEO Maxim Shafirov

However, though similar, at their core Java and Kotlin are two different languages. The latter is currently a new language, that means that there is no established equivalent to the sources like Effective Java for best programming practices. So there will be a learning curve for your in-house team to master the Kotlin tricks.

Java vs Kotlin: Community support

Java is a programming player with more than 2 decades of history. It naturally leads to the unfathomable number of Java projects implemented and an impressive community it gathered. At the time of writing, there were 801,248 repository results for "Java" query at GitHub.

The larger the community is, the more likely that someone has already left tips on the issue you are searching for. This, in its turn, makes the development process in a language more easy and enjoyable.

Despite the fact Kotlin is gaining more and more traction, its community is still small compared to Java’s. GitHub gave us only 33,182 "Kotlin" tagged results.

Therefore, there are few tools to pump up the skills and not so many Kotlin experts to ask (at the time of writing there were 361 job results for "Android Kotlin Developer" www.indeed.com compared to only 2 resumes).

Java vs Kotlin: Performance & compile time

JetBrains claims that a Kotlin application runs as fast as an equivalent Java one, thanks to very similar bytecode structure. Yet, Kotlin's support for inline functions allows code using lambdas to run even faster than the same code written in Java.

The tests conducted show that Java compiles 10-15 % faster for clean builds. However, for incremental compilation, Kotlin shows identical to Java or even slightly better results. Decreased compile time means less unproductive time for a developer.

Conclusion

Kotlin is not a complete revolution, but rather a pragmatic enhancement of Java. They resemble each other in structure and can peacefully coexist within one project. But because Kotlin is a fresh start to some extent, it adds a variety of state-of-the-art features. Java, however, is like a friend that stood the test of time.

Sharing is caring!

Author
Written by
Senior Account Manager
I am an expert in bringing mobile app ideas to life.
4.5
15 reviews

Rate this article

Let's Talk Business

Do you have a software development project to implement? We have people to work on it.

We will be glad to answer all your questions as well as estimate any project of yours.

Use the form below to describe the project and we will get in touch with you within 1 business day.

Contact form
* Maximum file size is 20MB
to top