Java-related books are perhaps the most widely available books in terms of diverse selections of any programming language. Even so, most Java books seem to fall into one of two categories: they are either introductory/general level books or they are highly focused specific books. These books all have their place and many of them have been beneficial to me in my career, but I'm always on the look out for that rare combination of the two: the book that is relatively general in terms of Java coverage, but is more advanced or looks at the topic quite differently than an introductory or typical general Java book. Books such as Effective Java and Java: The Good Parts come to mind as books that strive to hit this sweet spot. In this book review, I look at soon-to-be-released (in print, with electronic version available already) The Well-Grounded Java Developer, a book whose topic selection has interested me since first hearing about it in early 2011.
The initial paragraph of the "About This Book" section summarizes the authors' intent:
Welcome to The Well-Grounded Java Developer. This book is aimed at turning you into a Java developer for the modern age, reigniting your passion for both the language and platform. Along the way, you’ll discover new Java 7 features, ensure that you’re familiar with essential modern software techniques (such as dependency injection, testdriven development, and continuous integration), and start to explore the brave new world of non-Java languages on the JVM.
The authors of The Well-Grounded Java Developer, Ben Evans and Martijn Verburg, are instrumental players in the London Java Community, a member of the Java SE/EE Executive Committee in the Java Community Process. Both also speak at Java-related conferences with Martijn being well-known as the Diabolical Developer and Ben Evans as "the voice of reason?"
The title of the book and the selection of topics are what appealed to me most about the advertised content of The Well-Grounded Java Developer when I first saw its Table of Contents in the early MEAP edition. The chosen topics seem appropriate for experienced Java developers who are too busy developing solutions for their customers to spend time trying out features of Java 7, delving deeply into the intricacies of Java and the JVM, or playing with the major alternative JVM languages. I have worked with many solid Java developers who are great at Java, but don't have the time or inclination to play with the latest versions of Java or with JVM languages other than Java until or unless they need to for their job role. This book is a perfect quick introduction to these topics for such developers. A single book provides the highlights of Java SE 7 along with introduction material related to the three most popular non-Java JVM languages. It also throws in in-depth coverage of some advanced topics for making good Java developers better. In addition, the book includes information on modern Java development tools.
The Well-Grounded Java Developer is divided into four multi-chapter parts along with five appendices. Part 1 ("Developing with Java 7") introduces new features of Java SE 7 with focus on Project Coin (Chapter 1) and NIO.2 (Chapter 2).
Part 1 : Java 7
Chapter 1 ("Introducing Java 7") briefly discusses Java the language and Java the platform along with other general characteristics of the Java programming language (open source now, compiled or interpreted nature, etc.). The remainder of the first chapter covers various Project Coin features including switching on String, enhanced numeric literal syntax, improved exception handling, try-with-resources (automatic resource management), diamond operator syntax, and simplified variable arguments.
Chapter 2 ("New I/O") provides brief overview and history of NIO in Java before delving into details of Java 7's NIO.2. The chapter introduces NIO.2 via the all-important Path interface and looks at how this new interface enables improved file input/output (with Files class and other handy new files handling mechanisms).
Part 2 : Vital Techniques
Part 2 ("Vital Techniques") of The Well-Grounded Java Developer continues covering new Java 7 features, but the focus is shifted from the first part. In the first part, the focus was on the features new to Java 7. In the second part, other features new to Java 7 are covered, but in this part they are covered as a means to a different end than simply introducing new Java 7 features. The intent of this second part is to provide more in-depth coverage of "vital techniques" that Java developers should know. As the introduction to this part states, it is about "exploring vital programming knowledge and techniques with Java." These "vital techniques" are dependency injection (Chapter 3), concurrency (Chapter 4), class files and bytecode (Chapter 5), and performance tuning (Chapter 6).
Although there are great books devoted to some of these topics covered in Part 2 (Java Concurrency in Practice and Java Performance for example), many Java developers don't have the time, interest, or inclination to purchase and read these books. These chapters help to get a Java developer going with these ideas and more comprehensive books can be referenced when more comfortable with the subject or when more details are needed.
Chapter 3 ("Dependency Injection") provides an introduction to dependency injection (DI) and contrasts it with the encompassing concept of inversion of control (IoC). The chapter introduces JSR 330 ("Dependency Injection for Java") and discusses using Google Guice as an implementation of JSR 330.
The introduction to Chapter 4 ("Modern Concurrency") includes this description of the intent of the chapter:
The aim of this chapter is to make you aware of the underlying platform mechanisms that explain why Java’s concurrency works the way it does. We’ll also cover enough general concurrency theory to give you the vocabulary to understand the issues involved, and to teach you about both the necessity and the difficulty involved in getting concurrency right.
Chapter 5 ("Class Files and Bytecode") is one of the book's chapters that I think can be of most value to the highest percentage of intermediate to advanced Java developers. Classloading is one of the most frustrating issues in Java development and the fifth chapter attacks that topic head-on. A feature new to Java 7, method handles, are then covered. Method handles are described in this chapter as the "new Java 7 way to achieve the same ends [as the Java Reflection API], with much cleaner code."
When I reviewed the book Java Reflection in Action, I noted that one of its few weaknesses was its age (2004/JDK 1.4) and I concluded that "the most glaring omission from a book on Java reflection is Java 7's introduction of method handles, but few Java books in print today cover these." The Well-Grounded Java Developer is a welcome exception to this statement with an entire section (5.2) devoted to the topic.
I've been a big fan of the javap tool ("Java Class File Disassembler") that comes with the HotSpot SDK, but one of the things that has made it more difficult to learn to use that tool effectively is lack of easily accessible documentation on it. Section 5.3 ("Examining Class Files") of the fifth chapter goes a long way toward remedying that deficiency. Besides introducing javap
, the ambitious 5.3 section also covers reading bytecode. This chapter is dense with detail, but this is welcome detail and a great introduction to the subject.
The final section of Chapter 5 (Section 5.5 on "invokedynamic") introduces Java 7's invokedynamic. The introduction to the section notes where this subject likely likes in terms of interest to general Java developers:
[invokedynamic] isn’t a feature that will necessarily be used directly by every working developer, because it involves a very advanced use case. This feature is for frameworks developers and non-Java languages at present.
Chapter 6 ("Understanding Performance Tuning") introduces Java and JVM performance tuning by reminding the reader that performance tuning is often not necessary and depends on measurement with realistic loads. The chapter provides definitions of performance-related terminology and introduces "a pragmatic approach to performance analysis." This sixth chapter also discusses the garbage collection in more details than most Java developers are probably aware of and introduces some of the Oracle (HotSpot) JVM options that can be used.
Chapter 6 also introduces another Oracle JVM command-line tool (jmap) ["Memory Map"] and provides descriptive text on how to read jmap's output (similar to approach used with javap coverage in Chapter 5).
Part 3 : Alternative JVM Languages
Part 3 ("Polyglot Programming on the JVM") moves beyond the Java programming language and focuses on alternative languages running on the JVM. The authors point out that learning about these alternative JVM languages can be useful to Java developers because "many of the new ideas that will be needed in the future are present in other JVM languages today." I'll also add that, at least in the case of Groovy, I've found it useful already for things where Java is not as strong (scripting).
Chapter 7 ("Alternative JVM Languages") introduces this third part of the book focused on alternative JVM languages. This chapter covers why one would be interested in an alternative JVM language before delving into how alternative JVM languages can be used to support functional programming concepts on the JVM. The chapter outlines different ways to classify non-Java JVM languages such as interpreted versus compiled, statically typed versus dynamically typed, and imperative versus functional. The chapter also contrasts completely new languages designed for the JVM (Groovy, Scala, Clojure) with "reimplementation" languages (pre-existing languages ported to the JVM such as Jython, JRuby, and Rhino).
Chapter 7 provides information on how to decide which alternative JVM language to choose for different situations. The authors quickly introduce the non-Java JVM languages that each get a chapter's focus (Groovy, Scala, and Clojure) and explain why they selected these languages upon which to focus.
We’ve picked three languages that we see having the greatest
potential longevity and influence. These are the languages on the JVM (Groovy, Scala,
and Clojure) that already have well-established mind share among polyglot programmers.
After Chapter 7 kicks off Part 3 on polyglot programming on the JVM, the next three chapters of Part 3 each focus on a specific alternative JVM language: Chapter 8 ("Groovy: Java’s dynamic friend"), Chapter 9 ("Scala: powerful and concise"), and Chapter 10 ("Clojure: safer programming"). Each of these three chapters provides an overview of the respective alternative JVM languages. Of course, a single chapter is not sufficient to comprehensively introduce a programming language, so these chapters focus on the strengths of each covered language. They also cover things such as Java interoperability (for Groovy and Clojure) and use contrasting of the languages with Java to illustrate language features.
Part 4 : Applying Alternative Language and New Java Techniques and Tools
Part 4 ("Crafting the Polyglot Project") applies information covered earlier in the book to "some of the most common and important techniques in modern software development." Three of the four chapters in this part look at modern software development techniques (test-driven development, building/continuous integration, and rapid web development). The concluding chapter of the fourth part looks at what the future holds for Java.
Chapter 11 ("Test-Driven Development") introduces TDD, JUnit, Mockito, and ScalaTest. This chapter also looks at different ways to implement "test doubles" (dummy, stub, fake, mock). Chapter 12 ("Build and Continuous Integration") introduces tools Maven 3, Jenkins, FindBugs, Checkstyle, and Leiningen (for Clojure projects).
Chapter 13 ("Rapid web development") covers issues with developing web applications using Java. It looks at several different popular Java web frameworks before focusing specifically on Grails (Groovy) and Compojure (Clojure).
Chapter 14 ("Staying Well-Grounded") begins with the sentence, "To stay ahead of the curve, the well-grounded Java developer should always be aware of what’s coming around the corner." This chapter then looks at the authors' perspective on the future of Java. The authors cover Java 8 with specific focus on the two most significant features of that version: lambda expressions and Jigsaw modularity. The chapter also looks at JVM changes making polyglot programming easier and more productive and at improved concurrency support. It ends by looking at other JVM trends.
Appendices : Background / Supporting Information
Besides the four parts with 14 chapters, The Well-Grounded Java Developer also includes five appendices: Appendix A ("Java7developer - source code installation"), Appendix B ("Glob pattern syntax and examples"), Appendix C ("Installing alternative JVM languages"), Appendix D ("Downloading and installing Jenkins"), and Appendix E ("Java7developer - the Maven POM"). These appendices provide example code related to the book as well as other useful reference information related to topics covered in the book.
The Book's Audience
The Well-Grounded Java Developer hits its goal of being aimed at and primarily beneficial for the Java developer who wants to be a "well-grounded Java developer." Newer Java developers can learn much about basic tools, techniques, and approaches in Java. Moderately experienced Java developers are likely to pick up new tools and techniques or to gain a better and deeper understanding of principles about the Java language and about the JVM.
Most experienced Java developers will likely find much to learn from this book, especially if they are too busy developing applications to spend the time trying out three alternative JVM languages along with the new features of Java in Java 7 and Java 8. I know several Java developers who I consider very experienced and even they would benefit from some of the low-level details this book provides. For example, the sections on javap
and jmap
are as good as introductions and concise reference as I've seen for those respective Oracle JVM tools.
Although I think nearly all Java developers can learn new things, new approaches, and new techniques from The Well-Grounded Java Developer, I think the book is particularly well-suited for the Java developer who feels comfortable with Java, but has not had a lot of time in recent years to come up to speed on the popular alternative JVM languages or the features of Java 7 and 8 (closures and modularity). This book can provide a quick "tune-up" to bring these experienced Java developers up to speed on the latest happenings.
Disclaimer
It is trendy currently to talk about how "transparent" one is. In an effort to fit in with this trend, I must acknowledge here factors that might be misconstrued as affecting my judgment. First, the authors have kindly included a reference to my blog post on Groovy JSON support in The Well-Grounded Java Developer. This is a book that I'm very happy to have my name and my blog associated with and that may prove my opinion of this book more than anything else.
A second potential conflict of interest that one might misconstrue to affect my judgment is author Martijn Verburg's (@karianna) tweet-out of my Twitter handle (@DustinMarx). That single tweet increased the number of people "following" me on Twitter by several times my previous number. However, I had planned to write this review and had the general gist of it in mind well before this Tweet.
Manning Early Access Program (MEAP)
I enjoyed having access to portions of The Well-Grounded Java Developer earlier than its formal publication via the Manning Early Access Program. This is an especially valuable program when the forthcoming book is on subjects that are very new (such as Java 7).
The Downsides
The Well-Grounded Java Developer's primary downsides are related to the fact that it cannot be everything to everyone (nothing can!). The book is great at helping Java developers kick-start their efforts at becoming well-grounded. However, as the authors acknowledge multiple times in the book, many of the subjects will require additional reading of other sources for more details on subjects introduced in this book. Also, the book cannot possibly cover every "new" thing coming to the world of Java. For example, JavaFX is not mentioned in the book, though the current Java.net poll may end up indicating that JavaFX may not have yet earned enough community-wide respect and acceptance to warrant such a mention.
Conclusion
I was excited about the prospect of The Well-Grounded Java Developer when I initially read about it and it has delivered to a level matching even those high expectations. This is that rare book I'm always on the lookout for that stretches me as a general Java developer. Many highly-focused and specific Java-related books do this for me in one area of Java, but this book helped me to learn and realize things in several different aspects of Java and the JVM.
I have used Java for many years and was a fairly early adopter of Java 7. I have also been a huge fan of Groovy for a while now and I read and write blogs frequently, but I still found numerous details and insights in this book that I had not thought about previously. I work with many great Java developers who spend far less time reading blogs, working with alternative JVM languages, or trying out new features of Java and I'd expect them to gain even more useful insights from reading The Well-Grounded Java Developer. As Dr. Heinz Kabutz wrote in the book's forward, "Studying this book will help you become a well-grounded Java developer. Not only that, it will give you tips on how to stay well-grounded." This book comes from a great idea and is an example of where a delivered product meets the lofty expectations of the original idea.