Issue 15 of 30 Days of Hack (HHVM)
Set, Map and Vector have an immutable version, a version of the object that you cannot change.
Immutable objects can be cached more aggressively because we know for sure that they will not change its state. They are also thread safe (yes, I’ll talk about threads within the next few days). But the most obvious reason is simplicity. They are easier to understand and predict.
If you design a card game, you could have each card being a immutable object since you know the cards are not going to change their values or suits… You will, however, never encounter a situation where you need to use immutable objects. You could easily design the card game with mutable objects.
More about immutable objects in the Happyr developer blog.