Crayonbird
Menu

Computing

What is debugging?

Quick answer

Debugging means finding and fixing mistakes, called bugs, in an algorithm or a computer program. It is a normal part of coding for everyone.

Ages 6–14Primary

In one sentence

Debugging is the detective work of finding out why a program or set of instructions isn't working and fixing it.

Explained

When you write an algorithm or code, it often does something you didn't expect. The mistake is called a bug, and fixing it is debugging. Every programmer, from beginners to experts, spends a lot of time debugging. A bug doesn't mean you're bad at coding; it means you're coding.

Bugs come in a few types:

  • Syntax errors: the code is written wrongly, like a missing bracket or a misspelt command. The computer can't run it.
  • Logic errors: the code runs, but does the wrong thing, such as turning left instead of right or repeating 3 times instead of 4.
  • Missing steps: a step was left out of the algorithm.

Good debuggers work like detectives. They predict what should happen, run the program, compare the result with their prediction, and narrow down where it goes wrong. Changing one thing at a time makes it easier to see what fixed the problem.

The word "bug" was used for faults in machines long before computers; inventors used it in the 1800s. A famous story comes from 1947, when engineers working on the Harvard Mark II computer, a team that included Grace Hopper, found a real moth stuck inside. They taped it into their logbook as the "first actual case of bug being found". The joke worked because everyone already called faults bugs.

Debugging takes patience. It is a great example of a growth mindset: every error tells you something useful.

  • magnifying glass
  • computer
  • robot
  • butterfly
Grab your magnifying glass: debugging is detective work.

Examples

Step by step

  1. Spot the problemThe square comes out as a triangle.
  2. PredictIt should move and turn four times.
  3. Trace the codeGo line by line: "repeat 3 times… move 100… turn 90."
  4. Find the bugThe loop says 3, not 4.
  5. Fix and testChange 3 to 4 and run it again. It draws a square.

Common mistakes

  • Changing lots of things at once. You won't know which change fixed it, or which made it worse.
  • Not testing after a fix. Always run the program again.
  • Thinking bugs mean failure. Bugs are normal. Fixing them is a skill you get better at.

Quick quiz

Debugging

Check what you know with 4 quick questions.

Question 1 of 4

What is a bug in computing?

Practise it

Try it

Spot-the-mistake and logic puzzles

Ages 11–13

Number sequences · Warm-up

Ages 13–18

Binary and hex · Tricky

Ages 15–18

Number sequences · Expert

See more in the library

All Logic and code puzzles sheets

For grown-ups

Algorithm

An algorithm is a precise, step-by-step set of instructions for solving a problem or doing a task. Computers follow algorithms written as code.

Computing · Ages 5–12

Coding

Coding, or programming, means writing instructions in a language a computer understands so it can do a job, like run a game, an app or a website.

Computing · Ages 6–14

Growth mindset

A growth mindset is the belief that abilities can improve with practice, good strategies and help. A fixed mindset is the belief that you either have a talent or you don't.

Study skills · Ages 6–16

Binary

Binary is a number system that uses only two digits, 0 and 1. Computers use binary to store and process all their information.

Computing · Ages 9–14

Online safety

Staying safe online means keeping personal details private, using privacy settings and strong passwords, being kind, and telling a trusted adult if anything worries you.

Computing · Ages 5–14

Back to the Learning Wiki