The Elements of Programming Style

This is an old revision of this page, as edited by SimonTrew (talk | contribs) at 04:53, 12 March 2009 ("less than representative"? What's wrong with "different"?). 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 also with human readers in mind.

Cover of the second edition

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

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 an academic or pedagogical vacuum, but rather in the context of examples which are believably realistic, sometimes 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.

Its lessons are summarized at the end of each section in pithy maxims, such as "Let the machine do the dirty work."

One shortcoming of the book for modern readers is that its examples use older 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.) 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 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 New York, 1978. ISBN 0-07-034207-5