Java vs Kotlin: a Veteran against the Upstart Challenger

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 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.

 

Jun 14, 2018

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, confessed.

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 June 2018, Java has maintained its number one spot compared to June 2017. Kotlin, though still a young language, has made it to the top 50 of the rankings, setting down at number 49.

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 there 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, explains.

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 June 11, 2018.

Kotlin apps in Google Play

 

According to the Realm report,  Kotlin has every chance to overtake Java already by the end of December 2018.   

Kotlin overtakes Java

Source: realm.io

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," writes 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

Rob Fletcher, a senior software developer at Netflix, wrote: "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."

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 wrote.

 

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 a 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.

,>

RECOMMENDED FOR YOU

Lead Generation Design of The Best SaaS Websites

If clothes make the man, the design makes the website. That's where potential customers start evaluating a product. The SaaS website can (and should) be an online lead-generation machine, so each component of it has to be as good as possible. As people generally remember the first and the last thing they see, having impressive header and footer can go a long way towards making your product successful. What do some of the best SaaS companies do with their websites’ headers/footers? Look at this list to get and keep in mind some ideas for custom software development while building or redesigning your SaaS website. ...

PHP 7 vs Node.js

Our team is experienced both in PHP programming and Node.js development. We have a portfolio with both PHP-based applications and Node.js-based applications as well as mixed ones. What do we take into account when considering which tool to use in custom software development? ...

The Top 10 Advantages Of Laravel for Cost-Effective Web Development

Laravel framework is very popular for custom software development. It is the Most Starred PHP Framework on Github: more than 35 000 developers from all over the world (mostly from the USA) greatly appreciate robust features of this platform. Based on data of the BuiltWith, Laravel's popular websites verticals include Business, Entertainment, Media, News, Shopping, Technology, Vehicles. Why is Laravel so popular? ...

100% Remote Million-Dollar SaaS Companies

Companies that hire remote (distributed, virtual, dispersed, or dedicated) workers and do it well seem to have a huge leg up on the competition. Let’s learn how these successful SaaS companies use global talents to increase software quality and reduce the cost of rent and office supplies: Basecamp, Buffer, Chargify, Convertkit, Ghost(pro), Groove, Hubstaff, Invision, Olark, and Zapier. As the company where you can find a remote PHP developer, we believe that you could utilize their experience and expertise to build your own full remote SaaS company. ...

SaaS Founders Who Became Rich Starting With MVP

Belitsoft has a huge experience in MVP software development for startups and prototypes for existing brands. MVP is a minimal version of the product with the minimum set of features that is enough to deploy and test the key hypothesis to solve problems of this product’ potential customers. Experts suggest that, in B2B, it’s not an MVP until you sell it. Viable means you can sell it. ...

Profitable SaaS Startup Ideas

The way to get profitable startup idea is not to try to think of startup ideas (including SaaS development). It's to look for problems, preferably problems you have yourself.  In fact, for many entrepreneurs, successful business ideas start out as solutions designed to address a challenge they face personally. Solving the problem that frustrates you may be one of the best ways of finding an idea for your startup. Look at these software developers who turned their problem into success.  ...

Get A Free Quote

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.

Call us:
Phone - USA
Phone - BELARUS
Skype
EMAIL US:
Contact form

We use cookies to enhance user experience

Ok Learn more