C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » Kotlin

Introduction to Kotlin programming language

This article is related to a new language Kotlin. In this article I will discuss all the basics of the language.
Submitted by Aman Gautam, on November 25, 2017

Kotlin was invented by a software company JetBrains. This project is open Source and was started in 2010, But it was first released in 2016 as Kotlin v1.0.

Kotlin is statically typed Language means type checking is done at compile time. It runs on JVM (Java virtual machine) and requires less code to do the specific task as compared to java. Its code is more expressive than java and supports more feature than java like operator overloading (absent in java), lambda expressions etc.

We can develop Java Applications, Android Applications, Web Applications and native applications using Kotlin. So we can say it is a multiplatform Language.

Kotlin is not the replacement of java. Kotlin is interoperable with Java means we can use our existing Java code with Kotlin and Kotlin code with java.

In Google I/O 2017, Google has officially announced Kotlin as its official Android development language.

Features of Kotlin

  1. First of all the main point to notice is that Kotlin is completely open source language.
  2. Interoperable with java
  3. Concise
  4. Expressive
  5. Easy to learn → Similar syntax to existing language (like java)
  6. Type Inference → need not to provide data type for variables, use var/val instead, it can automatically infer data types.
    var a=5    //inferred as int
    var s="Aman"  //inferred as String            
    
  7. Operator overloading etc.
  8. Null Safety → to incur null pointer Exception (java)

The Kotlin programs can be compile and run in 'IntelliJ Idea' compiler (By JetBrains) includingeclipse (need plugin), NetBeans (need plugin). Kotlin files have ".kt" extension.

First Kotlin program

//first.kt

fun main (args : Array<String>)  // array arg of String type
{
     print("Hello");
}

Output

Hello

This is simple Kotlin program. In this, there is a main function which takes an array of String type as argument to provide command line input. Then there is print () function to print "Hello". There is no need for semicolon (;) to complete a statement in Kotlin.

Concluding that Kotlin is a powerful language with great features and is getting brighter and better continuously.









COMMENTS