Side-Effects in Functional Programming

In Functional Programming, when a function modifies a state outside of its scope, this behaviour is called as a Side-effect

Examples of Side-effects

  1. Modifying inputs (think of pointers or references, or arrays)
  2. Modifying global variables
  3. printing to console
  4. HTTP calls
  5. Changing the filesystem
  6. Querying the DOM

See in real world, you can not avoid side effects entirely.

In most cases, your whole applications are built to do HTTP calls or database updates.

And in many cases you need to have mutable variables shared between multiple threads e.g. counters.

To tackle this FP languages have bridges