Language basics
27 steps in 9 sets of Kotlin.
Kotlin is JetBrains' pragmatic answer to Java: a statically typed language for the JVM (and beyond) that keeps the platform and drops the ceremony. Since Google made it the preferred language for Android in 2019 it has become the default way tens of thousands of teams write for the phone in your pocket, while Spring and server-side shops adopted it for the same reason the IDE company built it — less boilerplate, null safety in the type system, and full interop with every Java library ever shipped.
This tour covers the core in typing-sized pieces: val and var, string templates, if and when as expressions, ranges, functions with defaults and named arguments, lambdas and collection chains, data classes and sealed hierarchies, the null-safety operators, scope functions, destructuring, operator and infix functions, generics, and delegation with by. The Encore is three complete programs — a word-frequency chart, a grade report, and a temperature summary — each one exercising what the sets taught.
Values
- The program shapeThe smallest Kotlin program: no class, no package line, just main.
- Values and variablesval for bindings that never move, var for the few that must.
- String templatesInterpolation with $, expressions with braces, and multiline raw strings.
Control flow
- if is an expressionKotlin has no ternary because if itself returns a value.
- whenThe switch that matches ranges, lists of values, and bare conditions.
- Ranges and loopsRanges are values, and for iterates anything that provides one.
Functions
- Defaults and named argumentsSignatures carry the defaults, so call sites stay short.
- LambdasFunction values in braces, with it standing in for a lone parameter.
- Extension functionsAdd member-looking functions to types you do not own.
Collections
- Lists and mapsRead-only by default, mutable by request.
- Collection chainsfilter, map and friends read left to right and never mutate.
- Grouping and sortingOrder a list by any key, or bucket it by one.
Classes & objects
- Data classesOne keyword buys equals, hashCode, toString, copy and destructuring.
- Sealed hierarchiesA closed set of cases the compiler can check exhaustively.
- Objects and companionsSingletons with object, statics with companion object.
Null safety
- Nullable typesnull is in the type system: String? admits it, String never will.
- Smart castsPassing an is-check narrows the type for the rest of the branch.
- Nulls in collectionsParse messy input without a single try/catch.
Idioms
- Scope functionsapply, let and also: tiny blocks that keep configuration close.
- DestructuringUnpack pairs, list heads and map entries where they land.
- Operators and infixTeach + a new type, or let a function sit between its operands.
Generics & delegation
- GenericsType parameters picked at the call site, bounded where needed.
- Delegation with byForward a whole interface to a wrapped instance in one clause.
- Builders and joinToStringFormat collections without loops, build strings without concatenation.
Encore
- word_freq.ktA word-frequency table from a split, a tally map, and a two-key sort.
- grade_report.ktReport cards from a data class roster, a when ladder, and format strings.
- temp_stats.ktA week of temperatures: extremes, mean, a bar chart, and overnight swings.