DEV Community

Ajeeb.K.P
Ajeeb.K.P

Posted on

Kotlin programming language - First impression

Introduction

Kotlin is a language with multiple domain support like Mobile-Cross-platform, Native, Data Science, Server-side, Web-development and Android (As per their website).

Some personal rant

And I was told, it has got a set wonderful language features (I'm only aware avoidance of null pointer exceptions. But I'm not even sure about the seriousness of null pointer exception, even though, I had more than 3 years of production experience with C# - which is having null, so null pointer exception. Anyone really interested, do comment below).

Installation

Since, I'm a Linux user. SDK is the tool to install kotlin. I think. Even, I had done this before :-) . Again, I had multiple options here, I was using brew already (Yeah, brew works well with Linux for most of apps). Also, I'm using snapd (https://snapcraft.io/snapd).

curl -s https://get.sdkman.io | bash

Install kotlin
sdk install kotlin

Hello World :-)

fun main(args: Array<String>) {
    println("Hello, World!")
}
Enter fullscreen mode Exit fullscreen mode

Let's build this. Yeah, we build a .jar, which can be run through java

kotlinc hello.kt -include-runtime -d hello.jar

Simple build for class is, which produces HelloKt.class and a META-INF/ folder.
kotlinc hello.kt

Run it

Since, we did include the runtime. It just need a java installation. I tested by removing kotlin from env (If you are interested in it, in short it's a simple ~/.bashrc trick to avoid loading sdk path into .env).
java -jar hello.jar

This prints a hello world message as per source code above. Since, I was checking Neutralinojs, together, I was interested in size of .jar file. It's around 1MB only.

Reference

https://kotlinlang.org/docs/tutorials/command-line.html

Top comments (0)