Stage 3
Stage 3: Advanced
✅ Complete. Every part below has its full lesson (
README.md),examples/,exercises.mdandsolutions/, and every program was compiled and run on the toolchain recorded in../TOOLING.md(kotlinc 2.4.21, JDK 21) — see each part's README for real, captured output.
Goal: Write generic, concurrent, and packaged Kotlin — the kind of code that shows up in a real library or service, not just a script. Time: about 4 weeks at 1–1.5 hours a day (~29 hours including the project) · Level: finished Stage 2, including Gradle (Part 11) and Java interop (Part 12).
Prerequisites
- Stage 2 complete. Coroutines (Part 14) specifically assume you're already fluent with
lambdas and higher-order functions from Part 10 — see
../DESIGN-NOTES.mdfor why coroutines sit after generics and functional Kotlin, not before. - A working Gradle setup from Stage 2, Part 11 — Stage 3 keeps using it rather than going back
to loose
.ktfiles.
Parts in this stage
| Part | Topic | Learning outcomes | You will build | Time |
|---|---|---|---|---|
| 13 | Generics and advanced typing | Generic classes/functions, variance (in/out/where), reified type parameters in inline functions, type aliases, designing an API around a sealed result hierarchy |
A generic, type-safe cache/repository | ~5 h |
| 14 | Coroutines and structured concurrency | suspend functions, coroutine builders (launch, async), Dispatchers, structured concurrency and cancellation, a first look at Flow, how this compares to Stage-1-level sequential code and to raw JVM threads |
A concurrent task runner that replaces a sequential loop with concurrent coroutines | ~7 h |
| 15 | Kotlin internals | inline/noinline/crossinline functions and why reified needs inline, delegated properties (by lazy, custom delegates), annotations, a light look at reflection, how suspend functions actually desugar (continuation-passing, at a conceptual level) |
A custom property delegate, e.g. a "logged" property that prints on every write | ~5 h |
| 16 | Packaging and modern Kotlin | Multi-module Gradle projects, publishing a library (conceptually — Maven coordinates, what a .jar/.klib is), building a CLI tool (parsing args, or a CLI library), a conservative look at what's new across recent Kotlin 2.x releases (flag for verification against the actual installed compiler before publishing — see ../TOOLING.md) |
Package and publish your own CLI tool as a runnable artifact | ~4 h |
| 🏁 | Project: Concurrent CLI capstone | A coroutine-based CLI tool (exact shape finalized in the content wave), packaged using Part 16 | ~8 h | — |
How every part will be organised (once content lands)
Same layout as Stage 1 and 2 (README.md, examples/, exercises.md, solutions/); every
part's examples/ folder continues to be a Gradle project, same as Stage 2 from Part 11 onward.
How the code will run
Continues the Stage 2 Gradle project pattern (./gradlew build/test/run). Coroutines (Part
14) require the kotlinx-coroutines-core dependency — the content wave must verify that
dependency resolves and the examples actually run concurrently (not just read as if they do)
before publishing.
Stage 3 checklist (once content lands)
- Parts 13–16 done, with every exercise attempted
- Concurrent CLI capstone built, packaged, and run as a standalone artifact
- Comfortable explaining structured concurrency in your own words
Next: 🧠 Stage 4: DSA in Kotlin