Leanpub Header

Skip to main content

Practical Kotlin Deep Dive Course

Unlocking the 'How' and 'Why' behind Kotlin fundamentals and internal mechanisms.

Takes you from "how to use Kotlin" into "how Kotlin really works," revealing internal implementations, demystifying bytecode and compiler behavior, and uncovering the internals that shape the language. With 158 interactive assessments to test and reinforce your understanding, this course doesn't just show you why everything is the way it is, it challenges you to prove you've mastered it.

 ISBN: 979-8243872744 

Minimum price

$129.00

$149.00

You pay

$149.00

Author earns

$119.20
$

...Or Buy With Credits!

You can get credits with a paid monthly or annual Reader Membership, or you can buy them here.
PDF
EPUB
WEB
125,841Words
About

About

About the Course

Practical Kotlin Deep Dive Course unpacks the "how" and "why" behind Kotlin from core language fundamentals and internal mechanisms to the design of its APIs. It spans Kotlin basics, the standard library, coroutines, kotlinx libraries, compiler internals, and Kotlin Multiplatform.

This course goes beyond surface-level APIs by diving into Kotlin's internals: it walks through real Kotlin function implementations, demystifies generated bytecode, and explains how the Kotlin compiler interprets the language. It also draws directly from KEEP proposals, JetBrains YouTrack discussions, and compiler source code to connect concepts to their origins and design rationale. The result is an approach that helps you reason about Kotlin instead of simply memorizing APIs.

This progression ensures that you understand not only how to use Kotlin effectively, but also why the language was designed the way it is, giving you insights that translate directly into better code.

For continuous growth, the course includes curated references and additional resources so you can keep exploring beyond its modules. Complex or less common terms are explained with accessible context, making advanced material approachable for newcomers while offering fresh insights to seasoned developers.

The advanced sections go beneath the surface, covering internal structures of Kotlin functions, algorithms, how the Kotlin compiler behaves, and implementation details that matter in real-world projects. Senior engineers will find thought-provoking details to sharpen their expertise, while mid-level developers gain insights for leveling up their Kotlin knowledge and building a stronger analytical mindset.

Unlike passive reading, this course challenges you to actively engage with the material through 158 interactive assessments: coding exercises that test your understanding, quizzes that reinforce core concepts, and advanced challenges that analyze real code scenarios. Each chapter concludes with a comprehensive recap of key terms and concepts, followed by assessments designed to solidify your knowledge before moving forward.

Whether you're optimizing performance-critical code, handling complex coroutine tasks, exploring multiplatform development, or writing your own compiler plugins, this course challenges you to go beyond tutorials. Learn to reason about language design, understand internal mechanisms, and approach Kotlin development with clarity, curiosity, and confidence.

Upon successfully completing this course, you will receive a Kotlin Deep Dive Certificate, a digital certificate that validates your comprehensive understanding of Kotlin. This certificate includes:

  • Official Recognition: A professionally designed digital certificate image.
  • Personal Signature: Signed by Jaewoong Eum (skydoves), Google Developer Expert for Android, Kotlin, and Firebase.
  • Completion Verification: Demonstrates that you have passed all quizzes and exercises throughout the course.

This course has been built top of the same content of the Practical Kotlin Deep Dive book, with the same ISBN number (979-8243872744)

Share this course

Instructor

About the Instructor

Jaewoong

The author of this book, Jaewoong Eum (known as skydoves), is a Google Developer Expert (GDE) for Android, Kotlin, and Firebase, an open-source developer created over 80+ open-source libraries and projects, collectively amassing 15+ million downloads annually. The author is also the founder of Dove Letter—a subscription-based repository dedicated to sharing, learning, and discussing Android and Kotlin development.

Material

Course Material

  • Introduction

  • Preface

  • Who This Course Is For

  • What This Course Covers

  • How to Use This Course

  • Course Structure

  • Quizzes and Exercises

  • Earning Your Certificate

  • Staying Current

  • [Chapter 1] Kotlin Language

  • Chapter Overview

  • The Type System

  • Null Safety in Kotlin

  • The Core Principle: A Tale of Two Types

  • 1. Non-Nullable Types

  • 2. Nullable Types

  • Safely Working with Nullable Types

  • 1. The Safe Call Operator (?.)

  • 2. The Elvis Operator (?:)

  • 3. The Not-Null Assertion Operator (!!)

  • 4. Smart Casts and Safe Casts

  • Interoperability with Java and Platform Types

  • Summary

  • The Any, Unit, and Nothing Types

  • Any: The Root of the Type Hierarchy

  • Unit: Representing the Absence of a Meaningful Value

  • Nothing: The Type That Has No Values

  • 1. For Functions That Never Return

  • 2. As the Bottom of the Type Hierarchy

  • Summary

  • Structural and Referential Equality

  • Summary

  • šŸ’” Pro Tips for Mastery: How does structural equality (==) work internally?

  • The First Line of Defense: The Safe Call Operator (?.)

  • The Null-Handling Bridge: The Elvis Operator (?:)

  • The Final Verdict: The Referential Null Check (b === null)

  • Why This Design is Great

  • Bonus: The null + null Operation

  • Why This is Important

  • Summary

  • Properties and Visibility

  • Variables: var vs val

  • Summary

  • šŸ’” Pro Tips for Mastery: Why is the val variable and property read-only and not immutable?

  • Summary

  • Visibility Modifiers

  • Public

  • Private

  • Protected

  • Internal

  • Summary

  • šŸ’” Pro Tips for Mastery: How internal visibility modifier is compiled to Java Bytecode?

  • The init Block

  • Key Features of the init Block

  • Example of the init Block

  • Benefits of Using the init Block

  • Important Considerations

  • Summary

  • šŸ’” Pro Tips for Mastery: What are the downsides of init block?

  • 1. Unintended Side Effects

  • 2. Limited Flexibility

  • 3. Tightly Coupled Initialization Logic

  • 4. Performance Impact

  • 5. Challenging Debugging

  • Best Practices to Mitigate Downsides

  • Summary

  • šŸ’” Pro Tips for Mastery: How init block is compiled to Java Bytecode?

  • Backing Fields and Backing Properties

  • Backing Fields

  • Backing Properties

  • Key Differences

  • Summary

  • Data and Sealed Classes

  • Data Classes

  • Key Characteristics

  • Key Features of Data Classes

  • Differences Between Data Class and Regular Class

  • Summary

  • šŸ’” Pro Tips for Mastery: Data class inheritance

  • šŸ’” Pro Tips for Mastery: The visibility of the copy function of data classes

  • šŸ’” Pro Tips for Mastery: Unveiling a data class in Java Bytecode

  • Conclusion

  • Sealed Classes

  • Key Characteristics of Sealed Classes

  • When to Use Sealed Classes

  • šŸ’” Pro Tips for Mastery: Sealed class inheritance

  • šŸ’” Pro Tips for Mastery: What are the differences between sealed classes and sealed interfaces?

  • Inheritance

  • Flexibility and Use Cases

  • Sealed Class Example

  • Sealed Interface Example

  • Sealed interfaces and sealed classes freedom

  • Summary

  • Enum and Value Classes

  • Enum Classes

  • Adding Properties and Methods

  • Using Enum Constants

  • Commonly Used Properties and Methods

  • Use Cases

  • Summary

  • šŸ’” Pro Tips for Mastery: Generic values() and valueOf() for enums

  • Advantages

  • Backward Compatibility

  • Impact on Reflection and Libraries

  • Summary

  • šŸ’” Pro Tips for Mastery: Decommission Enum.values() and replace it with Enum.entries

  • šŸ’” Pro Tips for Mastery: What are the differences between a sealed class and an enum class?

  • Example Code

  • Key Features

  • Use Cases

  • Summary

  • Value Classes

  • Key Features

  • Syntax Example

  • Benefits of Value Classes

  • Constraints of Value Classes

  • The Real-World Use Case

  • Summary

  • šŸ’” Pro Tips for Mastery: What are the differences between value classes and inline classes?

  • Inline Classes

  • Value Classes

  • Inline classes are user-defined value classes

  • @JvmInline annotation for value classes

  • Summary

  • šŸ’” Pro Tips for Mastery: How value class is compiled to Java Bytecode

  • šŸ’” Pro Tips for Mastery: @JvmExposeBoxed - Bringing Kotlin’s value classes for Java

  • @JvmExposeBoxed

  • Objects and Companions

  • Inner and Nested Classes

  • Declaring an Inner Class

  • Accessing the Outer Class Instance

  • Differences Between Nested and Inner Classes

  • Use Cases of Inner Classes

  • Drawbacks of Inner Classes

  • Summary

  • šŸ’” Pro Tips for Mastery: Decompiling differences for inner class vs. nested class in Java Bytecode

  • Object Declarations

  • Key Characteristics

  • Example of an Object

  • Use Cases

  • Differences Between Object and a Regular Class

  • Summary

  • šŸ’” Pro Tips for Mastery: Object declarations vs. expressions

  • Object Declarations: The Singleton Pattern, Simplified

  • Object Expressions: Anonymous, One-Time Instances

  • What are the key differences?

  • Summary

  • šŸ’” Pro Tips for Mastery: What is a data object?

  • Key Features

  • Example of a Data Object

  • Use Cases

  • Data Class vs. Object vs. Data Object

  • KEEP’s Data objects Proposal

  • Summary

  • šŸ’” Pro Tips for Mastery: How Kotlin’s object is compiled to Java Bytecode

  • Companion Objects

  • Key Characteristics of Companion Objects

  • Interoperability with Java and @JvmStatic

  • When to Use Companion Objects

  • Key Benefits

  • Summary

  • Delegation Patterns

  • Delegated Properties

  • How Delegated Properties Work

  • Common Use Cases for Delegated Properties

  • Local delegated properties

  • Summary

  • šŸ’” Pro Tips for Mastery: Internal mechanisms of Lazy

  • The Internal State Management: UNINITIALIZED_VALUE

  • šŸ’” Pro Tips for Mastery: How lazy() delegate property is compiled to Java Bytecode?

  • Lazy Initialization vs lateinit

  • Key Differences

  • Local and top-level lateinit vars

  • Summary

  • šŸ’” Pro Tips for Mastery: How can you check if a lateinit property has been initialized?

  • Lateinit property isInitialized intrinsic

  • šŸ’” Pro Tips for Mastery: How lateinit is compiled to Java Bytecode

  • Functions and Lambdas

  • Higher-Order Functions

  • Syntax

  • Example: Passing a Function as a Parameter

  • Example: Returning a Function

  • Real-World Use Cases

  • Advantages of Higher-Order Functions

  • Summary

  • šŸ’” Pro Tips for Mastery: How are higher-order functions compiled into Java bytecode?

  • Transformation into Function Interfaces

  • Lambda Conversion

  • Optimizations Using InvokeDynamic

  • Inline Functions and Bytecode Optimization

  • Summary

  • Lambda Expressions

  • Shorthand Syntax

  • Usage with Higher-Order Functions

  • Capturing Variables from the Scope

  • Summary

  • Inline and Reified

  • The inline Keyword

  • How inline Works

  • Benefits of Using inline

  • Enabling Advanced Language Features: Non-Local Returns

  • Reified Generics with inline

  • When Not to Use inline

  • Summary

  • šŸ’” Pro Tips for Mastery: What is an inline property? What advantages can you take from it?

  • Advantages of Inline Properties

  • Limitations

  • Inline for property accessors

  • Summary

  • šŸ’” Pro Tips for Mastery: How do functions like repeat(), map(), and filter() accept suspending functions in their lambdas despite not having coroutine-aware signatures?

  • Why Inline Functions Enable This Behavior

  • Summary

  • The reified Keyword

  • Key Use Cases

  • Benefits of Using reified

  • Limitations of reified

  • Example: Using reified for Filtering a List by Type

  • Summary

  • šŸ’” Pro Tips for Mastery: How inline and reified functions are compiled to Java Bytecode

  • Functional (SAM) Interfaces

  • SAM Conversion

  • Key Features of Functional Interfaces

  • Summary

  • šŸ’” Pro Tips for Mastery: A philosophy of SAM conversion

  • The Philosophical Bridge: A Function is an Object (and Vice Versa)

  • Kotlin’s Implementation: A Commitment to Interoperability

  • The Evolution in Java and the Continuing Relevance in Kotlin

  • Summary

  • Extensions and DSL

  • Extension Functions

  • Pros of Extensions

  • Cons of Extensions

  • Summary

  • šŸ’” Pro Tips for Mastery: How are Kotlin extension functions compiled into Java bytecode?

  • Advantages of This Compilation Approach

  • Limitations

  • Summary

  • šŸ’” Pro Tips for Mastery: JvmSynthetic annotation

  • 1. Kotlin Extension Functions: A Syntactic Sugar over Static Methods

  • 2. The @JvmSynthetic Annotation: Hiding from Java

  • 3. Case Study: internal Functions and @JvmSynthetic

  • Summary

  • Domain-Specific Languages (DSL)

  • How Kotlin DSL Works

  • Another Example of HTML Builder

  • Advantages of This Approach

  • Summary

  • Chapter 1 Recap

  • Chapter Summary

  • Key Terms

  • Important Concepts

  • What to Remember

  • [Quiz] Kotlin Language

  • Exercise: Kotlin Language Fundamentals

  • Quiz: Advanced Kotlin Concepts

    3 attempts allowed

  • [Advanced Quiz] Kotlin Language

  • Advanced Quiz: Kotlin Language Mastery

    3 attempts allowed

  • [Chapter 2] Kotlin Standard Library

  • Chapter Overview

  • Collections and Transformations

  • Collection Types

  • Read-Only Collection Types

  • Mutable Collection Types

  • Understanding Mutability of Read-Only and Mutable Collections

  • Summary

  • šŸ’” Pro Tips for Mastery: What are the differences between listOf() and emptyList()?

  • listOf()

  • emptyList()

  • Summary

  • Transformation Operators

  • map and mapIndexed

  • flatMap and flatten

  • groupBy and associateBy

  • zip and unzip

  • filter, filterNot, and filterIndexed

  • The Role of inline

  • Summary

  • Iterators and Sequences

  • Iterators

  • Key Features of Iterator

  • Examples of Using Iterator

  • MutableIterator

  • Key Features of MutableIterator

  • Examples of Using MutableIterator

  • Summary

  • Sequences

  • Creating a Sequence

  • Transforming Sequences

  • The Terminal Operation

  • Summary

  • Collection Retrieval

  • Retrieving Parts of Collections

  • subList

  • slice

  • take and takeLast

  • drop and dropLast

  • windowed

  • chunked

  • Summary

  • Ordering and Sorting

  • Defining Object Ordering

  • Sorting Functions

  • Reversing the Order

  • Randomizing the Order

  • Summary

  • Scope Functions

  • Understanding Scope Functions

  • let

  • run

  • with

  • apply

  • also

  • Choosing the Right Scope Function

  • Summary

  • Chapter 2 Recap

  • Chapter Summary

  • Key Terms

  • Transformation Operations

  • Collections vs Sequences

  • Scope Functions

  • Important Concepts

  • What to Remember

  • [Quiz] Standard Library

  • Exercise: Kotlin Standard Library

  • Quiz: Collection Operations and Algorithms

    3 attempts allowed

  • [Advanced Quiz] Standard Library

  • Advanced Quiz: Standard Library Mastery

    3 attempts allowed

  • [Chapter 3] Coroutines

  • Chapter Overview

  • Coroutines Basics

  • Coroutines

  • How Coroutines Work

  • Launching Coroutines

  • Suspending Functions

  • Summary

  • šŸ’” Pro Tips for Mastery: Coroutines Terminology

  • Summary

  • Continuation

  • How Continuations Work

  • How Kotlin Compiler Transforms Suspend Functions

  • Summary

  • Coroutines vs Threads

  • 1. Management and Creation

  • Threads (OS Kernel Management)

  • Coroutines (User-Space Management)

  • 2. Scheduling and Context Switching

  • Threads (Preemptive Multitasking)

  • Coroutines (Cooperative Multitasking)

  • 3. State, Memory, and Blocking

  • Threads (Stackful and Blocking)

  • Coroutines (Stackless and Suspending)

  • Comparison Example

  • Relationship Between Coroutines and Threads

  • Summary

  • šŸ’” Pro Tips for Mastery: What are the differences between multi-threading and multi-processing?

  • Memory Management

  • Execution Model

  • Resource Utilization

  • Fault Tolerance

  • Scalability

  • Summary

  • šŸ’” Pro Tips for Mastery: Coroutine Execution and Mutable State Management

  • Why Mutable State Sharing Is Risky

  • Safe Data Sharing in Single-Threaded Dispatchers

  • Handling Multi-threaded Environments

  • How Threads Interact with Coroutines

  • Summary

  • Coroutine Builders

  • Coroutine Builders

  • 1. launch

  • 2. async

  • 3. runBlocking

  • 4. produce (for Channels)

  • 5. actor (for Actors Model)

  • Summary

  • šŸ’” Pro Tips for Mastery: What are the differences between launch and async?

  • The Core Difference: Return Value and Intent

  • Error Handling and Structured Concurrency

  • Summary

  • Advanced Coroutine Builder Concepts

  • šŸ’” Pro Tips for Mastery: Why should you use runBlocking with caution?

  • When To Use runBlocking?

  • Summary

  • šŸ’” Pro Tips for Mastery: Internal mechanisms of the AbstractCoroutine

  • How Completion and Resumption Works: resumeWith

  • Structured Concurrency: The Parent-Child Link

  • Summary

  • Coroutine Context and Job

  • Coroutine Context

  • Elements of Coroutine Context

  • Creating a Custom Coroutine Context

  • Accessing Coroutine Context

  • Summary

  • šŸ’” Pro Tips for Mastery: CoroutineContext interface

  • Core Operations in Coroutine Context

  • Elements in Coroutine Context

  • Standard Library Context Elements

  • Accessing Coroutine Context

  • Summary

  • Job

  • Internal Mechanisms of Job

  • Structured Concurrency: The Parent-Child Link and Completion/Waiting

  • Summary

  • šŸ’” Pro Tips for Mastery: What’s a SupervisorJob?

  • When to Use a SupervisorJob

  • Real-world Use Case

  • Internals of SupervisorJob

  • Summary

  • Coroutine Scope

  • Coroutine Scope

  • Common Coroutine Scopes

  • (1) GlobalScope

  • (2) MainScope

  • (3) viewModelScope (Lifecycle-Aware Scopes)

  • (4) lifecycleScope (Lifecycle-Aware Scopes)

  • Example: Creating a Custom Coroutine Scope

  • Summary

  • šŸ’” Pro Tips for Mastery: Why should you use GlobalScope carefully?

  • The Dangers of Unstructured Concurrency

  • Legitimate (But Rare) Use Cases

  • The Correct Alternative: Structured Scopes

  • Summary

  • šŸ’” Pro Tips for Mastery: What is the coroutineScope() function?

  • Error and Cancellation Handling

  • When to Use coroutineScope()

  • coroutineScope() internals

  • Summary

  • šŸ’” Pro Tips for Mastery: What is the supervisorScope() function?

  • Why Use supervisorScope

  • Summary

  • Dispatchers and Channels

  • What kind of coroutine dispatchers exist, and what’s their purpose?

  • Choosing the Right Dispatcher

  • CoroutineDispatcher

  • Summary

  • šŸ’” Pro Tips for Mastery: Differences between CPU-intensive tasks and I/O tasks

  • CPU-Intensive Tasks

  • I/O-Intensive Tasks

  • Thread Behavior

  • CPU-Intensive Tasks vs. I/O-Intensive Tasks

  • Summary

  • šŸ’” Pro Tips for Mastery: Internals of Dispatchers

  • The Shared Engine: CoroutineScheduler and SchedulerCoroutineDispatcher

  • Dispatchers.Default: The CPU-Bound Workhorse

  • Dispatchers.IO: I/O-Bound Specialist

  • Dispatchers.Main: The Platform-Specific UI Thread

  • Dispatchers.Unconfined: The Unpredictable Executor

  • Summary

  • What are channels and how do they work?

  • 1. Rendezvous Channel (capacity = Channel.RENDEZVOUS or 0)

  • 2. Buffered Channel (capacity > 0)

  • 3. Conflated Channel (capacity = Channel.CONFLATED)

  • 4. Unlimited Channel (capacity = Channel.UNLIMITED)

  • Summary

  • šŸ’” Pro Tips for Mastery: Internals Mechanisms of Channel

  • Coroutine Control and Exception Handling

  • What are the join() and yield() functions?

  • 1. join() Function

  • 2. yield() Function

  • Key Differences

  • Summary

  • How do you handle exceptions in coroutines?

  • 1. try-catch Block

  • 2. Delegate Exception Propagation with CoroutineExceptionHandler

  • 3. SupervisorJob

  • Summary

  • šŸ’” Pro Tips for Mastery: The special nature of CancellationException

  • Re-throwing CancellationException for Graceful Exit

  • The runCatching Problem

  • When NOT to Rethrow CancellationException

  • Flow’s Approach: A Model to Follow

  • Summary

  • šŸ’” Pro Tips for Mastery: Handling exception propagation when using async

  • How to Handle

  • Summary

  • Flow Basics

  • What are the differences between cold flow and hot flow?

  • Cold Flow

  • Hot Flow

  • Key Differences Between Cold Flow and Hot Flow

  • Summary

  • šŸ’” Pro Tips for Mastery: Internal mechanisms of Flow and AbstractFlow

  • The flow { … } Builder: The Standard Implementation

  • The AbstractFlow Base Class: Enforcing Context Preservation

  • How Intermediate Operators Work

  • Summary

  • Explain the differences between StateFlow and SharedFlow

  • StateFlow

  • SharedFlow

  • Key Differences Between StateFlow and SharedFlow

  • Summary

  • šŸ’” Pro Tips for Mastery: Internal Mechanisms of StateFlow

  • The State-Holding Mechanism

  • The Update Mechanism: updateState() and Synchronization

  • The Collection Mechanism: collect() and StateFlowSlot()

  • Summary

  • šŸ’” Pro Tips for Mastery: Internal Mechanisms of SharedFlow

  • The Core Data Structure: A Circular Buffer and Indices

  • The emit Mechanism: A Synchronized State Update

  • The collect Mechanism: The Subscriber’s State Machine

  • Summary

  • Flow Operators

  • What does the Flow.flowOn() operator do?

  • Summary

  • šŸ’” Pro Tips for Mastery: Internal Mechanisms of flowOn

  • The ChannelFlowOperatorImpl: The Coroutine Boundary

  • Summary

  • How Flow.buffer() operator works?

  • When to Use buffer()

  • Summary

  • šŸ’” Pro Tips for Mastery: Internal Mechanisms of Flow.buffer()

  • The ChannelFlowOperatorImpl Mechanism: A Producer-Consumer Model

  • Summary

  • How Kotlin’s internal mechanisms optimize Flow with FusibleFlow and ChannelFlow

  • The Solution: FusibleFlow and Operator Fusion

  • ChannelFlow: The Concrete Fusible Implementation

  • The ChannelFlowOperator and the Fast Path

  • Summary

  • Flow Transformations

  • What are the differences between launchIn(Scope) and Scope.launch()?

  • scope.launch { flow.collect() }

  • flow.launchIn(scope)

  • Summary

  • What are Flow transformation operators: flatMapLatest, flatMapMerge, flatMapConcat?

  • flatMapConcat: The Sequential Model

  • flatMapMerge: The Concurrent Model

  • flatMapLatest: The Cancellation Model

  • Key Differences

  • Summary

  • What are callbackFlow and channelFlow, and their internal mechanisms?

  • callbackFlow

  • channelFlow

  • Key Differences

  • Summary

  • Chapter 3 Recap

  • Chapter Summary

  • Key Terms

  • Coroutine Builders

  • Dispatchers

  • Context Combination

  • Flow Operators

  • StateFlow vs SharedFlow

  • Important Concepts

  • What to Remember

  • [Quiz] Coroutines

  • Exercise: Coroutines Fundamentals

  • Quiz: Advanced Coroutines and Flow

    3 attempts allowed

  • [Advanced Quiz] Coroutines

  • Advanced Quiz: Coroutines Mastery

    3 attempts allowed

  • [Chapter 4] KotlinX Libraries

  • Chapter Overview

  • KotlinX Essentials

  • Kotlinx Serialization

  • How Serialization Works

  • Customizing Serialization

  • JSON Configuration

  • Polymorphic Serialization

  • Multiplatform Support

  • Summary

  • Kotlinx Datetime

  • The Need for kotlinx-datetime

  • Working with Time Zones

  • Date Arithmetic

  • Duration and Period

  • Parsing and Formatting

  • Comparison with Java Time

  • Summary

  • Kotlinx Collections Immutable

  • The Problem with Read-Only Collections

  • Truly Immutable Collections

  • Persistent Collections

  • Builders for Efficient Bulk Operations

  • When to Use Immutable Collections

  • Performance Considerations

  • Summary

  • Other Notable KotlinX Libraries

  • kotlinx-atomicfu

  • kotlinx-io

  • kotlinx-benchmark

  • Dokka

  • kotlinx-rpc

  • Kover

  • Summary

  • Chapter 4 Recap

  • Chapter Summary

  • Key Terms

  • kotlinx-serialization

  • kotlinx-datetime

  • kotlinx-collections-immutable

  • Important Concepts

  • What to Remember

  • [Quiz] KotlinX Libraries

  • Exercise: Immutable Collections

  • Quiz: KotlinX Ecosystem

    3 attempts allowed

  • [Advanced Quiz] KotlinX Libraries

  • Advanced Quiz: KotlinX Libraries Mastery

    3 attempts allowed

  • [Chapter 5] Kotlin Compiler and Plugins

  • Chapter Overview

  • Annotation Processing

  • Annotation Processors, KAPT, and KSP

  • Annotation Processor (Java APT)

  • KAPT (Kotlin Annotation Processing Tool)

  • KSP (Kotlin Symbol Processing)

  • Performance Comparison

  • Key Differences

  • Migration from KAPT to KSP

  • Summary

  • Kotlin Compiler Architecture

  • Structure of the Kotlin Compiler

  • High-Level Architecture

  • Frontend

  • Backend

  • Backend Processing Stages

  • Key Differences: Frontend vs. Backend

  • The Role of IR

  • Summary

  • The K2 Compiler

  • Why K2?

  • Key Improvements

  • FIR Compilation Phases

  • K2 for Plugin Authors

  • Migration to K2

  • Compatibility Considerations

  • Summary

  • Frontend Intermediate Representation (FIR)

  • FIR in the K2 Compiler

  • Why FIR?

  • FIR Element Hierarchy

  • FIR Resolution Phases

  • Working with FIR: Symbols and Providers

  • Building FIR Elements

  • FIR Scopes

  • ConeKotlinType: The Type System

  • Summary

  • Intermediate Representation and Backends

  • IR and the Kotlin Backend

  • The Role of IR

  • IR Tree Structure

  • Key IR Element Types

  • IR Lowering: High-Level to Low-Level

  • Platform-Specific Backends

  • IR Plugin Context

  • IR Transformation Patterns

  • IR Serialization

  • Summary

  • Writing Kotlin Compiler Plugins

  • How to Write a Kotlin Compiler Plugin

  • Plugin Architecture Overview

  • Step 1: Define Your Annotation

  • Step 2: Create the Command Line Processor

  • Step 3: Create the Component Registrar

  • Step 4: Register Services (SPI)

  • Step 5: Implement K2 FIR Extension

  • Step 6: Implement IR Generation Extension

  • Step 7: Create Gradle Plugin

  • Step 8: Usage in Projects

  • Summary

  • Real-World Compiler Plugin Examples

  • Compiler Plugin Use Cases

  • Kotlinx Serialization

  • Jetpack Compose

  • Parcelize

  • All-Open and No-Arg Plugins

  • SAM-with-Receiver

  • When to Consider Writing a Compiler Plugin

  • Summary

  • Chapter 5 Recap

  • Chapter Summary

  • Key Terms

  • Compiler Architecture

  • KAPT vs KSP

  • FIR Resolution Phases

  • IR Lowering Transformations

  • Compiler Plugin Structure

  • Real-World Plugin Examples

  • Important Concepts

  • What to Remember

  • [Quiz] Compiler Plugins

  • Quiz: Compiler Architecture and Plugins

    3 attempts allowed

  • [Advanced Quiz] Compiler Plugins

  • Advanced Quiz: Compiler Plugins Mastery

    3 attempts allowed

  • [Chapter 6] Kotlin Multiplatform

  • Chapter Overview

  • KMP Fundamentals

  • Kotlin Multiplatform Overview

  • Key Features of Kotlin Multiplatform

  • Key Advantages

  • Kotlin Multiplatform Architecture

  • Summary

  • Expect and Actual Declarations

  • Expect Declarations

  • Actual Implementations

  • What Can Be Expected/Actual

  • Default Implementations with Expected Classes

  • Compiler Guarantees

  • When to Use Expect/Actual vs Other Approaches

  • Summary

  • Concurrency and Asynchronous Programming

  • Kotlin Coroutines: The Primary Solution

  • Platform-Specific Dispatchers

  • Structured Concurrency in Multiplatform

  • Alternative Asynchronous Solutions

  • Summary

  • HTTP Network Communication

  • Ktor Client

  • Platform-Specific Engines

  • Ktorfit

  • Summary

  • Compose Multiplatform

  • How Compose Multiplatform Works

  • Writing Shared UI

  • Supported Platforms and Stability (2025)

  • Resources and Platform Integration

  • Platform-Specific UI When Needed

  • Navigation and Architecture

  • Trade-offs to Consider

  • Summary

  • Source Set Structure

  • Source Sets in Kotlin Multiplatform

  • Default Source Set Hierarchy

  • Project Structure

  • Gradle Configuration

  • Intermediate Source Sets

  • Dependencies Per Source Set

  • Summary

  • Kotlin/Native

  • Memory Management and Platform Interoperability

  • Kotlin/Native Memory Management

  • Interoperability with Objective-C and Swift

  • Controlling Swift/Objective-C Exposure

  • Using iOS Frameworks from Kotlin

  • Coroutines and Swift Async/Await

  • Performance Considerations

  • Summary

  • Testing Strategies

  • Testing in Kotlin Multiplatform

  • Common Test Structure

  • Test Source Set Configuration

  • Testing Coroutines

  • Platform-Specific Tests

  • Testing with Fakes and Mocks

  • Running Tests

  • Integration Testing

  • Summary

  • Dependency Injection Strategies

  • Dependency Injection in Kotlin Multiplatform

  • Why DI Matters in Multiplatform

  • Metro: Compile-Time DI with Kotlin Compiler Plugin

  • Koin: KSP-Based Compile-Time DI

  • Kodein-DI: Flexible Runtime Container

  • Manual Dependency Injection

  • Choosing the Right Approach

  • Constructor Injection Pattern

  • Summary

  • Chapter 6 Recap

  • Chapter Summary

  • Key Terms

  • Source Set Hierarchy

  • Kotlin to Swift/Objective-C Mapping

  • Interop Annotations

  • Testing in KMP

  • Platform-Specific Dependencies

  • Important Concepts

  • What to Remember

  • [Quiz] Kotlin Multiplatform

  • Exercise: KMP Fundamentals

  • Quiz: Advanced Multiplatform Development

    3 attempts allowed

  • [Advanced Quiz] Kotlin Multiplatform

  • Advanced Quiz: Kotlin Multiplatform Mastery

    3 attempts allowed

  • Final Words

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub