The Elements of Programming Style

This is an old revision of this page, as edited by Qutezuce (talk | contribs) at 00:52, 21 November 2005 (cleanup). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The Elements of Programming Style, by Brian W. Kernighan and P. J. Plauger, is a seminal book in the study of programming style, advocating the notion that computer programs should be written not only to satisfy the compiler, but rather also with human readers in mind.

Cover of the second edition

A particular strength of the book is that it is built on examples taken from actual, published programs. The book's advice is therefore delivered not in some academic pedagogical vacuum, but rather in the context of examples which are believably realistic -- sometimes all too uncomfortably so. The authors are diplomatic and generally sympathetic in their criticisms, and unabashedly honest as well, in that some of the examples which they find fault with and seek to improve in the second edition were taken from their own first edition.

The book's lessons are summarized in a series of pithy, eminently quoteworthy maxims, such as "Let the machine do the dirty work."

The book pays explicit homage -- in title and tone -- to The Elements of Style, by Strunk & White.

One shortcoming of the book for modern readers is that its examples use older programming languages -- Fortran and PL/I -- which are less than representative of the ones popular today. (None of today's popular languages had been invented when this book was written.) A perceptive reader can nevertheless appreciate and learn from most of the book's points, which generally concern stylistic and structural issues which transcend the idiosyncracies of particular languages.

References

  • B. W. Kernighan and P. J. Plauger, The Elements of Programming Style, McGraw-Hill, New York, 1974. ISBN 0070341990
  • B. W. Kernighan and P. J. Plauger, The Elements of Programming Style 2nd Edition, McGraw Hill, New York New York, 1978. ISBN 0070342075