adlfkjfadslkjfads

Book Review: Java Puzzlers

Posted on Mon 20 January 2014 in Posts

Book: Java Puzzlers

Authors: Joshua Bloch and Neal Gafter

Publisher: Addison Wesley

Pages Read: all

Sections: all

Thumbs up/Thumbs Down? Up, slightly sideways

Link: Amazon

Summary of Content Read

Java Puzzlers is not so much a book, but a collection of obscure corner cases in the Java programming language. The author (Joshua Bloch) is well known as the author of Effective Java which is widely regarded as the premier text for the language, and furthermore they are one the designers and authors of the Java Collections Framework. So to say the least, they know their stuff.

Each chapter of the book features a collection of "puzzlers" centered around a particular section of the language (examples include loops, strings, exceptions, classes, etc). Each "puzzler" is formulated where a puzzle (typically in the form of a code snippet) is given, and the reader is encouraged to try and predict what the output will be, or why the code is incorrect. Then an answer/explanation of the puzzler is given. All-in-all there are 95 different puzzlers across the book, and they range from the fairly common "if you thought about it a bit you'd figure it out" to the extremely obscure "unless you were a Java language designer you'd never have any hope of figuring this out". The explanations also often include commentary to language designers (ex: "the lesson for language designers here is...").

From an academic "curiosity" point of view the book is quite intriguing. As a fairly experienced Java developer I found myself surprised with the vast majority of the puzzlers. The programming languages guy in me found this fascinating (ex: wait, so you can have Unicode literals in comments, and those literals are interpreted by the compiler?).

Having said that, the book does reach a point where the puzzles and concepts hit upon by the puzzles are extremely obscure. For a typical Java developer you'll almost never run into most of the tidbits in this book. That's not to say that reading it isn't useful, you'll definitely learn a bit about the book, but if you're looking to learn "how to write good Java code" this is not the book for you (again, see Bloch's other book for that).

(Note: this post originally appeared on my blogspot blog at: http://codependentcodr.blogspot.ca/2014/01/book-java-puzzlers-authors-joshua-bloch.html)