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

Sentry mobile image

Tired of users complaining about slow app loading and janky UI?

Improve performance with key strategies like TTID/TTFD & app start analysis.

Read the blog post

Top comments (0)

Sentry mobile image

Mobile Vitals: A first step to Faster Apps

Slow startup times, UI hangs, and frozen frames frustrate users—but they’re also fixable. Mobile Vitals help you measure and understand these performance issues so you can optimize your app’s speed and responsiveness. Learn how to use them to reduce friction and improve user experience.

Read the guide

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay