The Elements of Programming Style

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 or personal programming "style", but also for "readability" by humans, specifically software maintenance engineers, programmers and technical writers.

The book pays explicit homage, in title and tone, to The Elements of Style, by Strunk & White and is considered a practical template promoting Edsger Dijkstra's structured programming discussions. It has been influential and has spawned a series of similar texts tailored to individual languages, such as "The Elements of C Programming Style", "The Elements of C# Style", "The Elements of Java(TM) Style", "The Elements of MATLAB Style", etc.

The book is built on short examples from actual, published programs in programming textbooks. This results in a practical treatment rather than an abstract or academic discussion. 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 (one example in the second edition is from the first edition).

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.) However, many of the book's points that generally concern stylistic and structural issues transcend the details of particular languages.

Famous quotes containing the words elements, programming and/or style:

    Let us have a fair field! This is all we ask, and we will be content with nothing less. The finger of evolution, which touches everything, is laid tenderly upon women. They have on their side all the elements of progress, and its spirit stirs within them. They are fighting, not for themselves alone, but for the future of humanity. Let them have a fair field!
    Tennessee Claflin (1846–1923)

    If there is a price to pay for the privilege of spending the early years of child rearing in the driver’s seat, it is our reluctance, our inability, to tolerate being demoted to the backseat. Spurred by our success in programming our children during the preschool years, we may find it difficult to forgo in later states the level of control that once afforded us so much satisfaction.
    Melinda M. Marshall (20th century)

    Sometimes among our more sophisticated, self-styled intellectuals—and I say self-styled advisedly; the real intellectual I am not sure would ever feel this way—some of them are more concerned with appearance than they are with achievement. They are more concerned with style then they are with mortar, brick and concrete. They are more concerned with trivia and the superficial than they are with the things that have really built America.
    Lyndon Baines Johnson (1908–1973)