Introduction to Kotlin
Learn what Kotlin is, who created it and why, its standout features, and write your first Kotlin program.
Introduction
Kotlin is a modern, statically typed programming language that runs on the Java Virtual Machine (JVM) and is fully interoperable with Java. It was designed to fix many of the pain points developers ran into with Java — verbose boilerplate, null pointer exceptions, and clunky syntax — while still letting you use every existing Java library and framework without friction.
This lesson introduces what Kotlin is, who created it and why, the features that make it stand out, and gives you your very first taste of actual Kotlin code.
- What Kotlin is and what kind of language it is (statically typed, JVM-based, interoperable with Java).
- Who created Kotlin at JetBrains, and the frustrations that led to it.
- The standout features that make Kotlin different from Java — especially null safety.
- How Kotlin relates to the JVM and to Java itself.
- What a minimal Kotlin program looks like.
What is Kotlin?
Kotlin is an open-source, statically typed programming language that targets the JVM (and, through additional compiler backends, JavaScript and native code). "Statically typed" means the type of every variable is known at compile time, which lets the compiler catch a large class of bugs before your program ever runs. Kotlin was designed from the start to be more concise than Java — many things that take several lines of Java can be written in one line of idiomatic Kotlin.
The single feature Kotlin is most known for is null safety: its type system distinguishes between types that can hold null (nullable types, written with a trailing `?`, such as `String?`) and types that cannot (non-nullable types, such as `String`). This moves an entire category of bugs — the infamous `NullPointerException` — from a runtime crash to a compile-time error in the vast majority of cases.
Who Created Kotlin, and Why
Kotlin was created by JetBrains, the software company behind IntelliJ IDEA and a family of other developer tools. JetBrains had a large Java codebase of its own and, like many teams working in Java at scale, grew frustrated with Java's verbosity and its lack of modern language conveniences. Rather than switching to an entirely different platform, JetBrains set out to build a new language that could compile to JVM bytecode, interoperate seamlessly with existing Java code, and fix the ergonomics Java was missing.
The language was first announced publicly in July 2011 at the JVM Language Summit, and was open-sourced under the Apache 2.0 license in 2012. After several years of development or refinement, Kotlin reached its stable 1.0 release in February 2016. The name "Kotlin" comes from Kotlin Island, located near St. Petersburg, Russia — where much of the JetBrains engineering team is based — following the tradition of naming programming languages after islands (as Java was named after the Indonesian island).
Key Features at a Glance
Null Safety
The type system distinguishes nullable from non-nullable types, catching most null pointer bugs at compile time.
Concise Syntax
Data classes, type inference, and expression-oriented constructs eliminate huge amounts of Java boilerplate.
100% Java Interop
Call Java code from Kotlin and Kotlin code from Java with no wrapper layer needed.
Coroutines
Lightweight, built-in support for asynchronous and concurrent code without callback hell.
Smart Casts
The compiler automatically casts a variable to a more specific type after a type check, no manual casting needed.
Multiplatform
Kotlin Multiplatform lets you share business logic across Android, iOS, backend, and web from a single codebase.
Kotlin and the JVM
Kotlin source files (`.kt`) compile down to the exact same JVM bytecode format that Java source files compile to. That single design decision is what makes Kotlin practical: it means Kotlin code runs anywhere the JVM runs, can use any existing Java library unmodified, and can be adopted file-by-file inside an existing Java project rather than requiring a full rewrite.
This interoperability runs in both directions. A Kotlin class can extend a Java class or implement a Java interface, and a Java class can call Kotlin functions as if they were ordinary Java methods. This is a major reason large companies with existing Java codebases — including Google itself for Android — were able to adopt Kotlin gradually instead of rewriting everything at once.
Your First Taste of Kotlin
No introduction to a language is complete without seeing actual code. Here is the smallest complete Kotlin program — one that prints a greeting to the screen.
fun main() { println("Hello, Kotlin!")}Click Run to see what this code prints.
Notice what is missing compared to Java: there is no wrapping `public class HelloWorld` and no `public static void main(String[] args)`. Kotlin does not require every piece of code to live inside a class, and `fun` is simply the keyword used to declare a function. You'll cover functions in full depth in a later lesson — for now, just notice how little ceremony is needed.
Where Kotlin Is Used Today
Kotlin's biggest breakthrough came in May 2017, when Google announced official first-class support for Kotlin on Android at Google I/O. In 2019, Google went a step further and made Kotlin its preferred language for Android app development, ahead of Java. Beyond mobile, Kotlin has also become a popular choice for backend development.
| Domain | How Kotlin Is Used |
|---|---|
| Android Development | Google's preferred language for Android apps since 2019, used alongside Jetpack Compose. |
| Backend / Server-Side | Frameworks like Spring Boot and Ktor let teams write concise, null-safe backend services. |
| Kotlin Multiplatform | Share business logic between Android, iOS, desktop, and web from one Kotlin codebase. |
| Scripting | Kotlin scripts (`.kts`) are used for build tooling, most notably Gradle build scripts. |
| Data & Tooling | JetBrains uses Kotlin extensively across its own IDE and developer-tooling products. |
Common Mistakes
- Assuming Kotlin is "just Android syntax" — it is a general-purpose language usable for backend, scripting, and multiplatform development too.
- Thinking Kotlin replaces the JVM — Kotlin compiles to the same JVM bytecode Java does; it is a language, not a separate runtime.
- Expecting to learn Kotlin from scratch if you already know Java — many concepts carry over directly, and framing it as "Java, but improved" helps it click faster.
- Skipping the null-safety concept early on — it is the single most important mental shift when coming from Java, and it shapes almost every later lesson.
Best Practices
- If you already know Java, actively look for the places Kotlin removes boilerplate — that contrast is the fastest way to learn.
- Get comfortable running small snippets early using the Kotlin Playground (play.kotlinlang.org) — no local setup required.
- Read error messages carefully; the Kotlin compiler's messages, especially around nullability, are usually specific and actionable.
- Bookmark kotlinlang.org — the official documentation is thorough, example-driven, and the authoritative source.
Frequently Asked Questions
No. Android is Kotlin's most famous use case, but it is a general-purpose language also used for backend services (Spring Boot, Ktor), scripting, desktop apps, and Kotlin Multiplatform projects that target iOS and web as well.
No, Kotlin can be learned as a first language. That said, if you already know Java, you will recognize many concepts immediately and move faster through the fundamentals.
Yes. Kotlin has been open source since 2012 and is developed by JetBrains under the Apache 2.0 license, with contributions from the broader community.
It means the compiler forces you to explicitly acknowledge when a value might be null before you use it, rather than letting a null slip through and crash the program later at runtime. You'll cover this in full depth in the Null Safety lesson.
Key Takeaways
- Kotlin is an open-source, statically typed language created by JetBrains that runs on the JVM.
- It was first announced in 2011 and reached its stable 1.0 release in February 2016, named after Kotlin Island near St. Petersburg.
- Kotlin is 100% interoperable with Java in both directions — call Java from Kotlin and Kotlin from Java freely.
- Its standout feature is null safety: the type system distinguishes nullable from non-nullable types.
- Google made Kotlin the preferred language for Android development in 2019.
Summary
You now know what Kotlin is, who built it, why it exists, and what makes it stand out from Java. You have also seen your very first line of runnable Kotlin code. Next, you will dig deeper into Kotlin's history — from its origins at JetBrains through its rise as Android's preferred language.