Dr. Dobb's Journal October 2003
It's still a bit of a shock sometimes to realize how long Java has been around. Eight years is a long time in our industrylong enough for two generations of undergraduates to have it as a first language, and long enough for books about it to go into their second edition.
Which is a welcome thing, because by and large, only good books are updated and reprinted. Take Jack Shirazi's Java Performance Tuning, for example. Shirazi is the driving force behind http://www.javaperformancetuning.com/, a site devoted to making Java programs faster, smaller, and more efficient. As the book acknowledges, speed has always been Java's Achilles' Heel. While today's compilers and virtual machines are much better than their predecessors, Java programs are still noticeably slower than their C or C++ counterparts. Knowing how to avoid performance bottlenecks is, therefore, an important part of a Java programmer's education, as is knowing how to fix them when they haven't been avoided.
Java Performance Tuning starts by asking a simple question: "Why is it slow?" After presenting a simple strategy for methodical tuning, Shirazi looks at the tools programmers have (or can build) for collecting performance data, including timing and memory-usage profilers. He then spends a chapter on JVM improvements, presenting such tricks as replacing standard JDK classes with ones tailored to application needs, uncompressing JAR files, and so on.
Chapters 4-11, which span over 250 pages, form the meat of the book. Object creation, strings, exceptions, casts, loops, I/O, threadingShirazi looks at how thoughtless use of each can lead to performance problems, and then presents ways to make those problems go away. Many of the examples include before-and-after speeds or quantitative comparisons of different approaches, which help to ground the discussion and set your expectations.
The last eight chapters of the book cover more advanced topics, such as J2EE and JDBC. This material is (necessarily) higher level than what's in the first half, but no less enjoyable. I think everyone who is using Java in real-world applications will get a lot out of this book, and I expect to refer to it often.
I will probably get almost as much out of Eric Burke and Brian Coyner's Java Extreme Programming Cookbook, although I think the eight tools they cover are as useful to other programming styles as they are to XP. This book covers almost exactly the same material as Hightower and Lesiecki's Java Tools for eXtreme Programming (reviewed here in May 2002), and in almost the same order. After one chapter introducing XP, the authors present solutions for common problems with:
Burke and Coyner answer most of the questions that first-time users of these tools will have, while also providing more background detail for people who are already familiar with them. Throughout, their explanations are clear, and both their text and their code samples are easy to read. I might have asked for more diagrams, and for a chapter each on a couple of other tools (most notably CVS and Checkstyle), and I think that if web testing deserves three chapters, then GUI testing deserves at least one, but these are quibbles with an otherwise impressive book.
The third book this month is JDBC: Practical Guide for Java Programmers, by Gregory Speegle. This book is a slim, easy-to-read introduction to the essentials of Java database connectivity. All of JDBC's core features are covered in just enough detail to leave the reader feeling comfortable with what the API is for, and how it ought to be used. Each chapter ends with a short API summary, and a "Going Beyond" section that instructors could use as a starting point for exercises.
I enjoyed Speegle's book, and will recommend it to students. However, I will probably not recommend the MySQL and Java Developer's Guide, by Mark Matthews, Jim Cole, and Joseph D. Gradecki. It does contain more information than Speegle's book, but it also contains more bugs. For example, pages 36-37 list the data types supported by MySQL. Page 37 then repeats this list, word for word, in a different font. I realize this is just a typesetting glitch, but there are enough others, and enough places where the text seems to have been thrown together in a hurry, that I found my confidence in the book ebbing. The nearly unreadable screen shots of DOS Windows didn't help matters either. On balance, I think developers would be better off reading Speegle's tutorial, and then going straight to online documentation.
DDJ