You’ve probably heard it before: There’s a “bug” in the software, causing something to malfunction or misbehave. What exactly is a computer bug and where did the term come from? We’ll explain.
A Bug Is a Programming Error in Computer Software
A “computer bug” or “software bug” is a term for an unintentional programming mistake or defect in computer software. Bugs arise from human error at some point in the chain of hardware or from software tools used to create computer applications, firmware, and operating systems.
A software bug is born when a programmer either makes a mistake while writing the software or writes code that works but has unintentional consequences that were not foreseen by the programmer. Removing bugs from software is called “debugging.”
In today’s software-driven world, bugs are serious business. Almost 20 years ago, the National Institute of Standards and Technology estimated that software bugs cost the U.S. economy almost $60 billion annually (about 0.6% of the GDP in 2002)—a number that has likely increased since then. While accurately quantifying the negative effects of bugs is difficult, it’s easy to imagine how malfunctioning software can affect productivity. It can even put lives at risk in the realm of transportation or endanger vital infrastructure like power plants.
Why Do We Call Them Bugs?
The term “bug” predates the invention of computers, and we don’t actually know who originally coined the term “bug” to refer to an engineering defect. In written records, historians have traced it back to Thomas Edison in the 1870s at the earliest.
Edison used the term in his personal notes and correspondence to mean a difficult problem that needed solving or an engineering defect that needed fixing. He even joked about the term being related to insects, writing in an 1878 letter:
“You were partly correct, I did find a ‘bug’ in my apparatus, but it was not in the telephone proper. It was of the genus ‘callbellum.’ The insect appears to find conditions for its existence in all call apparatus of Telephones.”
While some take Edison’s examples to mean that he coined the term “bug,” it’s possible that it originated from someone else earlier and that he merely popularized the term among his engineering friends and associates. The Oxford English Dictionary cites an 1889 example related to Edison that describes a bug as a metaphor for an insect crawling into a piece of equipment and making it malfunction, suggesting that a real bug doing just that might have originally inspired the term, similar to the term “fly in the ointment.”
Setting the word “bug” aside for a moment, the first known person in history to realize that software may malfunction due to errors in programming was Ada Lovelace. She wrote about the problem way back in 1843 in her commentary about Charles Babbage’s Analytical Engine.
“To this it may be replied that an analysing process must equally have been performed in order to furnish the Analytical Engine with the necessary operative data; and that herein may also lie a possible source of error. Granted that the actual mechanism is unerring in its processes, the cards may give it wrong orders.”
In this quote, Lovelace refers to the actual calculating mechanism being error-free in the way that it processes data, but stipulates that the data fed to it by humans (as programmed on cards at the time) could give the machine the wrong instructions and thus produce the wrong results.
What About Grace Hopper’s Moth?
For decades, books, magazines, and websites have erroneously reported that the term “bug” was coined by legendary computer scientist Grace Hopper when a moth flew into the relays of the Harvard Mark II computer and caused it to malfunction. As the story goes, she then taped the moth into a logbook and wrote a historical note: “First actual case of bug being found.”
While a moth really did fly into the Mark II in 1947, it wasn’t the inspiration for the terms “bug” or “debug,” both of which predate the incident. Also, there’s no evidence that the moth actually made the computer malfunction, just that it was an amusing find. Hopper made the story famous by telling it in a widely cited November 1968 interview:
“When we were debugging Mark II, it was over in another building, and the windows had no screens on them and we were working on it at night, of course, and all the bugs in the world came in. And, one night she conked out, and we went to look for the bug and found an actual large moth, about four inches wing span, in one of the relays beaten to death, and we took it out and put it in the log book and pasted scotch tape over it, and as far as I know, that’s still in the historical log book up at Harvard (we found an actual bug in the computer).”
Hopper found the story amusing because, after frequently hunting down bugs in the computer (as in hardware and software defects), her team had finally found an actual, literal insect inside the computer. Hence the inscription, “First actual case of bug being found.”
(As an interesting aside, Hopper describes the Mark IV moth as “beaten to death,” likely because of the damage from getting caught within the movement of the computer’s electromechanical relays.)
Historians don’t know whether it was Hopper’s log book, or who actually wrote the entry, but today, the Harvard Mark II log book resides in the National Museum of American History at the Smithsonian in Washington, D.C.
While the Mark II moth (Let’s call him “Mark.”) wasn’t the first computer bug, it nevertheless persists as a physical and cultural symbol of a very real and difficult problem all programmers struggle with, and it’s something we’ll all be dealing with for years to come. Now pass me the bug spray, will ya?