Bugs and Debugging
Mistakes are normal — here is how to find them and fix them
- say what a bug and an error are in simple words,
- explain why bugs are a normal part of coding,
- use a simple, calm method to find and fix a bug.
1. What is a bug?
A bug is a mistake in the instructions we give a computer. The computer does exactly what the code says — so if the code has a mistake, the computer does the wrong thing. The bug is not really in the computer; it is in the steps we wrote.
Why is a mistake called a "bug"? Long ago, a real insect flew into an early computer and stopped it from working. People took the insect out and joked that they were "debugging" the machine. The funny name stuck, and today every coder in the world talks about bugs.
2. What is an error?
An error is what you notice when something goes wrong. There are two common kinds:
- The computer stops and shows a message. It might say something like "I do not understand this line." This message is not the computer being mean — it is a helpful clue that tells you where to look.
- The program runs, but does the wrong thing. Nothing looks broken, but the character jumps the wrong way, or the answer is not what you wanted. This is a bug too, even without a message.
Both kinds mean the same thing: there is a bug somewhere in the steps, and it is time to go find it.