[x^2 for x in lst]

Modern Java in Action

Author: Raoul-Gabriel Urma

Review created: 2019-05-02

I bought Modern Java in Action because I wanted to learn how to use CompletableFutures better. I also thought it would be a good idea to get a good overview of other features in recent Java versions that I might have missed. I was not disappointed.

The book has three focus areas: streams, Completable futures and functional programming in Java. Of course it covers other topics as well, but these are the areas where it spends the majority part of its 542 pages.

The book are divided in the following chapters:

  • Java8, 9, 10, 11: what's happening?
  • Passing code with behavioural parameterization
  • Lambda expressions
  • Introducing streams
  • Working with streams
  • Collecting data with streams
  • Parallel data processing and performance
  • Collection API enhancements
  • Refactoring, tesing and debugging
  • Domain-specific languages using lambdas
  • Using Optional as a better alternative to null
  • New date and time API
  • Default methods
  • The Java module system
  • Concepts behind CompletableFuture and reactive programming
  • CompletableFuture and composable asynchronous programming
  • Reactive programming
  • Thinking functionally
  • Functional programming techniques
  • Blending OOP and FP: Comparing Java and Scala
  • Conclusions and where next for Java

The book also contains three appendices:

  • Miscellaneous language updates
  • Miscellaneous library updates
  • Performing multiple operations in parallel on a stream
  • Lambdas and JVM bytecode

The book is written in an easy to understand way which is easy to follow. It contains a good mix of text and code examples. Like very many other programming related books, no exercises are included in the book. This is something that, although expected, I always find a little bit dissapointing. For me, it is so much easier to try to solve a specified exercise than come up with some of my own in order to practise something I've read about in the book. I wish that I had better imagination so I could come up with some nice exercises of my own when reading about some new or interesting technology, but I haven't.

Although the book is quite long and contains much material, it does not feel that long. This is something I've also felt when reading other "in action" books. Maybe it's the writing style of the authors', maybe it is the mix of examples and text content, I don't know, but that's they way it feels.

The book gives a good overview of the features that are new in Java 8 and 9. As previously mentioned it has a focus of streams and functional programmming. Other Java features like lambdas, default methods in interfaces and Optionals are also covered thoroughly. Something I find very useful, as we currently use Java 8 at my work, is that the things that were added to Java 9 is highlighted in a good way when discussing some topic. e.g. streams. This makes it easier for us that still is stuck on Java 8 to see what features we cannot use.

So did I get the coverage of CompletableFutures that I wanted when buying this book? Yes, I think I did. The book have three chapters covering concurrent programming and one of those is dedicated to programming with CompletableFutures. The book examines the main methods of chaining CompletableFutures together and getting them to do what you want. I must say that this is the best coverage of the topic that I've read. Really nice!

I also found the chapters on lambdas, streams, and Optionals really useful. The coverage of the new Date API was very good and nicely written. The explanation of the classes included in the API and the code examples made easy to understand how the classes fit together, how they can be manipulated and converted to nicely formatted strings and so on.

The chapter on the new Java module system gave a brief but clear explanation of that, in my opinion, somewhat dry topic. Of course, the book does not treat this topic in depth; that would have required a much longer (and more boring) book.

Two of the appendices summarizes the new features of Java 8 and Java 9 that weren't included in the main part of the book. I think this was a good idea to summarize them in appendices. Now when one know that they exist, one can easily google more info about them.

Summary: Modern Java in Action is a good book if you want to brush up on the new features of Java 8 and Java 9. It covers the main new features in depth and briefly discusses the lesser changes either in the main text or in one of the appendices. I recommend it for anyone interested in these topics. If you're also interested in functional programming and how to practice such in Java, there is a lot of material for you as well.

Rating: 4 of 5.