The beginnings of coding. Is it worth placing your bets on Kotlin?

Comarch programmer works at the computer.

As you well know, the IT world hates status quo. New languages, technologies, concepts are created every day. Something that was once used and forgotten returns like a boomerang under a slightly different name. You can observe this trend in the JVMa (Java Virtual Machine) for instance. Another example is Kotlin - a relatively young coding language which - little by little - is losing its hipster label and placing itself as a commercially viable solution. Is Kotlin something a new programmer should learn? What are its pros and where to find more information about it?

To help find answers to these questions we’ve talked to Wojciech Franczyk, an IoT Software Developer, whose adventure with Comarch started 7 years ago.

In 2017 at the I/O conference Google announced that Kotlin would be used as a support language to create Android applications. Since then, the language popularity has grown tremendously. What is it that has brought Kotlin so many fans?

New coding languages are created every day and many of them try to fill a gap or improve certain elements in code writing. Companies, however, tend to be sceptical about investing their time and money in technologies that are not widely spread on the market. A consequent lack of interest may stop any further development of the language, and the company which has placed its bet on it might be forced to either hire from a narrow group of specialists or invest into an expensive technology change.  

It wasn’t until 2016 that Kotlin was released in a fully stable version and even though there had already been some talk about it, it was the support of Google - a true giant of the industry - that gave it a warranty of further support and development. In 2019 Google announced that Kotlin is going to be its official language for Android apps development, which only confirmed that the technology had “taken root.

What are, then, some of Kotlin advantages?

First of all, Kotlin is a language that was created based on many years of Java programmers’ experience and is frequently presented as its substitute. Its authors have paid close attention to all the aspects of Java that were troublesome for coders, issues that made writing a correct and safe code more difficult or added to Java being perceived as an obsolete language. 

Kotlin code is more compact, yet at the same time it communicates the coder’s intentions better (with the use of convenient mechanisms that make you declare clearly what you want to do). The language construction helps you avoid logical errors and improve the code readability.

From what you say, Kotlin seems like a friendly language. Yet, I know for a fact that some programmers are sceptical about using it, arguing that “it is too new”. How would you encourage them to give Kotlin a chance?

The language designers have made a clear declaration of what Kotlin is and what it isn’t. In its basic form, i.e. as a JVM based language, Kotlin can be compiled with JavaScript and the native code - it is meant as a full substitute to Java. This means that, in spite of the language being rather new, from the functional point of view it doesn’t differ that much from Java 8. All the main concepts and paradigms are very similar, yet Kotlin makes it much easier to use them correctly. 

Most of Java programmers are able to start coding in Kotlin in less than a week. The languages are fully compatible and can use each other’s code. There are generators translating the code in both ways, which - even in case of a failure - will allow you to quickly return to Java. 

Kotlin entry threshold is very low, and the advantages are many. Given the current state of the language, there is absolutely no reason to not give it a try.

Contrary to the common opinion, it seems that Kotlin is not only for Android, is it? Where else can it be used?

Before its appearance in Android, Java had been used mainly in the backend system programming and it still remains among the most common choices there. From our experience I can say that wherever you can use Java, you can also use Kotlin and benefit fully from its advantages. Our Comarch team uses it with great success in one of our projects and it has allowed us to reduce the code by over a half on about 15 microservices

Kotlin is the highest class language for creating Android apps and has already overtaken Java in this aspect. Do you think it is the end, or the beginning of a major change?

The mere fact of gaining a big market share and creating a real alternative for Java and other JVM languages has been a huge success. I personally see it as the end of a big change which is great news for a language that has already reached its full maturity, functionality and stability and has a clearly defined purpose.

Kotlin designers are very careful about adding new functionalities to it, especially when they are related to solving niche problems rather than common issues. Their policy is not to make the language any more complicated, which clearly shows that Kotlin has already gone through its stability period and is well mature. 

We’ve spoken a lot about the positive aspects of Kotlin. But is it the language one should choose when they are just starting to learn how to code? Kotlin is said not to be a good first language. Why is that? 

If you are planning a career in JVM languages, you must be aware of what happens below the implementation. No matter if your target language is Java, Kotlin, Sala, Groovy or some other JVM code, some of the concepts are the same and conditioned by the way the virtual machine works. Java may not be the most comfortable language to work with, but it teaches you all the mechanisms of coding and how to use them consciously. Other languages from the same family tend to hide these mechanisms, e.g. under key words.  

It doesn’t mean, though, that I consider Kotlin to be a bad first language. It is a perfectly good option as long as you don’t neglect the need to understand the concept of coding thoroughly. Kotlin allows you to start coding quickly and to obtain fast results, especially thanks to all the available tutorials and examples for Android - if this is the area you want to pick. If not, I’d suggest starting with Java, given the fact that in technologies different than the mobile ones, you tend to require lower level programming

If I already know how to code in Java, is it worth learning Kotlin?

As I mentioned before, Kotlin can do exactly the same things as Java, but is more comfortable to work with. The more advanced you are in Java, the more you’ll be able to appreciate the benefits of the new mechanisms that Kotlin provides.

What would you recommend people who want to learn Kotlin and train themselves in this language? 

No matter how advanced you are in other languages, I strongly recommend checking Kotlin’s official documentation, i.e.  Language Guide and Tutorials. For someone who is already familiar with the basics of the language, Kotlin Koans looks like a great tool to test your knowledge and to better understand the whole concept. 

I am not a fan of taking “a Kotlin course” and I much more recommend learning through your own projects or through examples of bigger projects. 

Add comment

      e-mail address will not be published

            Most read from this category