# Side Effect

> Work a function does on the side. Saving a file is one; so is printing.

**Field:** Software Development  
**Category:** Programming Paradigms  
**Also known as:** Side Effects

## Think of it like

Think of it like a cook who also moves your chairs. You asked for soup, not new seats.

## Definition

A side effect is anything a function does besides giving back its answer. Changing a variable outside the function is one. So is saving a file, printing, sending an email or calling a server. Programs need them to be useful at all. The trouble starts when they hide where nobody looks.

## Example

Emma's getPrice function also wrote to the log and bumped a counter. Calling it twice in a test gave two different counts.

## Why it matters

Hidden side effects are a top cause of bugs that only appear sometimes. Knowing where they live makes code easier to trust.

## Common mistake

Trying to remove all side effects. A program with none cannot save, show or send anything.

## Three principles

- **Beyond the answer.** Any change to the outside world.
- **Needed but risky.** Programs must have some.
- **Keep them visible.** In a few known places.

## Related terms

- [Pure Function](https://learn.benibix.com/term/development/pure-function)
- [Functional Programming](https://learn.benibix.com/term/development/functional-programming)
- [Immutability](https://learn.benibix.com/term/development/immutability)
- [Variable](https://learn.benibix.com/term/development/variable)

---

Source: https://learn.benibix.com/term/development/side-effect
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
