Book

Elements of Programming Style

by Brian W. Kernighan, P. J. Plauger

📖 Overview

The Elements of Programming Style is a programming guide first published in 1974 by Brian W. Kernighan and P. J. Plauger. The book examines real programming examples and proposes rules for writing clear, effective code. Through analysis of student programs written in FORTRAN and PL/I, the authors identify common mistakes and programming pitfalls. Each chapter focuses on specific aspects of programming, from data structures to documentation, with concrete examples of both problematic and improved code. The authors present 77 specific programming principles that emphasize readability, maintainability, and simplicity. Key concepts include proper variable naming, code organization, error handling, and testing methodologies. The book's enduring influence stems from its focus on fundamental programming concepts that transcend specific languages or technologies. Its core message about writing programs for human comprehension remains relevant to modern software development practices.

👀 Reviews

Readers describe this as a practical guide that teaches programming through examples of poor code that gets incrementally improved. Many note that despite being written in 1974 and using Fortran/PL/I examples, the principles remain relevant for modern programming. Liked: - Clear explanation of why each improvement matters - Short chapters focused on specific concepts - Real code examples showing before/after - Applicable across programming languages Disliked: - Dated programming language examples - Some readers found the writing style dry - Book length too short for deep coverage From one reviewer: "The lessons are timeless even if the examples aren't. The authors show exactly why certain programming practices lead to problems." Ratings: Goodreads: 4.18/5 (486 ratings) Amazon: 4.6/5 (31 ratings) Notable that many current programmers mention re-reading it multiple times throughout their careers for its foundational lessons in code clarity and maintenance.

📚 Similar books

Code Complete by Steve McConnell A comprehensive guide to writing clean, maintainable code with practical examples and proven techniques.

Clean Code by Robert C. Martin The book presents specific practices for crafting readable code through real-world examples and refactoring techniques.

Structure and Interpretation of Computer Programs by Harold Abelson, Gerald Jay Sussman The text explores programming fundamentals through the lens of Lisp while teaching principles that apply across languages.

Programming Pearls by Jon Bentley A collection of programming problems and their solutions that emphasize code efficiency and elegant design.

The Practice of Programming by Brian W. Kernighan The book covers practical programming topics from debugging to portability with examples in multiple languages.

🤔 Interesting facts

🔹 This influential programming book was inspired by Strunk & White's "The Elements of Style," borrowing its approach of teaching through examples and its focus on clear, simple expression. 🔹 The book's examples were originally written in PL/1 and Fortran (1974 edition), but were later updated to Pascal (1978 edition), reflecting the evolution of programming languages during that period. 🔹 Co-author Brian Kernighan also co-created the AWK programming language and co-wrote "The C Programming Language" with Dennis Ritchie, which became the definitive reference for C programming. 🔹 Many of the book's programming principles, such as "Write clearly - don't be too clever" and "Make it right before you make it faster," remain fundamental guidelines in software development nearly 50 years later. 🔹 The authors developed these programming guidelines while teaching at Bell Labs, where many revolutionary computing developments occurred, including Unix and the C programming language.