Review Of Kotlin For Android Developers

Review Of the Book Kotlin For Android Developers

This is a review of the book Kotlin For Android Developers by Antonio Leiva, an Android Engineer working for an international company.

When you have to pick an educational book the first thing you have to understand is:

  1. what kind of book is
  2. whose the book is for

When it comes to books aimed to teach a new programming language they can roughly divided in two groups: theoretical and pragmatic ones. A theoretical book can be a 1000+ page book that teach all the aspects of the language, from the platform to each construct, usually in a logic order of ascending difficulty. Instead a pragmatic book teaches a language explaining the concepts, while you meet them in the course of building something, like an app.

A book may be too short or change arguments too quickly for a beginner audience or, vice versa, it might have a too slow pace for an advanced user. Granted, some books are just bad, but usually the problem is that the reader picked the wrong book.

Audience Of The Book

The title itself of the book Kotlin For Android Developers does a good job in clarifying its type and audience: it is a pragmatic book for experienced Android developers that want to pick up Kotlin. Which means that it builds upon your Android knowledge to teach you how to do with Kotlin the stuff you already know to do with Java.

To put in another way: the book does not explain how to create Android applications, if you do not already know how to do that. In fact, if you are not an experienced Android developer, you will not understand what is going on or why somethings matters. Probably you will not even understand Kotlin that well.

This also means something that might be obvious to some, but not all: there is very little theory. You should already know how the tools work (e.g., Gradle) and what things like delegates or lambda are. Only the chapter on Generics explains a bit of the theory behind them. Also, typically the issues with using a certain feature are not discussed, unless the issue is related to the Kotlin approach.

For instance, when listing the operators that you can overload that is what the book has to say about identity comparison in Kotlin:

Operators === and !== do identity checks (they are == and != in Java respectively)
and can’t be overloaded.

─ Chapter 11, p. 49

In short, if you an expert programmer that complains constantly about filler content, you are the perfect audience for this book. If you are a novice that needs hand-holding you should look elsewhere and maybe come back later to this book, once you have covered your basis.

Structure Of The Book

The book does not really have a formal structure, for the most part: there are 30 short chapters about several aspects you will encounter developing an Android app. An Android developer might notice that the order of the chapters resembles how a real app is developed: you create a working app as soon as possible and then you refactor it to make it beautiful.

Although to be fair most of the time the chapters does not seem to follow any particular order. We cannot really understand if there is any reason to explain control flow expressions in chapter 22 of 30. On the other hand, given the audience of the book, this is not really a problem because you are supposed to already know your way around an Android app.

In our opinion, this approach makes sense given the audience (developers with experience on Android). Busy developers can jump quickly to the point they are interest into, while skipping parts that are not extremely important for them right now. Experts do not need someone to draw the path for them, they need pointers to find quickly the information they are looking for.

There are only a few minor issues related to the order of topics. For example, reified generics are discusses before the chapter on generics; the REPL and the online playground are not mentioned in the Getting ready chapter, but in the introduction of the chapter about classes.

The internal structure of each chapter is more consistent: there is usually a problem and the code that solve it, all related to a weather app that is used throughout the book. The code of each chapter is presented in its entirety in the companion repository of the book. The reader is constantly reminded of the repository. Also, frequently the author note that the chapter only discuss the major modifications to the code and not everything that is in the repository. We think that code should be at the center of books about programming, so we really liked this approach.

There are a few chapters that just list, or explain, things about Kotlin, without any reference to the app. For example, chapter 11, that lists which operators you can overload, or chapter 18, that lists collections and related operations of the Kotlin standard library.

Content Of The Book

The book covers all the main aspects of Kotlin: from variables and null safety to generics and lambdas. So there is no complain to be made there. They are also covered in pragmatic terms, you are rarely going to see a few pages without any code. When this happens is usually because of the few things that needs an explanation, or a list, like the operators that you can overload. There is also a chapter for coroutines, an experimental features of Kotlin 1.1, which is a nice surprise. Of course, all the content is explained with Android development and issues in mind.

The book also covers a few essential libraries and tools: Anko and the Kotlin Android Extensions. Anko is a library composed of several modules and many of them are used in the book: Anko SQLite, Anko Coroutines, etc. The addition of this library, which will probably be used by almost all developers, is a good example of the benefits of the pragmatic approach of the book. You are going to learn most of what you are going to use in your everyday development for Android with Kotlin.

The only important thing that the book does not talk about is Anko Layouts. And the reason is that the author does not care about it, which is a perplexing choice or, at the very least, a perplexing justification.

Anko is a powerful library developed by JetBrains. Its main purpose is the generation of UI layouts by using code instead of XML. This is an interesting feature I recommend you to try, but I won’t be using it in this project. To me (probably due to years of experience writing UIs) using XML is much easier, but you could like this approach.

─ Chapter 7, p. 33

Maybe it is true that most Android developers are used to XML, just like author, but it seems an odd reason to exclude something, especially since the author itself present it as the main purpose of the library.

In any case, with this choice the author miss the chance to talk about type-safe builders, which can be useful to build also HTML layouts or any kind of type-safe hierarchical data.

Summary

Once you understand the audience of the book you are going to agree that it has only a few flaws. The content you need is all there, although you could argue that some chapters devoted to theory are a bit thin.

For instance, the first chapter, that explains why you should use Kotlin for Android is a bit short. It does not really introduce all the good things of Kotlin (e.g., Anko) that the book will talk about, and it does not present well the one it mentions (e.g. Expressiveness shows only data classes and not other features linked to expressiveness). But this is mostly nitpicking.

The structure of the book can be perplexing. However, since the book is for experienced Android developers, this might be annoying for some, but not problematic for the target audience.

On the other hand if you know Android and prefer a pragmatic and code-first approach this book is the best you can find to learn Kotlin to use it for your Android apps.

There is no filler content, not a word more than the one you need to get you going and there is no quicker way to learn how to use Kotlin in your job.

A nice touch is that the author periodically updates the book, also based on the feedback he receives. The updates are sent automatically for the digital version. Buyers of the physical one can ask the author for free access to an updated digital edition.

Disclaimer: the author gave us a copy of the book for the review but we do not have any agreement for affiliate marketing or any other interest in recommending this book.

1 reply
  1. Antonio
    Antonio says:

    Thanks so much for this review! I take note of the flaws you mention, and will do my best to solve them on future updates. This is an alive book, so (at least in the digital edition) everything can be improved.

    Keep up the great work with SuperKotlin.

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *