main banner

Development

Kotlin: All you need to know before giving it a try!

The last Google I/0 2017 had a lot of surprises for developers. One of the most exciting topics was about the support that Kotlin is going to receive by Google. The word Kotlin sounds strange and you may think it is someone’s name, a tool, a type of food or a place. 

Kotlin example

What is Kotlin?

Kotlin is an open source language developed by JetBrains, the company behind IntelliJ IDEA which Android Studio IDE is based. This language was created with JAVA developers in mind.

 

What are the advantages of the language?

 

Kotlin code

It’s more expressive: this is one of its most important qualities. You can write and create more with less code.


It’s safer: Kotlin is null safe because this language gives us the opportunity to avoid NullPointerExceptions easilier.


It’s reliable: basically a mature language  object oriented language. It was introduced in 2011, which means it had already gone through a number of Beta and Alpha versions before the first release (1.0)


It makes use of extension functions: This means we can extend any class with new features even if we don’t have access to the source code.


It’s highly interoperable: You can continue using most libraries and code written in JAVA, because the interoperability between both languages is good.


It’s very intuitive and easy to learn for JAVA developers. The learning curve is less for Java Devs because Kotlin has an intuitive syntax similar to Java. Of course, Java programmers should study a little bit the new methods, functions and the best practices of developing in Kotlin.


Semicolons are not necessary: While you can use them, semicolons are not necessary and it’s a good practice to avoid them (the IDE will warn you).

 


Kotlin  Disadvantages


Kotlin is a good new language to code android apps but it isn’t perfect. All developer have been giving their feedbacks since it came to light and Google presented it as a new official language.


No namespaces

Kotlin keeps all function and properties as top level of files. It is a good feature but it can create a confusion by having a function with the same name inside the class and the library that is being imported.

The issue of Runtime Size

Due to standard library and runtime of Kotlin, your apk size will go up by extra 800 KB.  This may become a problem for apps with large size since users don’t download heavy apps.


Slow compilation

A small project could take more compilation time than Java.  I noticed performance is fine with any Java packages, but it is 10x slower in autocompletion, code analysis, typing, and compilation for the very small Kotlin package. This is simply unacceptable.

Small Support Community

Since it is new, very few people are using it, it could have some rare problems hence you have to solve yourself.

Conclusion

Kotlin is  described as "Java++" because it's a natural evolution of the language and can do the same things with less frustration.

This language has potential but please, do not abuse it. With great power comes great responsibility - Uncle Ben.  

Have a nice day!

 
Cristofer M

Cristofer was born in Balancán, Tabasco, México. He has a Bachelor's degree in Computer Engineering and certification in Java. When he is not working, he plays basketball, runs, goes to the gym and loves camping on the mountain and visit inusual places.

Articles