Software bug: Difference between revisions

Content deleted Content added
m new article, needs links
 
extensive copyedit - took out C++/Java argument as it's really not relevant here
Line 1:
A '''computer bug''' is ana error that occurs in a computer program. Often theseSuch canerrors beare detectedvery common, and "handled",the asconsequential byfailures [[Visualare Basic|Visualfamiliar Basic's]]to '''Onmost Errorcomputer Goto'''users. statement orThe C++term andis [[Javagenerally Programmingused Language|Javato describe mistakes that result of a flawed implementation of the program's]] '''throwdesign, .rather .than .mistakes catch'''in syntaxthe 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.
Programmers generally find it easier to find and fix computer bugs that they can reproduce. Some will refuse to even try to find irreproduceable bugs, as the effort required is often harder by orders of magnitude.
 
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. <I>explain why!</I>
 
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 [[Java programming language|Java]] does not support pointers.
 
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.
 
In C++, a common and vexing source of computer bugs is memory addressing. Overrunning the end of an array or accessing an non-existent [[object]] can cause hard-to-trace errors. Java does not permit the programmer to address memory directly or to perform address arithmetic, and all array references are checked. Fans of Java maintain that Java is superior to C++ in this respect.
 
It is considered [[best practices|good programming practice]] to anticipate possible program errors and write error handlers for them. Unanticipated errors are a prime source of computer bugs.
 
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.