Introduction to Android using Kotlin

Introduction to Android using Kotlin

Android development using Kotlin

As we know Android has been in a market for long time, and it is one of the widely used OS(Operating System) for smart phones. In this blog post I am going to explain advantages of Android and then we will go into technical parts to understand how we can use Kotlin for implementing apps the better way.

In the Google I/O’17 Google has announced that they are going to officially support Kotlin as primary language for developing Android apps. There are many advantages for using Kotlin over Java if you are starting to develop android apps or whether you are an experienced developer.

Android is a king of operating systems in the market right now. It has market share of smartphones more than 80% all over the world as pointed out by Quartz Media article. So if anyone want to make huge impact with their app idea the best way is to go Android first. With open-source, easy language support, good Google documentation and many more advantages Android can definitely be a first choice for entrepreneurs and early stage developers.

For newbie or an experienced developer there is official support of two programming languages, Java and Kotlin(recently announced). Java has been used for developing android apps for a long time and it is still in use by many developers around the world. Google will continue to provide support for Java for some amount of time, but the are shifting all of their existing projects on Kotlin because of many language advantages such as easy language understanding, less boilerplate coding, Interchangeability with Java, easy learning curve and many more.

A basic object in java would look like this:

User.java

public class User {
    private String firstName, lastName;
    public String getFirstName() { 
        return firstName; 
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() { 
        return lastName; 
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
}

The same in Kotlin will look like,

User.kt

class User {
    var firstName: String? = null
    var lastName: String? = null
}

Things to notice:

  1. No getter/setter methods
  2. No need to give specific data-types
  3. No semicolons, YAY! 🙂
  4. Easy implementation
  5. Null safety

Conclusion:

We have just what Kotlin offers. For those interested in further reading and learning more, check:

To sum up, Kotlin offers you the ability to save time when writing native Android apps by using a concise syntax. It is still a new programming language, but in my opinion, it is now stable enough to be used for building android apps.

Author: Pawan Kumar

Leave a Reply

Close Menu
%d bloggers like this:
Skip to toolbar