A “bug” in a computer program or system is a common term used to describe an error, flaw or a mistake that produces wrong results… Usually bugs arise from mistakes and error made by people in their program’s source code.
But the question remains, why it is called a bug?
In 1947, computers used relays instead of transistors as they are today (or vacuum tubes some time between). Relays are little (usually magnetic) switches which are essentially a mechanical representation of binary (on or off).
During that time, Grace Murray Hopper was working on the Harvard University Mark II Aiken Relay Calculator (a primitive computer). On the 9th of September, 1947, when the machine was experiencing problems, an investigation showed that there was a moth trapped between the points of Relay #70, in Panel F. The operators removed the moth and affixed it to the log. The entry reads: “First actual case of bug being found.”
- The First “Computer Bug”
The word went out that they had “debugged” the machine and the term “debugging a computer program” was born.
Read more in http://en.wikipedia.org/wiki/Software_bug