Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Kotlin vs Java for Android Developing – 2018

DZone's Guide to

Kotlin vs Java for Android Developing – 2018

This article makes the case for Kotlin over Java for Android development - read on to see why.

· Mobile Zone ·
Free Resource

Google announced at the keynote of the Google I/O 2017 the arrival of a new programming language for Android applications: Kotlin. A real revolution for developers! But how does it compare to Java? Let’s discuss Kotlin vs Java in more detail.

Android is an operating system that will soon celebrate its 10th anniversary. Its architecture involves different programming languages. Until now, Google only supported Java to develop the famous applications that you use every day. There are several versions of Java, the most recent of which is named Java 10.

Today, Java is increasingly decried because modern languages have become somewhat old-fashioned. iOS developers did not hesitate to make fun of Android, because Apple has developed its own language: Swift.

Rumors circulated a year ago about the support of a new language to complete Java. But during Google I/O 2016, we were treated to radio silence. Google engineers then denied the use of Swift, although the language is open-source.

This edition of Google I/O has generated great relief among Android developers since support for Kotlin has been formalized. This programming language developed by JetBrains (to whom we owe  IntelliJ, the environment that is the basis for Android Studio) has already been in use by some developers for several months or years, despite the lack of official support.

What Is Kotlin?

The addition of this new language raises many questions. The first, and not least, is that Kotlin does not require us to rewrite all applications. It is quite possible to combine Java code and Kotlin code. We understand why Google has opted for this solution that offers a smooth transition. Kotlin is also a robust and proven language since it has been available for almost five years and is already used in production on Android applications, some examples being Flipboard, Pinterest, or Expedia.

What Does Kotlin Offer?

The list of features would be too long, but we can summarize them: richer, flexible, and concise. An official page details more precisely the differences that can be found with Java.

On stage, Google has said loud and clear that the support of Java, C, and C ++ will be the same. Kotlin is simply a new supported language.

The Genesis of a Very Promising Language

JetBrains faced a dilemma: its software was developed exclusively in Java, but the language proved less and less adapted to their desire to expand. JetBrains needed a more productive and less restrictive language. Since the alternative languages of the time did not have the features sought by developers at JetBrains, they decided to create their own language; they presented it for the first time in June 2011 during the JVM Language Summit conference.

This new programming language created by JetBrains allowed developers to express the same intention using fewer keywords and characters than Java, without losing clarity and understanding. Product code with Kotlin is more compact, more expressive, and less subject to certain programming errors than Java. It is also as fast as Java at runtime, as well as at compile time.

A Need for Renewal

Android developers face the same constraints as JetBrains: they feel limited by the version of Java imposed by Google. They spend too much time “thinking code” and not enough “product” and new features. Especially since the latest version of Java is slow to arrive in the Android ecosystem, with a lot of promises and novelties to help developers produce more efficiently.

If the newest version of Java is already available on other platforms, Google is slow to implement it on Android, surely cooled by the case that has opposed Oracle on its use of Java APIs as part of the design of its virtual machine Dalvik. Some Android developers, frustrated at not being able to take advantage of this latest version, are starting to turn more and more towards Kotlin, just as JetBrains is making its language compatible with Google’s mobile platform.

However, not all Android developers dare to take the plunge: for some, using Kotlin in its code base represents a risk they are not ready to take because, before the announcement at Google I/O 2017, it was not officially supported.

And Android Studio?

Android Studio is based on IntelliJ, which supports Kotlin. Therefore, if you use at least Android Studio 2.0, the IDE knows perfectly how to handle this new language.

A concise language also means fewer potential errors, and thus fewer long-term crashes. As application development is easy, it is also hoped that applications and new features will be deployed faster.

If you’re new to Android, do not waste time - go straight to Kotlin!

Topics:
kotlin ,java ,mobile ,mobile app development ,android

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}