Phase 1 · FoundationsModule 1~32 min read

Introduction to Kotlin

What Kotlin is, why it exists, how it runs, and writing your first program — the concise, modern language behind Android.

What you'll learn

Welcome to Kotlin — a modern, concise, and safe language that has become the go-to choice for Android and a favourite far beyond it. This first module builds your mental model: what Kotlin is, why it exists, where it runs, and how to write and run your first program.

By the end you'll be able to:

  • Explain what Kotlin is and why developers love it
  • Describe where Kotlin runs — the JVM, Android, and beyond
  • Understand how Kotlin compiles and runs
  • Set up your tools and use the REPL / Playground
  • Write, run, and dissect your first Kotlin program

What is Kotlin?

Kotlin is a modern, statically-typed programming language created by JetBrains (the makers of IntelliJ IDEA) and first released in 2016. It was designed to fix the pain points of Java while staying 100% interoperable with it. In 2019, Google made Kotlin its preferred language for Android.

Developers reach for Kotlin because it is:

  • Concise — dramatically less boilerplate than Java
  • Safe — its type system eliminates most null-pointer errors (Module 3)
  • Interoperable — use any Java library, mix Kotlin and Java freely
  • Modern & expressive — coroutines, data classes, and more, built in
Kotlin's simplicity

Java

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Kotlin

fun main() {
    println("Hello, World!")
}

Same result, far less ceremony — no class, no public static void, no semicolons. That conciseness is Kotlin's whole point.

Where Kotlin runs

Kotlin is remarkably versatile — the same language targets many platforms. Most commonly it compiles to JVM bytecode (like Java), but it also compiles to native binaries and JavaScript:

Kotlin's reach

Android

The official language for Android — Google recommends Kotlin first.

Backend & Servers

Ktor, Spring Boot, and microservices on the JVM.

Multiplatform

Share code across Android, iOS, web, and desktop.

Anywhere Java runs

100% interoperable with Java and its huge ecosystem.

One language, many targets — all sharing the same clean syntax.

How Kotlin runs your code

On its most common target, the JVM, Kotlin works just like Java under the hood. The Kotlin compiler (kotlinc) turns your .kt source files into bytecode (.class files), which the Java Virtual Machine executes. This is exactly why Kotlin can use every Java library ever written — they end up as the same bytecode.

Key idea

Kotlin and Java compile to the same JVM bytecode. That's the secret behind their seamless interoperability — from the JVM's point of view, there's no difference.

Getting set up

Getting ready to code takes a few steps:

  1. Install a JDK (Java Development Kit, 17 or newer) — Kotlin runs on the JVM, so it needs one.
  2. Install an IDE — IntelliJ IDEA (Kotlin's home, made by the same company) or Android Studio for Android. Both bundle Kotlin.
  3. Experiment instantly with the online Kotlin Playground — no installation needed — or the REPL:
Kotlin REPL
>>> 2 + 3
res0: kotlin.Int = 5

>>> val name = "Sara"
>>> "Hi, $name"
res2: kotlin.String = Hi, Sara

Your first program: Hello, World!

By tradition, the first program prints "Hello, World!". In Kotlin it's beautifully short — press Run:

Main.kt
fun main() {
    println("Hello, World!")
}
Your first Kotlin program.

Let's make it greet you by name, using a string template — the $ drops a variable's value straight into the text:

Greet.kt
fun main() {
    val name = "Sara"
    println("Hello, $name!")   // string template
}

Anatomy of a Kotlin program

That tiny program has a few parts worth naming:

  • fun — the keyword that declares a function
  • main() — the special entry point where every Kotlin program starts
  • println(...) — a built-in function that prints a line of text
  • The curly braces { } group the function's body

Notice what's missing compared to Java: no class wrapping main, no public static void, and no semicolons at the end of lines. Kotlin keeps only what's essential.

Note

Unlike Python, Kotlin uses curly braces to group code, not indentation — but you should still indent consistently (4 spaces) for readability. And unlike Java, semicolons are optional and normally left out.

Recap & quick check

Key takeaways

  • Kotlin is a modern, concise, statically-typed language by JetBrains — Google's preferred language for Android.
  • Kotlin is 100% interoperable with Java because both compile to the same JVM bytecode.
  • It targets the JVM, Android, Native, and JS, and enables Kotlin Multiplatform.
  • A program starts at fun main(); println() prints text; string templates use $name.
  • Kotlin uses braces (not indentation) to group code, and semicolons are optional.

Quick check

1. Who created Kotlin, and what is it best known for?

2. Why can Kotlin use any Java library?

3. Where does a Kotlin program start?

4. How does Kotlin group blocks of code?

5. What does $name do inside a string?

Brilliant — you understand what Kotlin is and you've run your first program. Next up: Module 2 — Variables, Types & Basic Syntax.