Learn

Debugging with small experiments

Last updated: July 19, 2026

A method for isolating bugs in online compilers: shrink the program, form a hypothesis, change one variable, and keep a trail of what you learned.

The playground advantage

Large codebases hide bugs under frameworks and configuration. A playground forces the opposite: if the bug still happens in twenty lines, you have found the essential conflict.

Code Arena is built for that extraction. Paste the core, delete the rest, Run. When the failure remains, you can think. When it disappears, the bug was in what you deleted — also useful information.

The experiment loop

State a hypothesis in one sentence (“I think index is off by one”). Predict Output. Change the smallest thing that would falsify the hypothesis. Run. Record whether you were right.

If you change five things at once, you learn almost nothing. The discipline feels slow for five minutes and then saves an hour.

  • Hypothesis → prediction → single change → Run → note
  • Keep the last known good snippet in a comment or share link
  • Prefer deleting code over adding cleverness while hunting

Make failures obvious

Assert the thing you care about with a clear print: EXPECT 4 GOT ${result}. In Python, a simple assert can work for tiny demos; in JavaScript, an if + throw new Error message is enough.

Ambiguous Output (“looks fine?”) is how bugs survive. Force the program to disagree with you loudly.

Compare across languages carefully

Porting a snippet from Python to JavaScript (or the reverse) can reveal whether a bug is algorithmic or language-specific. Just remember the sandbox runtimes differ — do not treat floating point formatting quirks as deep mysteries until the algorithm is correct.

When to stop and go local

If you need a debugger with breakpoints across many files, property-based tests, or flaky network stubs, graduate the experiment into a repo. Take the minimized snippet with you so you do not reintroduce noise.

The win is not “never leave the playground.” The win is “never bring a vague bug into a heavy environment.”

Try it

Pick a small wrong program (for example, a reverse-string function that drops a character). Use only print/log and shrinking. Do not rewrite from scratch until you can explain the bug in one sentence.