Software bug
A computer bug is a error in a computer program that prevents it from doing what it was intended to do. The term derives from hardware engineering, where design errors are called bugs.
Some writers call software design errors bugs, while others restrict the term to a flawed implementation of the program's design.
Either way, such errors are very common, and the effects are familiar to most computer users (see GPF, crash, freeze (computing)).
Software bugs can be very expensive. Steve McConnell recounts several bugs that cost over $100 million. Europe's [[[Ariane 5]] rocket that self-destructed due to a computer bug cost over $1 billion.
Due to their commonality and the potentially severe consequences of such bugs, much of 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 can often 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 proliferation of bugs is a natural consequence of the nature of the programming task. Computer programs are very complex systems, and it is impossible for programmers to keep every detail of one in their heads. One very common type of error occurs when the input to a section of a program violates the assumptions (be they explicit or implicit) of the implementer or designer of that section. Much effort has gone into design and programming techniques to reduce the frequency of this error type.
The academic discipline of software engineering has evolved as a response to the challenge of improving software quality, which in part means dealing with computer bugs and reducing their associated costs. (Software engineering also deals with more fundamental software design issues, which, as mentioned above, are not generally categorized as "bugs".) 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.