Hello, Android developers! We’re happy to announce that the full release of ourKotlin Apprentice book is now available!
This is the sister book to ourAndroid Apprentice book, which focuses on creating apps for Android, while Kotlin Apprentice focuses on the Kotlin language fundamentals.
If you’re new to the Kotlin language, there’s no need to be intimidated: This book starts with the basics of basics — an introduction to programming — and then takes you through Kotlin fundamentals. But, if you’re familiar with Kotlin, you’ll advance into more intermediate and nuanced features of the language, such as functional programming, conventions and operator overloading, and coroutines.
Whatever your familiarity with the language, this book will teach you to organize and customize your code in Kotlin to create clean and modern apps in Kotlin.
Here’s what’s contained in the full release of the book:
Section I: Kotlin Basics
- Chapter 1: Your Kotlin Development Environment : We start you right at the beginning so you can get up-to-speed with programming basics. Learn how to work with IntelliJ IDEA, which you will use throughout the rest of the book.
- Chapter 2: Expressions, Variables & Constants : This is it, your whirlwind introduction to the world of programming! You’ll begin with an overview of computers and programming, and then spend your time working with code comments, arithmetic operations, constants and variables.
- Chapter 3: Types & Operations : You’ll learn about handling different types, including strings, which allow you to represent text. You’ll learn about converting between types and you’ll also be introduced to type inference, which makes your life as a programmer a lot simpler.
- Chapter 4: Basic Control Flow : You’ll learn how to make decisions and repeat tasks in your programs by using syntax to control the flow. You’ll also learn about Booleans, which represent true and false values, and how you can use these to compare data.
- Chapter 5: Advanced Control Flow : Continuing the theme of code not running in a straight line, you’ll learn about another loop known as the `for` loop. You’ll also learn about `when` expressions, which are particularly powerful in Kotlin.
- Chapter 6: Functions : Functions are the basic building blocks you use to structure your code in Kotlin. You’ll learn how to define functions to group your code into reusable units.
- Chapter 7: Nullability : Many programming languages suffer from the “billion dollar mistake” of null values. You’ll learn how Kotlin protects you from the dreaded null pointer exception.
Build your projects using IntelliJ IDEA!
Section II: Collections & Lambdas
- Chapter 8: Arrays & Lists : Why have only one of a thing when you could have many? Learn about the Kotlin collection types — arrays, lists, maps and sets — including what they’re good for, how to use them and when to use each.
- Chapter 9: Maps & Sets : Maps are useful when you want to look up values by means of an identifier. For example, the table of contents of this book maps chapter names to their page numbers, making it easy to skip to the chapter you want to read. With an array, you can only fetch a value by its index, which has to be an integer, and all indexes have to be sequential. In a map, the keys can be of any type and are generally in no particular order. You’ll also learn about sets, which let you store unique values in a collection.
- Chapter 10: Lambdas : Put code into variables and pass code around to help avoid callback insanity!
- Chapter 11: Classes : In this chapter, you’ll get acquainted with classes, which are are named types. Classes are one of the cornerstones of object-oriented programming, a style of programming where the types have both data and behavior. In classes, data takes the form of properties and behavior is implemented using functions called methods.
Use maps when you want to look up values by means of an identifier!
Section III: Building Your Own Types
- Chapter 12: Objects : Kotlin has a special keyword object that makes it easy to follow the singleton pattern in your projects, and that is also used to create properties specific to a class and not its instances. You also use the keyword to create anonymous classes.
- Chapter 13: Properties : In this chapter, you’ll learn more about Kotlin properties, along with some tricks to deal with properties, how to monitor changes in a property’s value and how to delay initialization of a property.
- Chapter 14: Methods : Methods are merely functions that reside in a class. In this chapter, you’ll take a closer look at methods and see how to add methods onto classes that were created by someone else.
- Chapter 15: Interfaces : Classes are used when you want to create types that contain both state and behavior. When you need a type that allows primarily the specification of behavior, you’re better off using an interface. See how to create and use interfaces.
- Chapter 16: Advanced Classes : Having seen the basics of creating classes, in this chapter you’ll see the more advanced aspects of object-oriented programing, including inheritance and limiting member visibility.
- Chapter 17: Enum Classes : Enumerations are useful when you have a quantity that can take on a finite set of discrete values. See how to define and use enum classes and see some examples of working with enum classes and when expressions.
- Chapter 18: Generics : At some point, you will need to ability to create abstractions that go beyond what’s available in regular classes and functions. You’ll learn how to use generics to super-power your classes and functions.
Get help figuring out if you’re dealing with a property or a method!
Section IV: Intermediate Topics
- Chapter 19: Kotlin/Java Interoperability : Kotlin is designed to be 100% compatible with Java and the JVM. Seamlessly use Kotlin in your Java projects and call back and forth between the languages.
- Chapter 20:Exceptions : No software is immune to error conditions. See how to use exceptions in Kotlin to provide some control over when and how errors are handled.
- Chapter 21: Functional Programming : Kotlin goes beyond just being an object-oriented programming language, and provides many of the constructs found in the domain of functional programming. See how to treat functions as first-class citizens by learning how to use functions as parameters and return values from other functions.
- Chapter 22: Conventions & Operator Overloading : You’ll learn the concept of conventions and see how to use conventions to implement operator overloading and write more concise but still readable code.
- Chapter 23: Kotlin Coroutines : Simplify your asynchronous programming using Kotlin coroutines, and discover the differences between coroutines and threads.
- Chapter 24: Scripting with Kotlin : Kotlin is not just useful on Android or the JVM, but also can be used for scripting at the command line. See how to use Kotlin as a scripting language.
- Appendix A: Kotlin Platforms : Now that you’ve learned about how to use Kotlin, you may be asking yourself: Where can I apply all of this knowledge? There are many different platforms that allow you to use Kotlin as a programming language. Anything that runs Java can run Kotlin, and there are very few machines that can’t run Java. In this chapter, you’ll learn about the top platforms for Kotlin and what to watch out for.
Mapping an unhandled exception!
Where to Go From Here?
Get your own copy:
The Kotlin language has been around since 2011, but its popularity took off in 2017 when Google announced Kotlin’s inclusion as a first-class language for Android development. With modern and expressive language characteristics such as those found in Swift, and 100% interoperability with Java, it’s no wonder that Kotlin has been named the second most-loved language by Stack Overflow users.
In this book, we’ll take you through programming basics, object-oriented programming with classes, exceptions, generics, functional programming, and more!
Questions about the book? Ask them in the comments below!