Why did I love this book?
This tour de force probably couldn't get written today. Kernighan and Plauger take snippets of Fortran and PL/I code from real, published textbooks and find things to fix about them. Now, many of their specific concerns are relics of the "structured programming" wars of the 1960s (overuse of arithmetic IF and GOTO) or quirks of the programming languages in question (undeclared variables silently getting the wrong type); but this is educational in itself. If you wonder what's so bad about GOTO, or why we need to declare functions and variables before use, this book may enlighten you. And despite its age, almost every example finds some present-day analog. For example, Kernighan and Plauger's advice to avoid manually counted Hollerith strings in Fortran applies equally to manually counted array bounds in C++: don't write "int a[5]" when you can write "int a[]". The authors boil every couple of pages down to a language-agnostic mantra, such as: "Let the machine do the dirty work." "Make input easy to prepare and output self-explanatory." "If a logical expression is hard to understand, try transforming it."
The title, of course, is a reference to Strunk and White's The Elements of Style (1959), which has its own mantras equally applicable to software design: "Put statements in positive form." "Use orthodox spelling." "Express coordinate ideas in similar form." But that's a story for another day.
1 author picked The Elements of Programming Style as one of their favorite books, and they share why you should read it.
This rounds out a collection of works by Kernighan. Each book of his covers a different aspect of software, in clear form with logical concepts. This book covers the look and feel of the code itself. As with the other works, some concepts have evolved as languages have evolved and the normal size of software projects has continued to expand. But the book still has many relevant points and is an interesting read for those wanting to delve into how software development as a process has been growing and evolving over time.
- Coming soon!