Kotlin Standard Library Cookbook
Kotlin Standard Library Cookbook
Summary:
Introduction
The book "Kotlin Standard Library Cookbook" by Samuel Urbanowicz was published in 2018 and immediately attracted the attention of developers seeking to master the Kotlin standard library at a professional level. Unlike many textbooks that only superficially introduce the syntax, this collection of recipes offers practical solutions to real-world problems — from working with collections to asynchronous programming with coroutines. The book's volume is 296 pages, which is optimal for diving into the topic without unnecessary filler.
What the book is about
The book is structured as a set of independent recipes grouped into thematic chapters. Each recipe contains a problem statement, a ready-made solution in Kotlin, and a detailed explanation of how and why it works. The main topics covered include:
- Working with collections and sequences (Sequence, List, Set, Map);
- Functional primitives: closures, lambdas, higher-order functions;
- Data serialization and deserialization (JSON, XML);
- Asynchronous programming with coroutines (launch, async, Channel, Flow);
- Working with dates, time, and strings;
- Interoperability with Java and using Java libraries from Kotlin;
- Code testing and debugging.
Who this book is for
The book is aimed at developers already familiar with the basics of Kotlin (syntax, types, basic constructs) who want to deepen their knowledge specifically in the standard library. For beginners just starting to learn the language, the book may seem challenging — it's better to first complete an introductory course. However, for those who already write in Kotlin and want to write more concisely, faster, and more reliably, this collection will become a desktop reference.
What the reader will learn
After working through the book, the reader will be able to:
- Effectively use collections — choose the right collection type, apply functions like filter, map, flatMap, groupBy, and optimize call chains using Sequence.
- Work with nullable types — safely handle null using operators ?., ?:, let, apply, run.
- Write asynchronous code — create coroutines, manage their lifecycle, handle exceptions, use channels and Flow for streaming data.
- Serialize data — convert objects to and from JSON using libraries kotlinx.serialization, Gson, Jackson.
- Integrate with Java — call Java code from Kotlin, use annotations @JvmStatic, @JvmOverloads, work with Java collections.
- Test code — write unit tests with JUnit, MockK, test coroutines using runBlockingTest.
Strengths of the book
The first and foremost advantage is its practical focus. Each recipe solves a specific problem that a developer encounters in daily work. The second is its clear structure: the book is divided into 10 chapters, each dedicated to a separate area of the standard library. The third is the presence of "How it works" and "Additional" explanations, which help to understand not only the solution but also its alternatives. Finally, the example code is neat, well-formatted, and ready for use in real projects.
Special mention should be made of the chapter on coroutines — at the time of the book's release (2018), it was one of the first detailed publications on this topic. Although the coroutine API has changed slightly since then, the core concepts remain relevant.
Who it is recommended for
The book will be useful for:
- Android developers who want to write cleaner and more performant code in Kotlin;
- Backend developers using Kotlin for server applications (Ktor, Spring Boot);
- Developers transitioning from Java to Kotlin who want to master an idiomatic style;
- Anyone who wants to systematize their knowledge of the Kotlin standard library and learn to apply its capabilities.