Bumper-Sticker Computer Science

More Programming Pearls
Confessions of a Coder
by
Jon Louis Bentley

Introduction

pi seconds is a nanocentury.

Tom Duff
Bell Labs

Regression testing cuts test intervals in half.

Larry Bernstein
Bell Communications Research

Absence makes the heart grow fonder.

Anon

Out of sight, out of mind.

Anon

Plagiarism is the sincerest form of flattery.

Anon

Coding

When in doubt, use brute force.

Ken Thompson
Bell Labs

Avoid arc-sine and arc-cosine functions---you can usually do better by applying a trig identity or computing a vector dot-product.

Jim Conyngham
Arvin/Calspan Advanced Technology Center

Allocate four digits for the year part of a date: a new millennium is approaching.

David Martin
Norristown, Pennsylvania

Avoid asymmetry.

Andy Huber
Data General Corporation

The sooner you start to code, the longer the program will take.

Roy Carlson
University of Wisconsin

If you can't write it down in English, you can't code it.

Peter Halpern
Brooklyn, New York

Details count.

Peter Weinberger
Bell Labs

If the code and the comments disagree, then both are probably wrong.

Norm Schryer
Bell Labs

If you have too many special cases, you are doing it wrong.

Craig Zerouni
Computer FX Ltd.
London, England

Get your data structures correct first, and the rest of the program will write itself.

David Jones
Assen, The Netherlands

User Interfaces

[The Principle of Least Astonishment] Make a user interface as consistent and as predictable as possible.

Contributed by several readers

A program designed for inputs from people is usually stressed beyond breaking point by computer-generated inputs.

Dennis Ritchie
Bell Labs

Twenty percent of all input forms filled by people contain bad data.

Vic Vyssotsky
Bell Labs

Eighty percent of all input forms ask questions they have no business asking.

Mike Garey
Bell Labs

Don't make the user interface provide information that the system already knows.

Rick Lemmons
Cardinal Data Systems

For 80% of all data sets, 95% of the information can be seen in a good graph.

William S. Cleveland
Bell Labs

Debugging

Of all my programming bugs, 80% are syntax errors. Of the remaining 20%, 80% are trivial logical errors. Of the remaining 4%, 80% are pointer errors. And the remaining 0.8% are hard.

Marc Donner
IBM Watson Research Center

It takes three times the effort to find and fix bugs in system test than when done by the developer. It takes ten times the effort to find and fix bugs in the field than when done in system test. Therefore, insist on unit tests by the developer.

Larry Bernstein
Bell Communications Research

Don't debug standing up. It cuts your patience in half, and you need all you can muster.

Dave Storer
Cedar Rapids, Iowa

Don't get suckered in by the comments---they can be terribly misleading. Debug only code.

Dave Storer
Cedar Rapids, Iowa

Testing can show the presence of bugs, not their absence.

Edsger W. Dijkstra
University of Texas

Each new user of a new system uncovers a new class of bugs.

Brian Kernighan
Bell Labs

If it ain't broke, don't fix it.

Ronald Reagan
Santa Barbara, California

[The Maintainer's Motto] If we can't fix it, it ain't broke.

Lieutenant Colonel Walt Weir
United States Army

The first step in fixing a broken program is getting it to fail repeatably.

Tom Duff
Bell Labs

Performance

[The First Rule of Program Optimization] Don't do it.

[The Second Rule of Program Optimization---For experts only] Don't do it yet.

Michael Jackson
Michael Jackson Systems Ltd.

The fastest algorithm can frequently be replaced by one that is almost as fast and much easier to understand.

Douglas W. Jones
University of Iowa

One some machines indirection is slower with displacement, so the most-used member of a structure or a record should be first.

Mike Morton
Boston, Massachusetts

In non-I/O-bound programs, less than four percent of a program generally accounts for more than half of its running time.

Don Knuth
Stanford University

Before optimizing, use a profiler to locate the "hot spots" of the program.

Mike Morton
Boston, Massachusetts

[Conservation of Code Size] When you turn an ordinary page of code into just a handful of instructions for speed, expand the comments to keep the number of source lines constant.

Mike Morton
Boston, Massachusetts

If the programmer can simulate a construct faster than a compiler can implement the construct itself, then the compiler writer has blown it badly.

Guy L. Steele, Jr.
Tartan Laboratories

To speed up an I/O-bound program, begin by accounting for all I/O. Eliminate that which is unnecessary or redundant, and make the remaining as fast as possible.

David Martin
Norristown, Pennsylvania

The fastest I/O is no I/O.

Nils-Peter Nelson
Bell Labs

The cheapest, fastest and most reliable components of a computer system are those that aren't there.

Gordon Bell
Encore Computer Corporation

Most assembly languages have a loop operation that does a compare and branch in a single machine instruction; although it was intended for loops, it can sometimes be used to do a general comparison very efficiently.

Guy L. Steele, Jr.
Tartan Laboratories

[Compiler Writer's Motto---Optimization Pass] Making a wrong program worse is no sin.

Bill McKeenan
Wang Institute

Electricity travels a foot in a nanosecond.

Commodore Grace Murray Hopper
United States Navy

Lisp programmers know the value of everything and the cost of nothing.

Alan Perlis
Yale University

Documentation

[The Test of Negation] Don't include a sentence in documentation if its negation is obviously false.

Bob Martin
AT&T Technologies

When explaining a command, or language feature, or hardware widget, first describe the problem it is designed to solve.

David Martin
Norristown, Pennsylvania

[One Page Principle] A {specification, design, procedure, test plan} that will not fit on one page of 8.5-by-11 inch paper cannot be understood.

Mark Ardis
Wang Institute

The job's not over until the paperwork's done.

Anon

Managing Software

The structure of a system reflects the structure of the organization that built it.

Richard E. Fairley
Wang Institute

Don't keep doing what doesn't work.

Anon

[Rule of Credibility] The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.

Tom Cargill
Bell Labs

Less than 10% of the code has to do with the ostensible purpose of the system; the rest deals with input-output, data validation, data structure maintenance, and other housekeeping.

Mary Shaw
Carnegie-Mellon University

Good judgement comes from experience, and experience comes from bad judgement.

Fred Brooks
University of North Carolina

Don't write a new program if one already does more or less what you want. And if you must write a program, use existing code to do as much of the work as possible.

Richard Hill
Hewlett-Packard S.A.
Geneva, Switzerland

Whenever possible, steal code.

Tom Duff
Bell Labs

Good customer relations double productivity.

Larry Bernstein
Bell Communications Research

Translating a working program to a new language or system takes ten percent of the original development time or manpower or cost.

Douglas W. Jones
University of Iowa

Don't use the computer to do things that can be efficiently done by hand.

Richard Hill
Hewlett-Packard S.A.
Geneva, Switzerland

Don't use hands to do things that can be efficiently done by the computer.

Tom Duff
Bell Labs

I would rather write programs to help me write programs than write programs.

Dick Sites
Digital Equipment Corporation
(the quote made its appearance in Dick's thesis (1974) and seems to have undergone slight mutations since then)

[Brooks's Law of Prototypes] Plan to throw one away, you will anyhow.

Fred Brooks
University of North Carolina

If you plan to throw one away, you will throw away two.

Craig Zerouni
Computer FX Ltd.
London, England

Prototyping cuts the work to produce a system by 40%.

Larry Bernstein
Bell Communications Research

[Thompson's Rule for First-Time Telescope Makers] It is faster to make a four-inch mirror and then a six-inch mirror than to make a six-inch mirror.

Bill McKeenan
Wang Institute

Furious activity is no substitute for understanding.

H.H.Williams
Oakland, California

Always do the hard part first. If the hard part is impossible, why waste time on the easy part? Once the hard part is done, you're home free.

Always do the east part first. What you think at first is the easy part often turns out to be the hard part. Once the easy part is done, you can concentrate all your efforts on the hard part.

Al Schapira
Bell Labs

Miscellaneous Rules

[Sturgeon's Law---This applies as well to computer science as to science fiction] Sure, 90% of all software is crap. That's because 90% of everything is crap.

Mary Shaw
Carnegie-Mellon University

If you lie to the computer, it will get you.

Peter Farrar
Germantown, Maryland

If a system doesn't have to be reliable, it can do anything else.

H.H.Williams
Oakland, California

One person's constant is another person's variable.

Susan Gerhart
Microelectronics and Computer Technology Corporation
(however, see below)

One person's data is another person's program.

Guy L. Steele, Jr.
Tartan Laboratories

[KISS] Keep it simple, stupid.

Anon

Principles

Eschew clever rules.

Joe Condon
Bell Labs

Clarifications

[December 1997] I received the following clarification from Susan Gerhart regarding the attribution of the quotation to her (thanks, Susan):

No big deal, but the quote attributed to me is a non-gender version of Alan Perlis' "one man's constant is another man's variable". Somehow the Perlis attribution got dropped. If you ever correct your web page with these quotes, please add something along these lines "(really from Alan Perlis"). I think the quote appeared in the acknowledgements of my thesis hence it got atributed to me.

susan gerhart


[ Miscellaneous | Krishna Kunchithapadam ]


Last updated: Sun Jun 27 17:00:19 PDT 2004
URL: http://geocities.datacellar.net/krishna_kunchith/misc/bscs.html

1