Bookshelf Classic: More Programming Pearls

Book cover with keyboard and pearls
If you were to judge a book by its cover, you would, from the image of the keyboard, conclude this book is old.  If you were to judge this book by what's inside, you would conclude likewise because the examples are written in C and Awk.  But were you to look deeper, you would see that these are no ordinary pearls.

Jon Bentley wrote a regular column for the Association for Computing Machinery (ACM) and his essays were collected into two of books: "Programming Pearls" and "More Programming Pearls."   The first book focused on speed and efficiency, while the second book covered that and more, including debugging, I/O, and enlightening "Aha!" moments.

Because these essays were originally written for a monthly magazine, Bentley recommends taking it slow, reading one column per sitting, and trying the exercises.  Thankfully, he doesn't leave you hanging, and provides answers at the end of the book.  Chapters 5 thru 8 are the exception and can be read in one sitting because they are just plain fun.

In chapter 5, one pearl reminds us to plumb what the user really wants:

An operations researcher was assigned to devise an elevator scheduling policy to minimize passenger waiting time in a certain building.  After visiting this building, he realized the problem his employer really wanted to solve was to minimize the discomfort to the passengers (who didn't enjoy waiting for elevators).  He solved the problem by installing mirrors near each elevator.  The passengers then spent their waiting admiring themselves, and complaints about the speed of the elevators were dramatically reduced.

Transferring this insight to long running programs, Bentley added a live status message along the lines of "Processing record 597 of 985".  Compared to a program that ran twice as fast but didn't inform the user when it would finish, he learned his users preferred predictability more than speed.

Chapter 6, titled "Bumper-Sticker Computer Science," is filled with funny and clever sayings drawn from his readership.

On coding: If you have too many special cases, you are doing it wrong.

On performance: The fastest I/O is no I/O.

On managing software: The structure of a system reflects the structure of the organization that built it.

A weightier chapter discusses little languages.  While big languages such as C++ and Java do the heavy lifting, little languages allow processes to work together. An example from the IBM mainframe days would be JCL, or Job Control Language. Modern day equivalents would include scripting languages such as Bash, and data description languages such as XML and JSON.  But Bentley explored even "littler languages" -- custom languages that were designed for a specific purpose -- namely Pic which is used for making line drawings. Aspiring compiler writers would benefit from this pearl, as Bentley breaks down lexical analysis, syntax analysis, code generation, and symbol tables.

Then again, you needn't be a compiler writer to appreciate this pearl.  Some time ago, I worked on a project that required a configuration file.  XML would have been suitable and JSON even better, but the project predated both.  Thus, we developed tools to read, write, delete, flatten, export, and analyze our own configuration file, with good results.

Bentley's writing is clear and friendly.  He makes deep subjects approachable, and connects light subjects in ways to reveal insights.  Real pearls get scuffed, deteriorate, and turn yellow with age, but these pearls will endure.  There's something in this book for everyone.


Popular posts from this blog

Post Processing: Swift, Kotlin, Team Scaling Fallacy, Levandowski

Programmer Humor for the Holidays

Apple's Busy End of Year