Ebook: The elements of programming style
Author: Brian W. Kernighan P. J. Plauger
- Genre: Computers // Programming
- Year: 1978
- Publisher: Computing Mcgraw-Hill
- Edition: 2
- Language: English
- djvu
from PREFACE to the First Edition
Good programming cannot be taught by preaching generalities. The way to
learn to program well is by seeing, over and over, how real programs can be
improved by the application of a few principles of good practice and a little common
sense. Practice in critical reading leads to skill in rewriting, which in turn leads to
better writing.
This book is a study of a large number of “ real” programs, each of which pro¬
vides one or more lessons in style. We discuss the shortcomings of each example,
rewrite it in a better way, then draw a general rule from the specific case. The
approach is pragmatic and down-to-earth; we are more interested in improving
current programming practice than in setting up an elaborate theory of how pro¬
gramming should be done. Consequently, this book can be used as a supplement in
a programming course at any level, or as a refresher for experienced programmers.
The examples we give are all in Fortran and PL/I, since these languages are
widely used and are sufficiently similar that a reading knowledge of one means that
the other can also be read well enough. (We avoid complicated constructions in
either language and explain unavoidable idioms as we encounter them.) The princi¬
ples of style, however, are applicable in all languages, including assembly codes.
Our aim is to teach the elements of good style in a small space, so we concen¬
trate on essentials. Rules are laid down throughout the text to emphasize the les¬
sons learned. Each chapter ends with a summary and a set of “ points to ponder,”
which provide exercises and a chance to investigate topics not fully covered in the
text itself. Finally we collect our rules in one place for handy reference.
from PREFACE to the Second Edition
The practice of computer programming has changed since The Elements of Pro¬
gramming Style first appeared. Programming style has become a legitimate topic of
discussion. After years of producing “ write-only code,” students, teachers, and
computing professionals now recognize the importance of readable programs. There
has also been a widespread acceptance of structured programming as a valuable cod ¬
ing discipline, and a growing recognition that program design is an important phase,
too often neglected in the past.
We have revised The Elements of Programming Style extensively to reflect these
changes. The first edition avoided any direct mention of the term “ structured pro¬
gramming,” to steer well clear of the religious debates then prevalent. Now that the
fervor has subsided, we feel comfortable in discussing structured coding techniques
that actually work well in practice.
The second edition devotes a whole new chapter to program structure, showing
how top-down design can lead to better organized programs. Design issues are dis¬
cussed throughout the text. We have made considerable use of pseudo-code as a
program development tool.
We have also rewritten many of the examples presented in the first edition, to
reflect (we hope) a greater understanding of how to program well. There are new
examples as well, including several from the first edition which now serve as models
of how not to do things. New exercises have been added. Finally, we have
extended and generalized our rules of good style.
Good programming cannot be taught by preaching generalities. The way to
learn to program well is by seeing, over and over, how real programs can be
improved by the application of a few principles of good practice and a little common
sense. Practice in critical reading leads to skill in rewriting, which in turn leads to
better writing.
This book is a study of a large number of “ real” programs, each of which pro¬
vides one or more lessons in style. We discuss the shortcomings of each example,
rewrite it in a better way, then draw a general rule from the specific case. The
approach is pragmatic and down-to-earth; we are more interested in improving
current programming practice than in setting up an elaborate theory of how pro¬
gramming should be done. Consequently, this book can be used as a supplement in
a programming course at any level, or as a refresher for experienced programmers.
The examples we give are all in Fortran and PL/I, since these languages are
widely used and are sufficiently similar that a reading knowledge of one means that
the other can also be read well enough. (We avoid complicated constructions in
either language and explain unavoidable idioms as we encounter them.) The princi¬
ples of style, however, are applicable in all languages, including assembly codes.
Our aim is to teach the elements of good style in a small space, so we concen¬
trate on essentials. Rules are laid down throughout the text to emphasize the les¬
sons learned. Each chapter ends with a summary and a set of “ points to ponder,”
which provide exercises and a chance to investigate topics not fully covered in the
text itself. Finally we collect our rules in one place for handy reference.
from PREFACE to the Second Edition
The practice of computer programming has changed since The Elements of Pro¬
gramming Style first appeared. Programming style has become a legitimate topic of
discussion. After years of producing “ write-only code,” students, teachers, and
computing professionals now recognize the importance of readable programs. There
has also been a widespread acceptance of structured programming as a valuable cod ¬
ing discipline, and a growing recognition that program design is an important phase,
too often neglected in the past.
We have revised The Elements of Programming Style extensively to reflect these
changes. The first edition avoided any direct mention of the term “ structured pro¬
gramming,” to steer well clear of the religious debates then prevalent. Now that the
fervor has subsided, we feel comfortable in discussing structured coding techniques
that actually work well in practice.
The second edition devotes a whole new chapter to program structure, showing
how top-down design can lead to better organized programs. Design issues are dis¬
cussed throughout the text. We have made considerable use of pseudo-code as a
program development tool.
We have also rewritten many of the examples presented in the first edition, to
reflect (we hope) a greater understanding of how to program well. There are new
examples as well, including several from the first edition which now serve as models
of how not to do things. New exercises have been added. Finally, we have
extended and generalized our rules of good style.
Download the book The elements of programming style for free or read online
Continue reading on any device:
Last viewed books
Related books
{related-news}
Comments (0)