AnyCompiler

Introduction to Kotlin

Kotlin is a compiled, statically typed language that runs on the JVM, fully interoperable with Java — you can call Java code from Kotlin and Kotlin code from Java in the same project. It was created at JetBrains specifically to fix the things Java programmers complained about most: too much boilerplate, and no protection against null references at the type level.

That second point is Kotlin's signature feature: every type is either nullable or not, and the compiler enforces the difference. A plain String can never hold null; only a String? can, and the compiler forces you to handle that possibility before you can use it. Java's NullPointerException — famously called its 'billion-dollar mistake' — becomes a compile error in Kotlin instead of a runtime crash.

A quick preview

Here's a real Kotlin program, executed for real on this page's own compiler — not a mockup:

fun main() {
    println("Kotlin: concise, statically typed, and runs on the JVM alongside Java.")
}
Output
Kotlin: concise, statically typed, and runs on the JVM alongside Java.

No class, no public static void — just a function. The next lesson runs your first full program and explains exactly what's happening.

Practice exercise

Declare a val named version set to 13, then print "Kotlin version: " followed by version.