Abstract


  • An object cannot be changed after being assigned a value
  • If we want to update an object, we need to create a new object with the changes

Benefits


Eliminating Side Effects

  • Same set of input produces the same set of output
  • Help in understanding & reasoning about code behaviour

Easy Concurrency

  • Immutability provides a single source of truth

Rust


  • In Rust, variables are by default immutable