Rusty & Bot-1

What's New

I’m thrilled to announce that Chapter 20: Coroutine Essentials has finally arrived!

This final chapter of Kotlin: An Illustrated Guide covers how to do concurrency and parallelism the Kotlin way - with coroutines. Learn all about coroutines, coroutine builders, dispatchers, structured concurrency, and much more. In fact, this chapter is roughly 40% longer than the previous longest chapter!

I’ll still be adding a few more features to the Leanpub edition of the book. Let me know which features you want, and once those are included, we’ll start looking toward a print edition.

To stay updated on the progress of this book (and other fun projects I’ve got up my sleeve!), join the hundreds of other Kotlin developers who have signed up for my email newsletter. It’s easy to sign up, I won’t spam you, and you can unsubscribe whenever you want.

Latest Articles and Videos

New!

Builder Pattern
in Kotlin

Do we need the Builder Pattern in Kotlin? Let's find out.

Builder Pattern<br />in Kotlin

Factory Patterns in Kotlin

Let's look at the Factory Method and Abstract Factory patterns to see how we can use them in Kotlin.

Factory Patterns in Kotlin

TypeAlias Show #2:
Multi-Cursor Magic

Kotlin Roadmap updates, StackOverflow survey results, and accelerated development in JetBrains' IDEs.

TypeAlias Show #2:<br/>Multi-Cursor Magic

State Pattern in Kotlin

The design pattern series continues. Let's see how we can modernize the State Pattern.

State Pattern in Kotlin

Decorator Pattern in Kotlin

In this video, we'll modernize the Decorator Pattern using some of Kotlin's language features.

Decorator Pattern in Kotlin

Strategy Pattern in Kotlin

Let's see how Kotlin can modernize the Strategy Pattern from the original Gang of Four book.

Strategy Pattern in Kotlin

Coroutines: Concurrency in Kotlin

A live presentation covering the main concepts from Chapter 20, in about 30 minutes.

Coroutines: Concurrency in Kotlin

TypeAlias Show #1: kotlinx.rpc

It's the very first episode of the TypeAlias Show Livestream!

TypeAlias Show #1: kotlinx.rpc

Composing Like You're Inheriting

Composition vs. Inheritance... or can we get the best of both worlds?

Composing Like You're Inheriting

Coroutine Essentials

Discover the power of coroutines in Kotlin and learn how to make your applications perform tasks concurrently and in parallel. Join Rusty and his construction crew as they streamline construction projects – and see how you can apply these same techniques to your Kotlin code!

Coroutine Essentials

7 Overlooked Stdlib Features

Let's look at seven features in the standard library that you might have missed.

7 Overlooked Stdlib Features

Reified Type Parameters

What is type erasure, and how does the reified keyword help?

Reified Type Parameters

The Essence of Coroutines

What makes a coroutine a coroutine?

The Essence of Coroutines

Looking Forward to Kotlin 2.0

Kotlin 2.0 is just around the corner!

Looking Forward to Kotlin 2.0

Three Simple Rules for Subtypes

Inheritance and variance are based on three simple rules.

Three Simple Rules for Subtypes

Generic Variance

Create subtypes from your parameterized types using Kotlin's generic variance. In this chapter, we'll learn about covariance, contravariance, and how they can be applied in declaration-site variance and use-site variance, based on three simple rules of subtypes.

Generic Variance

Inline Functions

Let's look at inline functions, and the crossinline and noinline modifiers.

Inline Functions

Every Kind of Class

Inner classes, value classes, sealed classes, and many others... let's look at them all!

Every Kind of Class

Generics

Perk up your understanding of generics in Chapter 18 of Kotlin: An Illustrated Guide! Through the engaging examples of Jennifer's bakery café and its ever-evolving beverage menu, you'll learn all about generics, type parameters, type arguments, upper-bound constraints, and lots more.

Generics

Type Projections

Type projections give us generic subtypes when declaration-site variance isn't an option!

Type Projections

Variance... without Generics!

Unlock the mental model of variance. No generics required!

Variance... without Generics!

Handling Runtime Exceptions

Catch some new knowledge about exception handling with Chapter 17 of 'Kotlin: An Illustrated Guide.' This chapter demystifies runtime errors, offering readers a blend of technical depth and relatable examples to master exception handling in Kotlin. Through vivid illustrations and clear, approachable explanations, learn how to navigate unexpected issues in your code gracefully. Whether you're a beginner eager to solidify your understanding or an experienced developer looking to refresh your knowledge, this chapter turns the complex topic of exceptions into an enjoyable learning experience.

Handling Runtime Exceptions

Introduction to HexFormat

Let's check out HexFormat and its related functions!

Introduction to HexFormat

Intersection Types in Kotlin

Intersection types are not denotable, but we can still use them!

Intersection Types in Kotlin

try-catch vs runCatching

Let's talk about try-catch, runCatching(), and those poll results!

try-catch vs runCatching

Sealed Types

In Kotlin, we can used sealed interfaces and sealed classes to make the compiler even more helpful! In this chapter, we'll learn how to get exhaustive matching with sealed types.

Sealed Types

Leanpub Frontmatter Podcast: Dave Leeds

Len Epp and I talk about Kotlin, learning how to code, publishing on Leanpub, and lots more!

Leanpub Frontmatter Podcast: Dave Leeds

A Tour Through Konsist with Igor Wojda

I team up with special guest Igor Wojda to demonstrate how the Konsist static code analysis tool can be used to ensure consistency in a Kotlin codebase!

A Tour Through Konsist with Igor Wojda

Data Classes and Destructuring

It's easy to use data classes to give your objects superpowers like value equality, a readable toString() implementation, the ability to easily copy values, and the ability to be destructured. In this chapter, we'll learn what they are, how to declare them, and when to use them!

Data Classes and Destructuring

How to Use Kotlin's Timing API

Kotlin's Timing API is stable as of Kotlin 1.9, and it offers some great ways to both measure and specify time. In this video, we'll take a tour through the main features of this API so that you can start using durations and time marks like a pro!

How to Use Kotlin's Timing API

Wall Clock vs. Monotonic Clock

As a prelude to exploring the newly-stable Timing API in Kotlin 1.9, let's check out the difference between a wall clock and a monotonic clock!

Wall Clock vs. Monotonic Clock

Abstract and Open Classes

In this chapter, we'll see how we can create subtypes from abstract classes and open classes. Impress your friends with big words like inheritance and polymorphism!

Abstract and Open Classes

Introduction to Collection Builders

Use Collection Builders to dynamically build out a collection's contents, without leaving it open to modifications.

Introduction to Collection Builders

Smart Casts with Kotlin Contracts

Use the experimental Contracts feature to create a Smart Cast from your own function.

Smart Casts with Kotlin Contracts

Introduction to Class Delegation

Use Kotlin’s class delegation feature to forward function calls from one object to another - without all the usual boilerplate!

Introduction to Class Delegation

Easy SharedPreferences with Delegated Properties

Learn how Kotlin's delegated properties work by turning Android's SharedPreferences into a delegate.

Easy SharedPreferences with Delegated Properties

5 Fun Ways to Use Extension Functions

Let's put extension functions together with operator function conventions to do some crazy things!

5 Fun Ways to Use Extension Functions

5-Year Celebration: Peek Behind the Scenes!

Get a peek behind the scenes, including my art setup, my writing tooling, and even my cute dog!

5-Year Celebration: Peek Behind the Scenes!

Introduction to Interfaces

In Kotlin, interfaces are one way to give a class more than one type at the same time. In this chapter, learn about interfaces and implementations, plus smart casts, interface inheritance, multiple interfaces, and default implementations.

Introduction to Interfaces

Scopes and Scope Functions

Kotlin's scope functions - with(), run(), let(), also(), and apply() - introduce a new scope where an object can be easily used. Learn about two different kinds of scopes and how they affect visibility. Then, explore all five scope functions, and learn how shadowing affects implicit receivers.

Scopes and Scope Functions

Receivers and Extensions

Use Kotlin extensions to add new functions and properties to existing classes - even to classes that you didn't write! Learn all about explicit receivers, implicit receivers, extension functions, and extension properties in this chapter.

Receivers and Extensions

Collections: Maps

Maps in Kotlin are used to associate keys and values. In this chapter, we'll learn all about them, including mutable and immutable maps, map operations like forEach() and filter(), and how to convert lists into maps with associate() and groupBy().

Collections: Maps

Collections: Lists and Sets

Kotlin collections give you powerful control over groups of objects. In this chapter, we'll look at List and Set collection types, and we'll learn about collection operations - including mapping, filtering, and sorting.

Collections: Lists and Sets

Lambdas and Function References

In Kotlin, you can pass a chunk of code from one function to another. In this chapter, we'll learn how to do that, covering topics like function types, function references, lambdas, higher-order functions, and much more.

Lambdas and Function References

Nulls and Null Safety

In Kotlin, null safety is a first-class concept. In this chapter, we'll learn all about nulls, including how to manage them with tools like smart casts, elvis operators, safe-call operators, and more.

Nulls and Null Safety

Enum Classes

Enumeration classes can improve your code by limiting values to only those that could be correct. In this chapter, we'll learn all about enum classes in Kotlin!

Enum Classes

Examples of Classes in Kotlin

A quick reference that shows how to create classes in Kotlin, with examples that include properties, functions, inheritance, generics, and more.

Examples of Classes in Kotlin

Introduction to Classes and Objects

Classes and objects are everywhere in Kotlin! In this chapter, we'll put variables and functions together to create our very own types, using Kotlin classes.

Introduction to Classes and Objects

Kotlin Conditionals: When and If

Kotlin has two important conditionals: when and if. They can be used either as expressions or as statements. In this chapter, we'll use illustrations and examples to demonstrate how to use them.

Kotlin Conditionals: When and If

Functions

Learn all about Kotlin functions the fun and easy way, with lots of examples and illustrations! Expression bodies, block bodies, named arguments, default arguments, and lots more.

Functions

Variables, Expressions, and Types

So you want to be a Kotlin programmer? You've come to the right place! Your adventure starts here in Chapter 1, where you'll learn all about variables, expressions, and types.

Variables, Expressions, and Types

When to Use Sequences

When should you use Kotlin sequences? And when should you use normal collections? In this article, we'll look at some of the characteristics that can have the biggest impact on performance.

When to Use Sequences

Inside Sequences: Create Your Own Sequence Operations

Learn how to create your very own sequence operation by understanding how Kotlin's sequences work on the inside.

Inside Sequences: Create Your Own Sequence Operations

Kotlin Sequences: An Illustrated Guide

An illustrated introduction to Sequences in Kotlin - easy-to-understand diagrams that demonstrate the difference between regular collection operations and sequence operations.

Kotlin Sequences: An Illustrated Guide

Inline Classes and Autoboxing

Get the best performance out of Kotlin's Inline Classes feature by understanding when they're inlined and when they're autoboxed.

Inline Classes and Autoboxing

An Introduction to Inline Classes

An introduction to Kotlin's inline value classes, which can give you strong types for simple values - without sacrificing performance.

An Introduction to Inline Classes

How to Enable Kotlin 1.3 Inline Classes Today

How to configure your IDE to use Kotlin 1.3 early access so that you can start exploring inline classes and other new features. Includes instructions for Gradle, Maven, IntelliJ IDEA, and Android Studio.

How to Enable Kotlin 1.3 Inline Classes Today

Parameters and Arguments: An Easy Way to Remember the Difference

Parameters and arguments aren't the same thing. Here's an easy way to remember the difference.

Parameters and Arguments: An Easy Way to Remember the Difference

All About Type Aliases in Kotlin

Kotlin's type aliases give you a quick and easy way to create simple, concise, and domain-specific names for types. This guide covers all of the essential concepts, with plenty of examples to help you level up your Kotlin game.

All About Type Aliases in Kotlin

Star-Projections and How They Work

What are star-projections in Kotlin? And why do they change your function parameter and return types? With just two easy-to-understand rules, we can illuminate star-projections and understand exactly why they work like they do.

Star-Projections and How They Work

The Ins and Outs of Generic Variance in Kotlin

The ultimate guide to understanding generics, covariance, contravariance, and type projections in Kotlin. Learn two simple subtyping rules that explain why generic variance works the way that it does.

The Ins and Outs of Generic Variance in Kotlin

An Illustrated Guide to Covariance and Contravariance in Kotlin

Confused about generic subtyping? With just a few simple, foundational concepts, almost everything about variance becomes clear. If you're confused about how subtyping works with generics in Kotlin, start here.

An Illustrated Guide to Covariance and Contravariance in Kotlin