Bugs refer to faults in computer programs—usually caused by a programming error—which lead to unexpected behaviour. They often lead to unrecoverable errors, but they can also be less severe and harder to find.
Usage of the term "bug" to refer to faults or defects in engineering predates computers. Invention of the term "bug" to refer to computer faults is usually attributed to operators of the Harvard Mark II, a computer built at Harvard University and finished in 1947, after they traced an error to a moth trapped in a relay. The moth was removed and taped to the log book, which is now on display at the Smithsonian National Museum of American History.
Debugging refers to the process of finding and eliminating bugs. Debugging is often said to be the most difficult task in programming. Sometimes the problem caused by the bug only occurs much later, long after the faulty code has executed. A programmer needs to have a lot of patience to find and correct the bugs.
Tools that aid programmers in debugging are called debuggers. Source-level debuggers generally allow the programmer to set "breakpoints" on certain lines of code, pausing the program and allowing the programmer to inspect and change variables. Debuggers are often included in integrated development environments.