Kotlin by Example: Hello World

Our first program will print the classic "hello world" message. Here's the full source code.

fun main() {
    println("Hello world!")
}

As you can see, Kotlin is very concise; it does not require a lot of boilerplate.

To run the program, we first have to compile it.

$ kotlinc main.kt -include-runtime -d main.jar
$ ls
main.kt Main.jar

Then, we can run the resulting jar file.

$ java -jar Main.jar
Hello, world!