Immutable
Immutability is a property of data whose state cannot be modified after it is created. In programming, an immutable object cannot be altered; operations that would modify it instead return a new object with the desired changes. Immutable data structures preserve the previous versions when updated and often rely on structural sharing to minimize memory use.
Many languages provide immutable primitives or types. Strings in Java and Python are immutable; numbers and
Benefits of immutability include easier reasoning about program behavior, since values do not change unexpectedly, and
Drawbacks include potential memory and performance costs from creating new objects rather than updating existing ones.
In practice, developers choose immutability to enhance safety and predictability, while mutability remains useful for performance-critical