This book is for dedicated novices and experienced programmers.
You’re a novice if you don’t have prior programming knowledge, but “dedicated” because we give you just enough to figure it out on your own. When you’re finished, you’ll have a solid foundation in programming and in Kotlin.
The “Atomic” part of the book title refers to atoms as the smallest indivisible units. In this book, we try to introduce only one concept per chapter, so the chapters cannot be further subdivided—thus we call them atoms.
All programming languages consist of features. You apply these features to produce results. Kotlin is powerful—not only does it have a rich set of features, but you can usually express those features in numerous ways.
If everything is dumped on you too quickly, you might come away thinking Kotlin is “too complicated.”
This book attempts to prevent overwhelm. We teach you the language carefully and deliberately, using the following principles:
- Baby steps and small wins. We cast off the tyranny of the chapter. Instead, we present each small step as an atomic concept or simply atom, which looks like a tiny chapter. We try to present only one new concept per atom. A typical atom contains one or more small, runnable pieces of code and the output it produces.
- No forward references. As much as possible, we avoid saying, “These features are explained in a later atom.”
- No references to other programming languages. We do so only when necessary. An analogy to a feature in a language you don’t understand isn’t helpful.
- Show don’t tell. Instead of verbally describing a feature, we prefer examples and output. It’s better to see a feature in code.
- Practice before theory. We try to show the mechanics of the language first, then tell why those features exist. This is backwards from “traditional” teaching, but it often seems to work better.
If you know the features, you can work out the meaning. It’s usually easier to understand a single page of Kotlin than it is to understand the equivalent code in another language.
# Where Is the Index?
This book is written in Markdown and produced with Leanpub. Unfortunately, neither Markdown nor Leanpub supports indexes. However, by creating the smallest-possible chapters (atoms) consisting of a single topic in each atom, the table of contents acts as a kind of index. In addition, the eBook versions allow for electronic searching across the book.
In this book:
- Italics introduce a new term or concept, and sometimes emphasize an idea.
Fixed-width fontindicates program keywords, identifiers and file names. The code examples are also in this font, and are colorized in the eBook versions of the book.
- In prose, we follow a function name with empty parentheses, as in
func(). This reminds the reader they are looking at a function.
- To make the eBook easy to read on all devices and allow the user to increase the font size, we limit our code listing width to 47 characters. At times this requires compromise, but we feel the results are worth it. To achieve these widths we may remove spaces that might otherwise be included in many formatting styles—in particular, we use two-space indents rather than the standard four spaces.
# Sample the Book
We provide a free sample of the electronic book at AtomicKotlin.com (opens new window). The sample includes the first two sections in their entirety, along with several subsequent atoms. This way you can try out the book and decide if it’s a good fit for you.
The complete book is for sale, both as a print book and an eBook. If you like what we’ve done in the free sample, please support us and help us continue our work by paying for what you use. We hope the book helps, and we appreciate your sponsorship.
In the age of the Internet, it doesn’t seem possible to control any piece of information. You’ll probably find the electronic version of this book in numerous places. If you are unable to pay for the book right now and you do download it from one of these sites, please “pay it forward.” For example, help someone else learn the language once you’ve learned it. Or help someone in any way they need. Perhaps in the future you’ll be better off, and then you can pay for the book.
# Exercises and Solutions
Most atoms in Atomic Kotlin are accompanied by a handful of small exercises. To improve your understanding, we recommend solving the exercises immediately after reading the atom. Most of the exercises are checked automatically by the JetBrains IntelliJ IDEA integrated development environment (IDE), so you can see your progress and get hints if you get stuck.
You can find the following links at http://AtomicKotlin.com/exercises/.
To solve the exercises, install IntelliJ IDEA with the Edu Tools plugin by following these tutorials:
- Install IntelliJ IDEA and the EduTools Plugin (opens new window).
- [Open the Atomic Kotlin course and solve the exercises](https://www.jetbrains.com/help/education/learner-start-guide.html?section=Atomic Kotlin).
In the course, you’ll find solutions for all exercises. If you’re stuck on an exercise, check for hints or try peeking at the solution. We still recommend implementing it yourself.
If you have any problems setting up and running the course, please read The Troubleshooting Guide (opens new window). If that doesn’t solve your problem, please contact the support team as mentioned in the guide.
If you find a mistake in the course content (for example, a test for a task produces the wrong result), please use our issue tracker to report the problem with [this prefilled form](https://youtrack.jetbrains.com/newIssue?project=EDC&summary=AtomicKotlin%3A&c=Subsystem Kotlin&c=). Note that you’ll need to log in into YouTrack. We appreciate your time in helping to improve the course!
You can find information about live seminars and other learning tools at AtomicKotlin.com.
Bruce creates Open-Spaces conferences such as the Winter Tech Forum (opens new window). Join the mailing list at AtomicKotlin.com to stay informed about our activities and where we are speaking.
# Support Us
This was a big project. It took time and effort to produce this book and accompanying support materials. If you enjoy this book and want to see more things like it, please support us:
- Blog, tweet, etc. and tell your friends. This is a grassroots marketing effort so everything you do will help.
- Purchase an eBook or print version of this book at AtomicKotlin.com.
- Check AtomicKotlin.com for other support products or events.
# About Us
Bruce Eckel is the author of the multi-award-winning Thinking in Java and Thinking in C++, and a number of other books on computer programming including Atomic Scala (opens new window). He’s given hundreds of presentations throughout the world and puts on alternative conferences and events like the Winter Tech Forum (opens new window) and developer retreats. Bruce has a BS in applied physics and an MS in computer engineering. His blog is at www.BruceEckel.com (opens new window) and his consulting, training and conference business is Mindview LLC (opens new window).
Svetlana Isakova began as a member of the Kotlin compiler team, and is now a developer advocate for JetBrains. She teaches Kotlin and speaks at conferences worldwide, and is coauthor of the book Kotlin in Action.
- The Kotlin Language Design Team and contributors.
- The developers of Leanpub, which made publishing this book so much easier.
For my beloved father, E. Wayne Eckel. April 1, 1924—November 23, 2016. You first taught me about machines, tools, and design.
For my father, Sergey Lvovich Isakov, who passed away so early and who we will always miss.
# About the Cover
Daniel Will-Harris (opens new window) designed the cover based on the Kotlin logo.