small medium large xlarge

Programming Kotlin: Create Elegant, Expressive, and Performant JVM and Android Applications


Cover image for Programming Kotlin

Programming Kotlin

Create Elegant, Expressive, and Performant JVM and Android Applications


Programmers don’t just use Kotlin, they love it. Even Google has adopted it as a first-class language for Android development. With Kotlin, you can intermix imperative, functional, and object-oriented styles of programming and benefit from the approach that’s most suitable for the problem at hand. Learn to use the many features of this highly concise, fluent, elegant, and expressive statically typed language with easy-to-understand examples. Learn to write maintainable, high-performing JVM and Android applications, create DSLs, program asynchronously, and much more.

Choose Your Format(s)

  • $27.95 In Stock
    • Beta: What do I get?

  • Ebooks are DRM free.

  • Ebook delivery options.

  • The Paper Book will ship on 2019-03-01 (roughly).

About this Title

Pages: 450 (est)
Published: 2019-03-20
Release: B2.0 (2018-11-12)
ISBN: 978-1-68050-635-8

Kotlin is a highly concise, elegant, fluent, and expressive statically typed multi-paradigm language. It is one of the few languages that compiles down to both Java bytecode and JavaScript. You can use it to build server-side, front-end, and Android applications. With Kotlin, you need less code to accomplish your tasks, while keeping the code type-safe and less prone to error. If you want to learn the essentials of Kotlin, from the fundamentals to more advanced concepts, you’ve picked the right book.

Fire up your favorite IDE and practice hundreds of examples and exercises to sharpen your Kotlin skills. Learn to build standalone small programs to run as scripts, create type safe code, and then carry that knowledge forward to create fully object-oriented and functional style code that’s easier to extend. Learn how to program with elegance but without compromising efficiency or performance, and how to use metaprogramming to build highly expressive code and create internal DSLs that exploit the fluency of the language. Explore coroutines, program asynchronously, run automated tests, and intermix Kotlin with Java in your enterprise applications.

This book will help you master one of the few languages that you can use for the entire full stack – from the server to mobile devices – to create performant, concise, and easy to maintain applications.

What You Need

To try out the examples in the book you’ll need a computer with Kotlin SDK, JDK, and a text editor or a Kotlin IDE installed in it.

Contents & Extracts

This book is currently in beta, so the contents and extracts will change as the book is developed.

  • Introduction
  • Hello Kotlin excerpt
    • Reasons to Love Kotlin
    • Why Should You Choose Kotlin?
    • Taking Kotlin for a Ride
    • Compile to Bytecode and Run
    • Compiling to Other Targets
    • Which Option to Choose?
    • Wrapping Up
  • Scripting with Kotlin
    • Kotlin Essentials for the Java Eyes
      • Less Typing
      • Sensible Warnings excerpt
      • Prefer val over var
      • Improved Equality Check
      • String Templates
      • Raw Strings
      • More Expressions, Fewer Statements
      • Wrapping Up
    • Working with Functions
      • Creating Functions
      • Default and Named Arguments
      • Vararg and Spread
      • Destructuring
      • Wrapping Up
    • External Iteration and Pattern Matching
      • Range and Iteration
      • Iterating Over Arrays and Lists
      • When It’s Time To Use when
      • Wrapping Up
    • Using Collections
      • Flavors of Collections
      • Using Pair and Triple
      • Arrays of Objects and Primitives
      • Using List
      • Using Set
      • Using Map
      • Wrapping Up
    • Type Safety To Save the Day
      • Any and Nothing Classes
      • Nullable References
      • Type Checking and Casting
      • Explicit Type Casting
      • Generics: Variance and Constraints of Parametric Types
      • Wrapping Up
  • Object-Oriented Kotlin
    • Objects and Classes
      • Objects and Singletons
      • Creating Classes excerpt
      • Companion Objects and Class Members
      • Creating Generics Classes
      • Data Classes
      • Wrapping Up
    • Class Hierarchies and Inheritance
      • Creating Interfaces and Abstract Classes
      • Nested and Inner Classes
      • Inheritance
      • Sealed Classes
      • Creating and Using Enums
      • Wrapping Up
    • Extension Through Delegation
      • When to Choose Delegation Over Inheritance?
      • Designing with Delegates
      • Delegating to a Parameter
      • Dealing with Method Collisions
      • Caveats of Kotlin Delegation
      • Delegating Variables and Properties
      • Built-in Standard Delegates
      • Wrapping Up
  • Functional Kotlin
    • Functional Programming with Lambdas
      • The Functional Style
      • Lambda Expressions
      • Lambdas and Anonymous Functions
      • Closures and Lexical Scoping
      • Non-local and Labeled return
      • Inlining Functions with Lambdas
      • Wrapping Up
    • Internal Iteration and Lazy Evaluation
      • External vs. Internal Iteration
      • Internal Iterators
      • Sequences for lazy evaluation
      • Wrapping Up
  • Elegant and Efficient Kotlin
    • Fluency in Kotlin
      • Overloading Operators
      • Injecting Methods and Properties
      • Extending Functions
      • Function Fluency with infix
      • Fluency with the Any Object
      • Implicit Receivers
      • Wrapping Up
    • Creating Internal DSLs
      • Types and Characteristics of DSLs
      • Kotlin for Internal DSLs
      • Challenges in Building for Fluency
      • Type-Safe Builders
      • Narrowing Access with Scope Control
      • Wrapping Up
    • Programming Recursion and Memoization
      • The Power and Perils of Recursion
      • Tail Call Optimization
      • Memoization
      • Applying Memoization to Dynamic Programming
      • Wrapping Up
  • Programming Asynchronous Applications
    • Using Coroutines
    • Asynchronous Programming
  • Interop and Testing
    • Intermixing Java and Kotlin
      • Place holder
    • Unit Testing with Kotlin
    • Programming Spring Applications with Kotlin
    • Writing Android Applications with Kotlin


Dr. Venkat Subramaniam is an award-winning author, founder of Agile Developer, Inc., and an instructional professor at the University of Houston. He has trained and mentored thousands of software developers in the US, Canada, Europe, and Asia, and is regularly invited to speak at international conferences. He’s the (co)author of multiple books, including the 2007 Jolt Productivity award winning book Practices of an Agile Developer.