Another programming language!

During the last year while searching and exploring code examples of Android’s new technologies like Jet pack architecture components our team noticed that more and more code on the git hub is posted only in Kotlin – the new programming language for Android platform. And that raised a question in our team, is this new kid on the block something that can speed up our app development even more and we should start to prepare for another transition? And as usually we started to explore and see what benefits the new language can bring. But for me all this recalled my own experience with programming languages and how I was switching between different languages.

My first encounter with programming happened at high school and the first language I learned was BASIC. The friendship with BASIC lasted only a year. When I started to study at university I switched to Pascal. Yes, that was quite long time ago. At that time most of the software I was producing was dealing with mathematics and were command line utilities. I didn’t see a much difference between those two languages except that now in Pascal along the variables I had to declare their types. The course at university was organised so that students had to start with some high level language and gradually switching to C/C++. So far in the length of time I was switching from simple to more complex languages, and at that point of time it didn’t seem that switching to more complex language would ease the programming process, on the contrary the C/C++ comparing with BASIC made it harder to write software that solve mathematical problems. And that was the first time when I learned about the Programming domain. C/C++ gave me the ability to write software for almost any domain. But at the same time for some tasks more high level languages were preferable. After C/C++ followed SQL and Java, then C# and JavaScript. When I switched from C++ to Java the same task could take 10-25% less coding. Now the operations with text were easier and all pointers were gone. When I learned C# and that was the time when Microsoft released C# version 2.0, but Oracle had Java 1.5 I noticed in cases where callbacks and events where used in C# I could type 5-10% less code. But this increase in productivity was only in certain programming domains, like Windows applications. In other areas like embedded systems or OS C was still the main option, and the arise of new languages didn’t really affect those fields. The main conclusion I made for myself was that if a new language emerges, then most likely it speeds up development only in certain domain.

And what about Kotlin? The creators of Kotlin JetBrains claim that replacing Java with Kotlin will allow developers be more productive. After playing with Kotlin little bit and converting some existing Android classes into Kotlin we saw that it could really be the case. Then we looked at oficial Kotlin’s documentation where Kotlin is compared with Java and although some of the features we are really missing in Java like Data classes, Null-safety and Extensions we didn’t really see anything groundbreaking. And we were about to put Kotlin aside for this project since :

  • our team doesn’t feel yet so comfortable with Kotlin that we could produce code that is easy readable and follow best practices. To master the language requires time.
  • The productivity we would gain would not outweigh the time we would spent on learning the new language

We assumed if we want to switch to the new language we have to convert the whole application code base to the new language and keep coding in Kotlin, but then we noticed this tutorial saying that we can mix Java and Kotlin in one project. And we saw this as a good opportunity some of the files write in Kotline. And one of the first candidates for Kotlin we chose entities and DTO. It requires to learn very few new syntax and classes can be made much smaller thanks to getting rid of getters and setters. We decided to spend some time on learning Kotlin and once we learn the feature that really reduces the number of code lines and brings something valuable in code comparing with Java we will write that peace of code in Kotlin. In such way we hope we can keep the same development speed while learning new language and at some point of time start to reduce the development time comparing with Java. It worked well in time when I switched from C/C++ to Java and now it looks like it is time to switch from Java to Kotlin.

http://fitradar.me/

Leave a Reply