In: Computer Science
In simple terms, immutability means unchanging over time or
unable to be changed.Thus,Immutable variables simply means that
their values can't be modified once after it is created.In other
words,you can say they are the constants.
Advantages of immutabilty:
1. It is easier to deal with and create.
2. Since their values are not modifiable they are easy to share
them across various functions
3. They do not have a defensive copy, so their usage is side effect
free.
4. They simplifies debugging as they have only one value.
Disadvantages:
1.May be the reason for access memory usage sometimes.
2.The updates of immutable variables tend to require multiple
allocations and can lead to excessive garbage collection
work.
3.There might be difficulty in propagating changes, particularly
when dealing with objects with identity.
4.The immutable data might be slower than their mutable counter
parts.