DEV Community

Ajeeb.K.P
Ajeeb.K.P

Posted on

3 1

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

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more