Bugs are errors in computer programs that cause the software to not work as it should. Usually, bugs are caused by an error in the program code that is often only discovered by users when using the program.
The name bug comes from the time when the first computers were developed. The huge calculating machines worked with large circuits, relays and partly mechanical elements. Insects often crawled into the computer case and caused a short circuit or similar malfunction. Testimony of such a finding is a logbook entry with a glued-in beetle, which was found in the' Mark II Aiken Relay Calculator' in 1947, after a malfunction.
The use of the term bug for a fault in a mechanical and/or electrical system is, however, even older: Thomas Edison is said to have spoken of bugs as early as 1878, when he told a friend about difficulties with his inventions.
Bugs occur in a wide variety of variants. Since programs are created by humans, statistical frequency of errors in the source code is expected. The larger a program is, the more likely it is that bugs will be detected either in beta testing or by users. There are different types of errors that lead to bugs.
1.) Lexical errors are misspelled or unknown input words. Depending on the programming paradigm used, only certain correctly written commands of a particular language (usually English) are possible. Even a lower case or an incorrect translation can result in a program error.
2.) Syntax errors are characterized by the fact that the available characters of the respective programming language were not used correctly. If a semicolon or quotation marks are missing, the program can abort at these points.
3.) Semantic errors occur when program parts such as a parameter or an argument are incorrectly defined. The syntax can be completely correct, but an error in the declaration can lead to unwanted results.
4.) If the program still contains an error that only becomes apparent during the test run, this is known as a runtime error. The compiler translates the program into binary code so that the computer can run the program. If unexpected values for certain variables occur, it can abort, even though everything seems to be alright in formal terms.
5.) Runtime errors are closely related to logical errors. In particular, large programs can produce undesirable results due to logical errors in the source code. The program does not terminate, but it outputs data that it is not supposed to output. Logical errors can also produce security holes.
Avoiding bugs starts with the planning of a programming project, in what is called software engineering. The phases of a project are defined according to the objectives of the programme. Structural processes ensure that the program outputs exactly what it is supposed to output. This is accompanied by a documentation of the development process in order to be able to carry out simple changes afterwards.
However, since some bugs are only discovered when many users use the program, alpha and beta tests are carried out before the program is released. Even after the release of a program, bugs can be fixed by updates, bugfixes or patches. A known bug is Heartbleed, for example.