liveBook · Manning

Chapter 1: Kotlin: What and why

What you will learn in chapter 1 of Kotlin in Action, 2E

The chapter introduction characterizes Kotlin as a pragmatic successor to Java and shows how its uses have expanded across applications and platforms.

After this chapter you will be able to

Section by section

Introduction

The chapter introduction characterizes Kotlin as a pragmatic successor to Java and shows how its uses have expanded across applications and platforms.

Key terms: better Java, developer ergonomics, concise, safe, pragmatic, JVM, Android, server-side development, targets, cross-platform solutions

1.1 A taste of Kotlin

A small Kotlin example shows how a collection of people can be searched for the oldest person when an age may be missing.

Key terms: Person, maxBy, lambda expression, Elvis operator (?:), null

1.2 Kotlin’s primary traits

Introduces Kotlin’s static typing, combination of programming paradigms, and support for asynchronous code.

Key terms: statically typed, compile time, run time, multiparadigm, object-oriented, functional, abstractions, asynchronous code

1.2.1 Kotlin use cases: Android, server side, anywhere Java runs, and beyond

This section describes Kotlin’s broad range of uses, from Java-compatible environments to cross-platform applications.

Key terms: Android, server-side code, Java, Kotlin Multiplatform, cross-platform applications, browser

1.2.2 Static typing makes Kotlin performant, reliable, and maintainable

This section explains how Kotlin combines compile-time type checking with type inference, and what that means for reliability, performance, maintainability, and tooling.

Key terms: static typing, dynamically typed, compile time, run time, performance, reliability, maintainability, tool support, dynamic typing, type inference

1.2.3 Combining functional and object-oriented programming makes Kotlin safe and flexible

The section explains the ideas and benefits of functional programming and shows how Kotlin supports them alongside object-oriented programming.

Key terms: first-class functions, immutability, immutable objects, pure functions, side effects, functions as values, abstraction, lambda expressions, safe concurrency, immutable data structures

1.2.4 Concurrent and asynchronous code becomes natural and structured with coroutines

Introduces Kotlin coroutines as a way to write concurrent code that can wait without blocking threads, and illustrates concurrent work and structured cancellation.

Key terms: coroutines, suspendable computations, suspended, thread, async, await, structured concurrency, coroutine scope, lightweight abstraction, concurrent jobs

1.2.5 Kotlin can be used for any purpose: It’s free, open source, and open to contributions

This section explains that Kotlin is free and open source, describes how developers can contribute, and names open-source IDE options.

Key terms: open source, free to use for any purpose, Apache 2 license, code contributions, bug reports, feedback, Kotlin community, IntelliJ IDEA Community Edition, Android Studio, open source IDEs

1.3 Areas in which Kotlin is often used

Introduces server-side and Android development as two common uses of Kotlin and previews a discussion of why Kotlin fits each.

1.3.1 Powering backends: Server-side development with Kotlin

This section explains why Kotlin suits server-side development and illustrates its use with Spring Boot and Ktor.

Key terms: server-side programming, JVM, interoperability, Java code, type system, null values, NullPointerException, Spring Boot, first-class support, annotations

1.3.2 Mobile Development: Android is Kotlin first

This section explains why Android is Kotlin first and how Kotlin supports productive, reliable app development without sacrificing compatibility or performance.

Key terms: Kotlin first, Android, Jetpack, Jetpack Compose, if expressions, MessageDetails, NullPointerExceptions, Google Home, Java 8, runtime

1.3.3 Multiplatform: Sharing business logic and minimizing duplicate work on iOS, JVM, JS, and beyond

This section explains where Kotlin code can run and how Kotlin Multiplatform shares code without giving up platform-specific capabilities.

Key terms: JVM, JavaScript, Kotlin/Native, Kotlin/Wasm, WebAssembly, Kotlin Multiplatform, expect/actual, business logic, platform-specific implementation, lowest common denominator

1.4 The philosophy of Kotlin

This section introduces four qualities associated with Kotlin—pragmatism, concision, safety, and interoperability—to be explained in the following sections.

1.4.1 Kotlin is a pragmatic language

This section explains Kotlin’s pragmatism through its real-world focus, cautious feature design, flexibility in programming style, and integrated IDE support.

Key terms: pragmatic, real-world problems, developer feedback, proven, experimental state, stable, programming style, paradigm, idiomatic, tooling

1.4.2 Kotlin is concise

This section explains how Kotlin makes code concise without sacrificing readability, and why that matters when developers read and change existing code.

Key terms: concise, intent, boilerplate, getters, setters, type inference, standard library, lambdas, anonymous functions, overloading

1.4.3 Kotlin is safe

This section explains how Kotlin reduces common programming errors through JVM and type-system guarantees, nullability checks, and smart casts, while acknowledging that safety involves tradeoffs.

Key terms: safe, compiler, tradeoff, JVM, memory safety, static typing, type safety, val, immutable (data) classes, NullPointerException

1.4.4 Kotlin is interoperable

This section explains how Kotlin and Java code, libraries, and tools work together in a mixed-language project.

Key terms: interoperability, Java APIs, Kotlin classes and methods, collections, Java standard library classes, wrap or convert objects, Kotlin tooling, mixed-language projects, Find Usages, IntelliJ IDEA

1.5 Using the Kotlin tools

1.5.1 Setting up and running the Kotlin code

This section explains how to run Kotlin code in a browser or an IDE and how to use the Java-to-Kotlin converter when learning or migrating code.

Key terms: Kotlin online playground, IntelliJ IDEA, Android Studio, Kotlin plug-in, Java-to-Kotlin converter, Convert Java File to Kotlin File

1.5.2 Compiling Kotlin code

This section explains Kotlin’s compilation targets, the Kotlin/JVM build process, and the dependencies needed to run compiled code.

Key terms: compiled language, JVM bytecode, Dex bytecode, ART, native targets, JavaScript, .kt, Kotlin compiler, .class files, JVM

1.6 Summary

Where this is used later

Concepts explained in this chapter

Chapter 2: Kotlin basics →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.