Introduction
Kotlin is a modern, statically typed language that runs on the Java Virtual Machine — fully interoperable with Java, but with null safety, less boilerplate, and a lot of small conveniences Java never had.
What Kotlin is
Kotlin is a statically typed language that runs on the Java Virtual Machine — it compiles down to the same bytecode Java does, which means it can call Java libraries directly and Java code can call Kotlin back. Google made it the preferred language for Android development in 2019, but it runs anywhere the JVM does: servers, desktop tools, command-line scripts. JetBrains, the company behind IntelliJ IDEA, created it specifically to fix things about Java that had been awkward for a decade — verbose boilerplate, no built-in null safety, no way to write a quick script without a full class wrapper.
Your first Kotlin program
Unlike Java, Kotlin doesn't require every piece of code to live inside a class. A fun main() at the top level of a file is a complete, runnable program:
fun main() {
println("Hello, Kotlin!")
}
Hello, Kotlin!
Compile and run it with the Kotlin command-line compiler (kotlinc main.kt -include-runtime -d main.jar, then java -jar main.jar), or paste it directly into the official Kotlin Playground in a browser — no local install needed to experiment.
Semicolons are optional
Kotlin doesn't require a semicolon at the end of a statement — the compiler infers the end of a statement from the line break in almost every case:
fun main() {
val a = 5
val b = 10
println(a + b)
}
15
You can put multiple statements on one line separated by semicolons, but the idiomatic style — and what every formatter defaults to — is one statement per line with no trailing semicolon.