A computer bug is a error in a computer program. Such errors are very common, and the consequential failures are familiar to most computer users. The term is generally used to describe mistakes that result of a flawed implementation of the program's design, rather than mistakes in the design itself.
Computer bugs can be very expensive. Steve McConnell recounts several bugs that cost over $100 million. The Ariane rocket that self-destructed may have cost over $1 billion. Due to their commonality and the potentially severe consequences of such bugs, much and the time and effort of programmers is spent reviewing and testing code before it goes into production use, and finding and fixing bugs located by such reviews and tests. This effort is typically greater than that expended actually writing the program in the first place.
It became obvious very early on in the history of digital computers that bug-finding and fixing would be a major component of programmer activity. Maurice Wilkes, an early pioneer, described his realisation in the late 1940's that much of the rest of his life would be spent finding mistakes in his own programs. He was proven correct, as the complexity of computer programs grew bugs grew ever more common and difficult to fix.
The prolification of bugs is a natural consequence of the nature of the programming task. explain why!
The entire academic discipline of software engineering has evolved as a response to the challenge of computer bugs, and the effort to reduce the many costs of dealing with them. Modern computer languages, programming environments, common programming techniques and development methodologies include many of the lessons learned.
For example, most programmers are taught to write their programs in such a way that they can recover from some bugs, or at least detect their presence and inform the user of their existence. Programming language features such as exception handling support this concept. Modern languages also attempt to eliminate features that are known to be bug-prone - for instance the Java programming language does not support pointer arithmetic.
Once bugs have been reported, it is the task of the programmer to locate and fix them. Such bug fixing is an art, and whilst guidelines have been developed to assist novice programmers to learn this skill, it generally comes with experience. Generally, the first step in locating a bug is finding a way to reproduce it easily. Some bugs are very difficult to reproduce - for instance, some bugs disappear when the program is run under the microscope of a debugger. Once reproduced, the programmer usually uses specialised tools to monitor the execution of the program in the faulty region and figures out precisely what is causing the problem.