Debugging
Debugging finds and fixes errors.
About this topic
Debugging is finding and fixing errors, called bugs, in programs. The term is often linked to a moth found in an early computer in 1947, though bugs were discussed earlier. There are three main types: syntax errors (breaking the language rules, so the program will not run), runtime errors (crashing while running, such as dividing by zero) and logic errors (running but giving wrong results).
A good method is to reproduce the problem, locate where it happens, form a guess and test it. Tools include reading error messages carefully, adding print statements to show variable values, using a debugger to step through line by line and set breakpoints, and explaining the code aloud to a rubber duck, which often reveals the mistake.
For example, if an average comes out wrong, print the total and count to see which is incorrect. Logic errors are hardest because no message appears. A common mistake is changing many things at once, making it unclear what fixed the issue. Change one thing at a time, keep notes, and take a break if you are stuck.
Key ideas
- Syntax, runtime and logic errors
- Print statements and debuggers
- Rubber duck debugging
Quick check
Use cases: where Debugging helps
- Homework: review the key idea behind Debugging before you start a problem set.
- Exam revision: use the quick check to test whether you can recall Debugging without notes.
- Visual learning: play with the interactive lab to see how Debugging changes when you adjust its inputs.
- Teaching a friend: explain Debugging in your own words, then compare your version with the key ideas.
Computing ideas run phones, search engines, games and the wider internet.
Frequently asked questions
What is Debugging?
Debugging finds and fixes errors.
What will I learn in Debugging?
Syntax, runtime and logic errors. Print statements and debuggers. Rubber duck debugging.
Is Debugging part of Computer Science?
Yes. It is one of 80 Computer Science topics on LearnViz HighSchoolEdu, with 3 key ideas, a live animation and a quick check.
Does the Debugging lab work on a phone or tablet?
Yes. The animation resizes to fit your screen and supports touch, so you can drag, tap and slide with your finger.
How should I study Debugging?
Read the summary and key ideas first, play with the interactive lab to see the idea in motion, then answer the quick check. If you get a question wrong, go back to the key idea it tests.
Do I need an account, and is my progress saved?
No account is needed. Marking a topic as learned is saved in your own browser, so it stays on that device and is not sent to a server.