While the physical act of removing the moth was "debugging," the term evolved to encompass the logical process of fixing code errors.
The term “debug” has a charmingly literal origin story. In the 1940s, computers were massive electromechanical machines filled with vacuum tubes and relays. On September 9, 1947, operators of the Harvard Mark II computer at Harvard University traced an intermittent malfunction to a real moth trapped between two relay contacts. They taped the insect into their logbook with the caption: “First actual case of bug being found.” While the physical act of removing the moth
In modern software development, a bug represents any variance between expected behavior and actual behavior. Software engineer Brian Kernighan famously encapsulated the difficulty of resolving these issues through Kernighan's Law: On September 9, 1947, operators of the Harvard
At its simplest, is the process of identifying, analyzing, and removing bugs (errors, defects, or unexpected behaviors) from software or hardware systems. A bug can range from a syntax error that prevents compilation to a subtle logical flaw that causes data corruption once every million transactions. Debugging begins where testing ends: once you’ve discovered that something is wrong, debugging helps you find out why and fix it. A bug can range from a syntax error
Before diving into techniques, it helps to recognize the usual suspects. Bugs fall into several broad categories:
| Rookie Mistake | Professional Fix | | :--- | :--- | | Changing multiple things at once | Change one variable, test, revert. Isolate. | | "I'll just rewrite the whole module" | No you won't. That introduces new bugs. Fix the bug. | | Debugging without a stack trace | First, get the stack trace. If none, catch the exception. | | Assuming the library is broken | The library has 10 million users. You are the bug. | | No version control | Use git . Commit often. Tag releases. |