The Elements of Programming Style
![]() | This article is written like a review. (May 2009) |

The Elements of Programming Style, by Brian W. Kernighan and P. J. Plauger, is a study of programming style, advocating the notion that computer programs should be written not only to satisfy the compiler, but also with human readers in mind (especially software maintenance engineers).
The book pays explicit homage, in title and tone, to The Elements of Style, by Strunk & White.
The book is built on short examples from actual, published programs. Its advice is therefore delivered not in an academic or pedagogical vacuum, but rather in the context of examples which are believable and realistic, sometimes uncomfortably so. The style is diplomatic and generally sympathetic in its criticism, and unabashedly honest as well— some of the examples with which it finds fault are from the authors' own work.
Its lessons are summarized at the end of each section in pithy maxims, such as "Let the machine do the dirty work."
Modern readers may find it a shortcoming that its examples use older procedural programming languages (Fortran and PL/I) which are quite different from those popular today. (Few of today's popular languages had been invented when this book was written.) But perceptive readers can nevertheless appreciate and learn from most of the book's points, which generally concern stylistic and structural issues that transcend the idiosyncrasies of particular languages.
References
- B. W. Kernighan and P. J. Plauger, The Elements of Programming Style, McGraw-Hill, New York, 1974. ISBN 0-07-034199-0
- B. W. Kernighan and P. J. Plauger, The Elements of Programming Style 2nd Edition, McGraw Hill, New York, 1978. ISBN 0-07-034207-5