Kotlin: New Kid on the Block Makes Brilliant Debut


Kotlin has emerged as one of the fastest growing programming languages in the world. In June 2011, during the JVM Language Summit, members of the JetBrains development team announced the genesis of a new and promising programming language and presented Kotlin for the first time.

Because of their desire to expand, JetBrains’ developers were constantly requesting the need for a more productive technology and less restrictive language. At that time, Java was used exclusively for JetBrains’ software development, and because other alternative languages did not have the requested features, they decided to create their own language.

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.

Very quickly and after very little time, Kotlin was adopted by many Android developers facing the same constraints as JetBrains: they were spending too much time “thinking code” and not enough “producing code” and new features due to the limitations of the version of Java imposed by Google.

In June 2017, Google announced that “Android is officially supporting the Kotlin programming language, in addition to the Java language and C++. Kotlin is a brilliantly designed, mature, production-ready language that we believe will make Android development faster and more fun.”

Kotlin growth rate

What is Kotlin?

Initially, Kotlin was designed to solve some of Java’s problems. It’s a combination of object oriented and functional programming features. It has a lot of similarities to Java in structure. But Kotlin adds a lot of nice-to-have features and has a much cleaner syntax. Interoperability, security, clarity, and tooling support are Kotlin’s focus.

Unlike the Swift programming language, which was initially an internal Apple project and later open sourced, Google doesn’t own Kotlin. The language will continue to be developed and supported by JetBrains — the company is partnering with Google to set up a non-profit Kotlin foundation to shepherd the language. Kotlin will also continue to target other platforms: the language is designed to run as native code on iOS and Mac, and compiles to JavaScript for web development.

What are the Advantages of Kotlin Over Java?

As a modern language, Kotlin has the natural advantage of being able to leverage all the language design expertise gained in the past 20 years and focus on state-of-the-art features that have proven to work well.

Kotlin has Complete Interoperability with Java

Java and Kotlin are 100% interoperable. When debating whether to use Kotlin or Java for Android development, there is a third option: to use both. This means it’s possible to have Kotlin and Java classes side-by-side within the same project, and everything will still compile.

Kotlin is More Concise and More Productive than Java

Based on new features such as data classes, smart casts, type interfaces, properties, etc., Kotlin can solve the same problems using fewer lines of code, which in turn means more reliable code with fewer bugs. For example, when writing a data class in Kotlin, ‘getters’, ‘setters’, ‘equals’ and ‘hashCode’ methods are automatically generated once this code is converted to JVM byte-code. This provides the power to directly check if two objects are the same without having to write the ‘equals’ method manually or maintaining it as the class changes. Functional programming paradigm is also supported by Kotlin even better than in Java 8: the functional concepts can be used more concisely and explicitly with proper function types.

In addition to readability and easier maintainability, this can also boost developer productivity especially by taking advantage of object declarations, parameter values and extension functions, which are all new features introduced by Kotlin to speed-up development work.

According to RebelLabs’ Developer Productivity Report 2017 (using a sample over 2000 Java developers), Kotlin is the technology they’re most excited about using, and the one they’re most satisfied with (9.1 out of 10).

Kotlin lesser known langugages

Kotlin is Safer, Easier to Maintain and Smart

Kotlin was designed to prevent many of the common programming mistakes that can be made when using Java. For example, one of the biggest goals of Kotlin is to eradicate the NullPointerException from the code, therefore producing fewer system failures and application crashes. In Kotlin, the rule of thumb is, if you know something may be null (such as data coming from a network call), use nullable variables to protect yourself from null pointer exception. All types are non-nullable by default in Kotlin: if you need to assign a null value to a variable, you must explicitly mark it as nullable. 

It's also worth mentioning that Kotlin offers a simpler and safer way to deal with the parcelable serialization by using a single annotation @Parcelize on the given class. Kotlin’s co-routines can help write async code in a blocking fashion – in this way it is possible to focus on the data rather than how to fetch it.

User-Friendly Tools with Kotlin

Regarding tooling, Kotlin does not arrive empty handed:

  • JetBrains offers an award-winning Java code editor (IntelliJ IDEA) with a Kotlin plugin.
  • The official development environment of Google (Android Studio) is itself based on this IDE, so it also natively supports Kotlin.
  • Kotlin extensions also exist for the main Java IDEs (Eclipse and Netbeans), just like for Maven or Gradle build software.
  • Kotlin is known as being based on the Java Virtual Machine (JVM), but you can also compile it to JavaScript or Native for building code that can run on iOS.
  • On the framework side, Spring is beginning to go down the Kolin path.
  • Other developer tools such as Gradle, Vert.x, Spark Java andCodename One already support Kotlin.

Static Code Analysis Tools for Kotlin

After listing all of the above features and facts (which undoubtedly make Kotlin a safer, more concise and clearer programming language), does it make sense to check if we need static analysis tools for Kotlin?

The answer seems obvious since JetBrains itself has set up the first static code analysis tool (called ‘Ktlint’), well before the specialists like CAST and others.

Even though Kotlin offers the ability to reduce the number of code lines for same feature when compared to Java (which in turn means more reliable code with fewer bugs) mistakes will happen and simply reviewing pull requests will not be sufficient.

While ‘Ktlint’ seems to be currently focused on best programming practices and code style, some checks for code smell and security will be integrated in the future.

The Future with Kotlin

When comparing Kotlin to Java, we can say that:

  • Java isn't going anywhere, and it will be used for a long time until it gets completely phased out by Kotlin. While Kotlin comes with many advantages that Java doesn't have, it still has some shortcomings. It has already proved itself to several development communities, however, the transition will not be immediate and so obvious. The resistance to change is quite natural and especially when coming from the Java ecosystem that is fairly well equipped and has a clear and well-honed vision.
  • On other hand, Kotlin is here to stay, and it will continue its upward trend to be more developer-friendly. It is highly likely that it will be adopted by innovative projects for startups and will start to challenge Java to become champion.

In addition to Google and JetBrains, Amazon, Netflix, Pinterest, Uber, Foursquare, Trello, Capital One, Coursera, Basecamp and Corda have all implemented Kotlin's new features into their mobile apps.

  This report describes the effects of different industrial factors on  structural quality. Structural quality differed across technologies with COBOL  applications generally having the lowest densities of critical weaknesses,  while JAVA-EE had the highest densities. While structural quality differed  slightly across industry segments, there was almost no effect from whether the  application was in- or outsourced, or whether it was produced on- or off-shore.  Large variations in the densities in critical weaknesses across applications  suggested the major factors in structural quality are more related to  conditions specific to each application. CRASH Report 2020: CAST Research on  the Structural Condition of Critical Applications Report
Open source is part of almost every software capability we use today. At the  very least libraries, frameworks or databases that get used in mission critical  IT systems. In some cases entire systems being build on top of open source  foundations. Since we have been benchmarking IT software for years, we thought  we would set our sights on some of the most commonly used open source software  (OSS) projects. Software Intelligence Report <> Papers
Making sense of cloud transitions for financial and telecoms firms Cloud  migration 2.0: shifting priorities for application modernization in 2019  Research Report
Emna Gargouri
Emna Gargouri Principal Product Manager
Emna is a principal product manager at CAST, where she has innovated on system-level analysis and advanced technology capabilities for more than a decade.
Load more reviews
Thank you for the review! Your review must be approved first
New code

You've already submitted a review for this item