A bug is anything that makes a program deviate from its expected behavior: a button that does not work, a wrong amount on an invoice, or an app that suddenly closes.

Where bugs come from#

They usually come from human mistakes, not the computer. A few common reasons:

  • A mistake in the program logic, such as a wrong condition
  • Wrong assumptions about user input
  • Special cases nobody anticipated, such as empty text or a negative number
  • Interference with another part of the code or an external library

Types by effect#

  • Syntax error: shows up right at the start.
  • Runtime error: stops the program while it is running.
  • Logic error: the program runs but gives the wrong answer; harder to find.

Fixing a bug#

First you must be able to reproduce the bug, then find its cause, fix it, and write a test so it does not come back. This process is called "debugging".

As a user#

If you see a bug, a good report includes what you did, what you expected, what happened, and on which device or browser. A precise report greatly reduces the time to fix.

A note#

No large piece of software is completely free of bugs. The goal is to have fewer bugs, find them quickly, and prevent new ones from appearing through testing and code review.