bug:機器裡的那隻飛蛾
Every programmer knows the word "bug". It means a mistake in a computer program that makes it behave in the wrong way. But why do we use the name of an insect for a software problem?
There's a famous story about this. On 9 September 1947, a team of engineers at Harvard University was working on a huge early computer called the Mark II. The machine kept making errors, and when they looked inside, they found the cause: a moth had got trapped in one of the machine's electrical switches.
The engineers carefully removed the moth and taped it into their logbook. Next to it, someone wrote: "First actual case of bug being found." The story was later told many times by Grace Hopper, a pioneering computer scientist who worked on the machine, and the logbook – with the moth still in it – is now kept in a museum in Washington.
But here's the interesting part. Look closely at the words "first actual case". The engineers were making a joke. They already used "bug" to mean a technical fault, and they thought it was funny that this time, the bug was a real insect.
In fact, engineers had been talking about "bugs" for many decades. The famous inventor Thomas Edison used the word in a letter in 1878 to describe small faults and difficulties in his inventions.
So the moth didn't create the word "bug". But it did give us one of the best stories in the history of computing – and the phrase "debugging" has been part of every programmer's life ever since.
每個程式設計師都知道「bug」這個字,它指的是電腦程式裡讓程式執行出錯的錯誤。可是為什麼我們要用一種昆蟲的名字來稱呼軟體問題呢?
關於這個,有一個很有名的故事。1947 年 9 月 9 日,哈佛大學的一個工程師團隊正在處理一台叫做「馬克二號」的早期巨型電腦。這台機器老是出錯,他們打開一看,找到了原因:一隻飛蛾卡在機器的一個電子開關裡。
工程師們小心翼翼地把飛蛾取出來,用膠帶把它貼在工作日誌裡。旁邊有人寫著:「第一次真的發現了一隻蟲子(bug)。」後來,參與這台機器工作的電腦科學先驅葛麗絲.霍普多次講起這個故事。那本日誌——連同裡面的飛蛾——現在收藏在華盛頓的一間博物館裡。
但有趣的地方在這裡。仔細看看「第一次真的」這幾個字。工程師們其實是在開玩笑。他們早就用「bug」來表示技術故障了,覺得這次的「bug」竟然是一隻真正的蟲子,實在很好笑。
事實上,工程師們說「bug」已經說了好幾十年。大發明家湯瑪斯.愛迪生在 1878 年的一封信裡就用過這個字,用來形容他的發明中的小毛病和小麻煩。
所以,「bug」這個字並不是那隻飛蛾創造的。但它確實留給我們電腦史上最精彩的故事之一——而從那以後,「debugging」(除錯)就成了每個程式設計師生活的一部分。