There’s a fun bit of etymological folklore that claims the use of the word “bug,” as in a computer bug, alludes to an actual insect that crawled inside what was, at the time, one of the largest and most powerful computers in the world.
BUG IN THE MACHINE

The story goes like this.
On September 9, 1947, a moth was discovered inside the mechanism of the Harvard Mark II, a gigantic 25-ton electromechanical computer housed at Harvard University. The moth, which unfortunately didn’t survive its run-in with the machine’s workings, was extracted from inside one of the Mark II’s many relay contacts and taped into the logbook alongside the caption, “First actual case of bug being found.” (Popular history even claims this line was the work of the legendary computer scientist and mathematician Grace Hopper, who was one of the Mark II’s programmers.)
This, the story concludes, is why computer errors and malfunctions are still known as “bugs” today.
ORIGIN OLDER THAN COMPUTERS

It’s a neat story, certainly. And, unusually for etymological tales like this, it is at least partly true: a moth was indeed found inside the Mark II back in 1947, and the luckless insect was genuinely taped into the Harvard logbook. Unfortunately, it’s unknown where Grace Hopper herself was involved in the discovery, and it seems unlikely that it was she who wrote the note. Even more unfortunately, however, it is not true at all that this is the origin of the computer “bug.”
Aside from the fact that that caption (“First actual case of bug being found”) seems to suggest that computer malfunctions were already known as bugs by the time the moth was found, the origins of mechanical bugs actually date back a lot further than the computers we now associated them with. So, although this mothy tale is certainly one of the earliest known records of a computer glitch being labelled a “bug,” it seems far more likely that this meaning developed from the far older use of a “bug” to refer to a defect or fault in any mechanical device or piece of machinery, which dates from mid 19th century America.
In fact, popular history also likes to claim that it was none other than Thomas Edison who first coined this earlier mechanical “bug”—but unfortunately this tale too seems a little misguided. While it’s certainly true that Edison knew and used the term (“Bugs’, as such little faults and difficulties are called,” he wrote in a letter of 1878), in truth the word has been unearthed somewhat further back in time than Edison’s writing, with the Oxford English Dictionary now dating this use of the word to 1875. So if not an actual bug, and if not an invention of Thomas Edison, where did this word come from?
While it has at least been suggested that the 19th century use of “bug” to mean a malfunction or defect might have been coined on the basis of people presuming mechanisms were being infected with insects, a more likely explanation is that this is simply a figurative extension of one of the word’s original meanings. When the word bug first appeared in the language way back in the late 1500s, it seems to have been particularly associated with insects and other creepy-crawlies that were considered a pest or annoyance, such as flies, maggots, or caterpillars.
This, in turn, led to the word being used as an insult in the 1700s for an equally unwelcome, unpleasant or irritating person (the same meaning that still survives in the verb bug, meaning to annoy someone). The use of bug to mean a glitch or malfunction that emerged a century later in the 1800s, ultimately, might simply be an extension of this older use of the word to mean something that annoys, or that you’d really rather not have to deal with.
