Sunday, March 31, 2019

Kotlin - Introduction

Greetings!

I'm going to talk about Kotlin as a Java developer. There are many languages looming and Kotlin is one of them. Since it is another JVM based language it will be easier to grasp.

Why another language?

Java is more than 20 years old mature, widely used language. The problem of being old is it lacks modern techniques. Even though Java adapted to functional programming with Java 8, I believe it is somewhat late for the game.
Considering modern day language features, difficulties they have faced using Java, Jetbrains created Kotlin. Being the one of the best IDE providers they know what they are doing. With InteliJ Idea Kotlin has the best IDE support with it.

What is Kotlin

Kotlin is a cross-platform, statically typed, general-purpose programming language with type inference. Kotlin is designed to interoperate fully with Java, and the JVM version of its standard library depends on the Java Class Library, but type inference allows its syntax to be more concise.
(Wikipedia)

Java disadvantages

  • Lack modern day programming features.
  • Disappointed/ forced exception handling.
  • Boilerplate codes.
  • Unnecessary getter and setters.

Kotlin advantages

  • Modern features.
  • 100% compatible with Java.
  • Interoperable, leverage existing libraries for the JVM, Android and browser.
  • Better exception handling (specially null pointers).
  • Concise, clean easy to read code.

Kotlin = Java + modern features

Hello World

Java
package com.slmanju.blog;

public class Hello {

    public static void main(String[] args) {
        System.out.println("Hello World");
    }

}

Kotlin
package com.slmanju.blog

fun main(args: Array<String>) {
    println("Hello World")
}

As you can see, Kotin is a beauty.



No comments:

Post a Comment