fbpx
Get In Touch
1201 3rd Avenue Seattle, WA 98101, US
(HQ) Av. Punto Sur 31, Tlajomulco de Zúñiga, Jal 45050, MX
Carrera 11B # 99 - 25, Btá, 110221, CO
Let's talk
hello@inmediatum.com
Ph: +1 (650) 603 0883
Sales attention M - F 9am - 5pm (CT)
Get support
Careers
Endless inspiration and meaningful work
See open positions
Back

Kotlin for Android: A developer review 2019

Hey there fellow Android Developers! I’ve been an Android app developer with Inmediatum for quite a while now. Currently, I’m responsible for setting internal standards and guidelines for delivering native mobile applications on Android. However, another key component of my work is to improve development speed and quality. Managing tight deadlines is the most challenging part of Android app development. So today, I am sharing something new with you that promises to give us a productivity boost.  Here is my developer review of Kotlin for Android.

BACKGROUND

First, a little background about this general purpose language and why it’s is relevant today. Kotlin has been around since 2011, but it wasn’t until 2017 that Google made it an official language for Android. Since that time, its popularity has grown dramatically. This primarily due to many Android developers converting to Kotlin. As a general-purpose language, Kotlin is accelerating quicker than TypeScript, jumping a full eight spots since RedMonk’s last ranking update.

JetBrains created Kotlin, the same company behind Android Studio and IntelliJ IDEA (which is, in my opinion, one of the best IDE’s). Open source developers augmented the original version, making more open and flexible. One of the greatest things about Kotlin is that you can mix it with Java or vice versa. This unique ability allows for more interoperability and the capability to leverage existing libraries. This feature allows you to use it for current projects. You can learn more about Kotlin as you use it because you don’t have to rewrite existing code from scratch.

GET STARTED

Getting started with Kotlin is easier than you think. You only need to change a single setting on the creation of your new project in Android Studio, and you’ll be ready to go!

configure your Android project

Android Studio even has an option to convert to Kotlin your current Java projects.  The way to do that is just right clicking on any java file or package and find the option “Convert Java file to Kotlin file.”

convert Java file to Kotlin file

So far, I have tested it on a few applications. Everything seems to work pretty well. The only problem I experienced is with the projects that have several SDK’s implemented. Sometimes this becomes tricky to manage with the auto converter. However, it is easy to fix manually, so there is nothing to worry about.

In regards to SDK’s, I haven’t noticed any problems with the ones we usually use (Realm, Retrofit, Piccaso to mention a few of them) in our development process. However, more and more development companies nowadays have added Kotlin documentation and support for their SDK’s. Even if they haven’t, you don’t need to worry. In most of the cases, it’s really easy to transform the code from Java to Kotlin by yourself.

Nevertheless, you are not alone in this task. Android Studio helps you with that too. When pasting some Java code in a Kotlin file, Android Studio automatically converts that code.

THE JOURNEY

Here there are a couple of examples of Java vs. Kotlin so you can see the difference between them. This is just the tip of the iceberg, meaning there is a huge amount of material to learn from.

Data classes://JAVA
public class User {

private String name;
private String lastname;
private int age;

public User(String name, String lastname, int age) {
this.name = name;
this.lastname = lastname;
this.age = age;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getLastname() {
return lastname;
}

public void setLastname(String lastname) {
this.lastname = lastname;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}
}//KOTLIN
data class User( var name: String, var lastname: String, var age: Int)Functional support (Lambdas)://JAVA (Lambdas are supported on Java 8)
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

}
});//KOTLIN
view.setOnClickListener { }

CONCLUSION

Finally, here’s a link to the Kotlin official page where you can see a comparison against Java. It has been great sharing my Kotlin experience with you. I hope that my story helps you discover something new.  I am looking forward to your comments or questions.

Talk with Mobile Solution Experts

Discuss your ideas, questions, and concerns. Get answers specific to your needs.

[pofo_popup pofo_popup_type=”popup-form-1″ pofo_popup_preview_image=”popup-form-1″ pofo_contact_forms_shortcode=”22152″ pofo_popup_form_id=”1551116660″ pofo_popup_button_title=”Schedule Call” pofo_button_bg_color=”#eeee22″ pofo_button_text_color=”#000000″ pofo_button_hover_text_color=”#000000″ pofo_button_hover_bg_color=”#ffffff”][/pofo_popup]
Eduardo Rodriguez
Eduardo Rodriguez

We use cookies to give you the best experience. Cookie Policy