The first edition of Programming Pearls was one of the most influential books I read early in my career, and many of the insights I first encountered in that book stayed with me long after I read it. Jon has done a wonderful job of updating the material. I am very impressed at how fresh the new examples seem. -Steve McConnell
When programmers list their favorite books, Jon Bentley's collection of programming pearls is commonly included among the classics. Just as natural pearls grow from grains of sand that irritate oysters, programming pearls have grown from real problems that have irritated real programmers. With origins beyond solid engineering, in the realm of insight and creativity, Bentley's pearls offer unique and clever solutions to those nagging problems. Illustrated by programs designed as much for fun as for instruction, the book is filled with lucid and witty descriptions of practical programming techniques and fundamental design principles. It is not at all surprising that Programming Pearls has been so highly valued by programmers at every level of experience.
In this revision, the first in 14 years, Bentley has substantially updated his essays to reflect current programming methods and environments. In addition, there are three new essays on "testing, debugging, and timing set representations, string problems." All the original programs have been rewritten, and an equal amount of new code has been generated. Implementations of all the programs, in C or C++, are now available on the Web.
What remains the same in this new edition is Bentley's focus on the hard core of programming problems and his delivery of workable solutions to those problems. Whether you are new to Bentley's classic or are revisiting his work for some fresh insight, the book is sure to make your own list of favorites.
Review By: Harmon Avera, Jr. 02/04/2007The second edition of "Programming Pearls" is a collection of essays that originally appeared in "Communications of the ACM," revised, edited, and updated for this book. Just as a real pearl is produced in response to an irritant, the columns in Bentley’s book are gem-like solutions to irritating programming problems. Bentley holds the collection together with a writing style is very personal and approachable--almost like discussing an intriguing problem with him over a cup of coffee.
The book is slightly less than 250 pages and divides the collected columns into three main parts—Preliminaries, Performance, and The Product—with additional sections at the end that include Appendices, Problem Hints and Solutions, and an extensive index. Each column explores solutions to different programming problems and has questions at the end to encourage further study. This second edition includes several new problems, solutions, and appendices, making it about 25 percent longer than the first edition. Where appropriate, solutions are presented in pseudo code.
The first section, Preliminaries, sets the stage for the rest of the book with simple, low-level problems and shows the steps of problem definition, algorithm and data structure selection, and verification, as well as the “Simple Matter of Programming” step of actually writing and testing the code. The Performance section includes columns on estimation, algorithm design, code tuning, and squeezing code into less space. The final five columns in The Product section provide focal points where the techniques of the previous columns converge in real applications.
The appendices are an excellent reference section and include a catalog of algorithms discussed in the book as well as a set of code tuning rules taken from an earlier book that is no longer in print.
The First edition of this book has occupied a special place on my bookshelf for almost twenty years. Its very first column grabs you with a seemingly simple question and goes on to show how an elegant solution depends critically on correct problem definition. Software testers are well aware of the importance of clear requirements, and Bentley uses the theme of careful problem definition to springboard discussions of algorithm selection, design verification, and program testing. This edition preserves the original book’s magic while updating perspectives, questions, and solutions. Bentley’s actual code implementations (not originally available) and the newer sections on testing, debugging, and timing are welcome additions. For example, one of my favorite columns discusses how hard it is to get a correct code implementation of “binary sort” and how assertions and program verification techniques can help.
Although this book focuses on developing code solutions to small programming problems, it shows the importance of problem definition (requirements) and unit-level testing (assertions, verification) to developing elegant and robust software solutions. The book can be read quickly, but there are information-dense sections that take time and effort to grasp and appreciate. Bentley’s writing style makes it well worth the effort—you can almost feel the wheels turning as he describes his journey toward solutions in each column. I also tried answering some of the interesting end-of-column questions and, when I got stuck, the solution hints at the end of the book were an enjoyable treasure hunt in themselves. I consider this book a classic that should be required reading for developers and testers alike.