“Programming Pearls” by Jon Bentley is a book based on a collection of articles written by the author for the eponymous column in Communications of the ACM. True to its name, the book presents several pearls of programming wisdom based on the hard-won experience of a brilliant computer programmer who was also lucky enough to be associated with some of the brightest minds in computer programming (the group at Bell Labs). The icing on the cake is the clarity and brevity of the book. I have read the book at least three times over the years and I continue to learn new things from it - no wonder this book is considered a classic in computer programming.
The book is divided into three parts with five chapters per part. The first part presents the fundamentals of programming, from programme design to algorithms, data structures, programme verification and testing. The second part focusses on performance and shows how to perform rough estimations of running costs, improving algorithms, tuning code and saving space. The third part applies the principles of the previous two parts to problems in sorting, searching and string-processing.
The chapters are short, clear and peppered with interesting anecdotes. These make them easy to read, though it would be a terrible mistake to zip through them. The author himself recommends that you take the time to understand the concepts presented in a chapter and attempt solving the given problems yourself before taking a look at the solutions. The chapters only give you a flavour for some of the concepts - you'll have to supplement it with reading a suitable book if you are not familiar with these concepts. Here the author has some recommendations and the usual suspects (The Art of Computer Programming, Code Complete, The Practice of Programming, etc.) all figure prominently.
The author ends the book with a couple of amusing epilogues presented as interviews with himself. He takes a dig at himself for the frequent references in the book to his colleagues from Bell Labs. One of the appendices contains rules for code tuning adapted from his now-out-of-print book “Writing Efficient Programs”. I suspect that an absolute beginner would have some trouble understanding these recommendations since they are presented here without much elaboration or examples, though there are references to related material elsewhere in the book. Another appendix presents a model for estimating the costs of various data-types and operations. These can be used to make quick back-of-the-envelope calculations about the time and space that will likely be taken by a given function during its execution.
Some of the material, like that on performance improvement or programme verification, might not be very fashionable today, but no serious computer programmer can afford to ignore it. Much of the advice in this book is timeless and will definitely help you become a better programmer.
Note that the web-site for the book as given in it, “www.programmingpearls.com”, is not valid any more.
The sequel to this book was published as “More Programming Pearls: Confessions of a Coder”. That book is a little hard to find in most book-shops as it did not become as famous as this one.