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. Our dedicated Java application developer has 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 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.
‘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.
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.
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
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.
‘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.
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.
Rate this article
Our Clients' Feedback
They use their knowledge and skills to program the product, and then completed a series of quality assurance tests. We were working in an agile way with them. Belitsoft performed very well throughout our project. We are definitely looking at Belitsoft as a long-term partner.
Service Delivery Director at Crimson (United Kingdom)
I highly recommend Belitsoft for website design and development. We were up against a tight deadline to launch the project. The work was delivered on time and within budget! I will continue working with Belitsoft as a valued partner for our web development!
Program Administrator at UC Berkeley (United States)
We have worked with Belitsoft team over the past few years on projects involving much customized programming work. They are knowledgeable and are able to complete tasks on schedule, meeting our technical requirements. We would recommend them to anyone who is in need of custom programming work.
Main Partner at Hathway Tech (United States)
Belitsoft company is able to make changes instantly. One of our internal engineers has commented about how clean their code is. Belitsoft seems to know what they're doing, which I appreciate.
Co-Founder at HOWCAST MEDIA (United States)
It was a great pleasure working with Belitsoft software development company. New requirements and adjustments were implemented fast and precisely. We can recommend Belitsoft and are looking forward to start a follow-up project.
Deputy Head of Division at Fraunhofer FIT (Germany)
Belitsoft company has been able to provide senior developers with the skills to support back end, native mobile and web applications. We continue today to augment our existing staff with great developers from Belitsoft.
CEO at Apollo Matrix (United States)
Belitsoft company delivered dedicated development team for our products, and technical specialists for our clients' custom development needs. We highly recommend to use this company if you want the same benefits.
Managing Director at Key2Know A/S in 2012 (Denmark)
We approached BelITsoft with a concept, and they were able to convert it into a multi-platform software solution. Their team members are skilled, agile and attached to their work, all of which paid dividends as our software grew in complexity.
COO at Regenerative Medicine LLC (United States)
Having worked with Belitsoft as a service provider, I must say that I'm very pleased with the company's policy. Belitsoft guarantees first-class service through efficient management, great expertise, and a systematic approach to business. I would strongly recommend Belitsoft's services to anyone wanting to get the right IT products in the right place at the right time.
CEO at Moblers (Israel)
If you are looking for a true partnership Belitsoft company might be the best choice for you. They have proven to be most reliable, polite and professional. The team managed to adapt to changing requirements and to provide me with best solutions. I strongly recommend Belisoft.
Director at ShowCast Limited (Germany)
I expected and demanded a lot of you at Belitsoft company, but you exceeded my expectations. You acted pro-actively, challenged me at the right moments. Thanks!"
CEO at Ticken B.V. (Netherlands)
We have been working for over 10 years and they have become our long-term technology partner. Any software development, programming, or design needs we have had, Belitsoft company has always been able to handle this for us.
СEO at ElearningForce International (United States/Denmark)
Belitsoft has been the driving force behind several of our software development projects within the last few years. This company demonstrates high professionalism in their work approach. They have continuously proved to be ready to go the extra mile. We are very happy with Belitsoft, and in a position to strongly recommend them for software development and support as a most reliable and fully transparent partner focused on long term business relationships.
Global Head of Commercial Development L&D at Technicolor