Kotlin

A concise, modern language for Android apps that runs on the JVM.

Kotlin is Google's recommended language for Android development. It runs on the JVM and works with existing Java libraries, while adding concise syntax, null safety in the type system and coroutines for async work.

  • Intermediate
  • 8 lessons
Not started yet
Start lesson 1

Lessons

  1. Hello, KotlinWrite and run your first Kotlin program and learn val, var and type inference. Kotlin needs less setup code than Java: main does not need a class and semicolons are optional.
  2. Null SafetyLearn how Kotlin handles null. String and String? are different types, so the compiler can stop you from writing code that would throw a NullPointerException.
  3. Functions, when & ExpressionsLearn how to write functions, use default and named arguments, and branch with if and when. In Kotlin both if and when return values, which keeps many functions short.
  4. Classes & Data ClassesLearn classes, interfaces and data classes. A data class gives you equals, hashCode, toString and copy from a single line, so you can model data with very little code.
  5. Collections & LambdasLearn lists, maps and lambdas, and how functions like filter, map, sumOf and groupBy replace many hand-written loops. This style is common in Android code.
  6. Coroutines and Async CodeLearn coroutines, Kotlin's way of doing slow work such as network calls without freezing the app. Asynchronous code written with coroutines reads like ordinary step-by-step code.
  7. Your First Android ScreenBuild a simple counter app with Jetpack Compose, Android's UI toolkit. You describe the screen with Kotlin functions and it redraws when state changes.
  8. Kotlin CheatsheetNull safety, data classes, collections, and coroutines on one page.

Install it on your own computer

For Android apps, install Android Studio, which includes everything you need. To learn just the language, install the Kotlin compiler (it runs anywhere Java does) or use play.kotlinlang.org in your browser with no install.

Bash
# Fastest: https://play.kotlinlang.org (no install)

# For Android development:
winget install Google.AndroidStudio

# Just the compiler (needs a JDK):
winget install EclipseAdoptium.Temurin.21.JDK
# then via SDKMAN in WSL/Git Bash, or scoop install kotlin

kotlinc hello.kt -include-runtime -d hello.jar
java -jar hello.jar

What people build with Kotlin

Learn the basics first, then pick up these tools when a project needs them.

Practical uses

  • Develop modern Android apps
  • Build concise JVM backend services
  • Share code across mobile platforms
  • Create Gradle build logic and scripting tools

Projects to try

  1. Android notes app
  2. Ktor JSON API
  3. Compose desktop timer
  4. Multiplatform reading tracker

Common tools and packages

Jetpack ComposeKtorKotlin Coroutineskotlinx.serializationExposedKotestDetektKoin

Well-known software

Pinterest AndroidTrello AndroidGradle Kotlin DSLIntelliJ platform featuresCash AppDuolingo Android