Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
Programming Kotlin
Samuel S., Bocutiu S., Packt Publishing, Birmingham, UK, 2017. 420 pp. Type: Book (978-1-787126-36-7)
Date Reviewed: Jan 15 2018

It has been said that Java’s greatest contribution is the Java virtual machine (JVM). This is borne out by the proliferation of other JVM languages. While Java is (understandably) slow to change, other JVM languages have experimented with many new syntactic and semantic features. JVM languages include Scala, Clojure, Groovy, and, since 2011, Kotlin, which has the distinction of being the second official language for Android. However, Kotlin can be used anywhere that Java is used, and this book addresses Kotlin for general programming and is not limited to Android development.

Like Java, Kotlin is an object-oriented language, but it also has a strong and convenient functional-programming subset, which Java only started providing at version 8. Kotlin’s design decisions influence the ease of use of various language features in a way different from Java’s. For example, Kotlin makes it just as easy to create immutable variables (declared with “val” rather than “var,” as opposed to the extra “final” keyword in Java) and classes are final by default. Kotlin provides various mechanisms that are not available in Java, for example, top-level functions (which are compiled into hidden classes in the JVM). Kotlin is much less verbose than Java, not least because of type inference that reduces the need for type declarations and casts. Scala inspired several Kotlin concepts, such as data classes, the companion object, and immutable collections.

The book’s first chapter explains Kotlin tools and integrated development environments (IDEs), making it easy for readers to try out code snippets from the book. This is followed by an introduction to various language features. The third chapter deals with object-oriented features of the language, an unusually early placement of this topic. This chapter discusses Kotlin’s object-oriented features, including classes, interfaces, inheritance and polymorphism, and delegation. However, the claim in the chapter summary that readers who have no previous experience with object-oriented programming can now write object-oriented code is widely exaggerated; it may perhaps be true in terms of the syntax, but there is a great deal more to object-oriented programming that the book doesn’t cover at all.

The following chapters discuss functions (with a separate chapter on higher-order functions and functional programming), properties, null safety, generics, data classes, and collections. The final chapters address more advanced topics: unit tests, microservices, and concurrency. Other advanced subjects are addressed in the appropriate places. These include reflection, annotations, and domain-specific languages inside Kotlin. This last discussion uses as an example a unit-testing framework, which is similar in spirit to the KotlinTest framework presented in the chapter on unit testing.

Kotlin doesn’t have native support for some useful features found in similar languages, such as currying, memoization, and disjoint union; the chapter on functional programming explains how to implement these in Kotlin with minimal effort.

I expect every technical book to contain crisp definitions accompanied by well-thought-out examples that illustrate the point being made with as little extraneous material as possible. Examples should be small yet make sense (on their own or as part of a coherent set of related examples) and should not have any misleading content. Unfortunately, this book falls short in this respect. Definitions are not always provided and tend to be rather vague, relying heavily on examples. Moreover, the examples also suffer from various problems. Some are self-admittedly contrived, or have caveats such as “never use it like this,” while others are misleading or even wrong. Some of the statements made in the book are also incorrect, so readers need to be alert and check claims against the documentation or experiment for themselves.

The preface claims that “no prior knowledge of functional or object-orientated programming is required.” However, the earlier statement that “the book is targeting Java and Scala developers primarily” is actually the case. Knowledge of Java is assumed, and various Kotlin constructs are explained by reference to the corresponding Java features. Concepts derived from Scala are also provided with short explanations with references to the Scala equivalents, relying on some knowledge of Scala. Many explanations use compiled bytecode, but no introduction to bytecode is given, making these parts hard to understand for the many Java programmers who can’t read bytecode.

The book contains many mistakes that should have been caught during proofreading, such as typographical errors, wrong words (“destruction” instead of “destructuring”), missing text and spaces, and bad line breaks and indentation in the code examples.

In summary, this book covers a lot of material, including some advanced concepts, but requires a lot of effort from readers to overcome confusing and sometimes incorrect text.

More reviews about this item: Amazon, Goodreads

Reviewer:  Yishai Feldman Review #: CR145770 (1803-0122)
Bookmark and Share
  Reviewer Selected
Featured Reviewer
 
 
Language Constructs and Features (D.3.3 )
 
 
Multiparadigm Languages (D.3.2 ... )
 
 
Object-Oriented Languages (D.3.2 ... )
 
 
Applicative (Functional) Programming (D.1.1 )
 
Would you recommend this review?
yes
no
Other reviews under "Language Constructs and Features": Date
A stub generator for multilanguage RPC in heterogeneous environments
Gibbons P. IEEE Transactions on Software Engineering 13(1): 77-87, 1987. Type: Article
Aug 1 1987
Essentials of programming languages
Friedman D. (ed), Haynes C., Wand M., MIT Press, Cambridge, MA, 1992. Type: Book (9780262061452)
Feb 1 1994
Symbolic computing with Lisp
Cameron R., Dixon A., Prentice-Hall, Inc., Upper Saddle River, NJ, 1992. Type: Book (9780138778460)
Apr 1 1994
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy