small medium large xlarge

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

by

Cover image for Programming Kotlin

Programming Kotlin

Create Elegant, Expressive, and Performant JVM and Android Applications

by

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.

Customer Reviews

Venkat is someone that can take any topic and make it pleasurable and easy to understand. In this book he will take you on an adventure of learning Kotlin in a clear and pragmatic way, providing real-world usages, while at the same time showing you the benefits of the language.

- Hadi Hariri

Developer Advocate, JetBrains

This book will open the door to the amazing world of Kotlin. You’ll be guided along this journey by one of the most famous public speakers and educators of our day. Have a nice Kotlin!

- Eugene Petrenko, PhD

Developer, Speaker, JetBrains

Enter the cave of Kotlin using this excellent book as your headlight. Gain confidence in this beautiful language as a cave explorer gains self-assurance in finding his way in a newly explored cave never seen by the human eyes before. Explore pragmatically deeper and deeper into this modern JVM language using the knowledge, hints, and guidelines provided by an extraordinary, experienced programming-language enthusiast: Venkat.

- Tom Adam

Senior Consultant, CEO, Lambda Consulting AS

The engaging and humorous way of explaining things, as Venkat does in his talks, is also displayed in this book. It is a very well-structured and easy-to-read guide for everyone who is—or wants to begin—programming in Kotlin.

- Brian Vermeer

Developer Advocate, Snyk

Really a perfect book to get up and running, and not just hear about the hype of Kotlin. It actually explained what’s the buzz about Kotlin. Venkat did it once more! A must-read book, not just to get up and running with Kotlin but also to compare what we are missing in Java.

- Zulfikar Dharmawan

Software Engineer, ING Bank NV

Kotlin is a very promising new language, and Venkat uses his knowledge, humor, and clear admiration for Kotlin to create a very readable and educational book. Venkat explains things very well, provides helpful advice, and even gives an occasional laugh.

- Tory Zundel

Software Architect

The book is well-crafted with good, succinct examples—highly recommended for Java developers looking to transition into Kotlin.

- Ashish Bhatia

Software Enginner and Blogger, ashishb.net

If you’re content with Java and see no need for null-safe traversal or first-class delegation then put this book down; you’re not ready. Otherwise, read this book. You will be entertained and educated simultaneously.

- Daniel DeGroff

CTO, FusionAuth

See All Reviews

Choose Your Format(s)

  • $54.95 In Stock

    Save $16.95 on the combo pack.

  • $43.95 In Stock
  • $27.95 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

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

  • 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 Argument 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
      • Reified Type Parameters
      • 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 Iterators
      • Internal Iterators
      • Sequences for Lazy Evaluation
      • Wrapping Up
  • Elegant and Efficient Kotlin
    • Fluency in Kotlin
      • Overloading Operators
      • Injecting Using Extension Functions and Properties
      • Extending Functions
      • Function Fluency with infix
      • Fluency with 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
    • Exploring Coroutines
      • Coroutines and Concurrency
      • Running Concurrently Using Coroutines
      • Coroutine Context and Threads
      • Debugging Coroutines
      • async and await
      • A Peek at Continuations
      • Creating Infinite Sequences
      • Wrapping Up
    • Asynchronous Programming
      • Programming Asynchronously
      • Exception Handling
      • Cancellations and Timeouts
      • Wrapping Up
  • Interop and Testing
    • Intermixing Java and Kotlin
      • Joint Compilation
      • Calling Java from Kotlin
      • Calling Kotlin from Java
      • Wrapping Up
    • Unit Testing with Kotlin
      • The Code Under Test
      • Getting the Project Files
      • Starting with a Canary Test
      • Writing Empirical Tests
      • Writing Data-Driven Tests
      • Mocking Out Dependencies
      • Testing Top-Level Functions
      • Testing Coroutines and Asynchronous Calls
      • Integrating with the Service
      • Viewing the Code Coverage
      • Taking the App for a Drive
      • Wrapping Up
    • Programming Spring Applications with Kotlin
      • Creating a Starter Project
      • Creating a Controller
      • Creating an Entity Class
      • Creating a Repository Interface
      • Creating a Service
      • Integrating the Service with Controller
      • Taking It for a Ride
      • Wrapping Up
    • Writing Android Applications with Kotlin
      • Creating a Project
      • Defining Domain Objects
      • Creating Layouts
      • Implementing the Activity
      • Updating the RecyclerView
      • Seeing the App in Action
      • Wrapping Up

Author

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.