Abstract


Purity

Also known as deterministic. The same input always produces the same output(Referential Transparency) without affecting anything else(no Side Effect).

What if my program needs side effect to work?

For example, printing stuff to the screen is considered as side effect. We have Monad (functional programming) - Wikipedia to introduce side effects into the program and ensures the purity.

Referential Transparency


  • The output only depends on the input.

Side Effect


Example

Some side effects are listed below:

  • Print to the screen
  • Write to File
  • Throw exceptions
  • Change variables outside of the function
  • Modify the values of the arguments