3 ms·
Because when dealing with mutability, you usually want to specify which of two parties can mutate: none (immutable collection), only the producer (read-only int
by pron 4y ago
Because when dealing with mutability, you usually want to specify which of two parties can mutate: none (immutable collection), only the producer (read-only interface), only the consumer (transfer of ownership), or both (mutable collection). E.g. a read-only interface does not tell a receiver whether or not it is safe to store in a field. So to do it "properly" either you multiply the number of interfaces by four, or complicate the type system to track ownership. Either way, the price for that feature is high, and it's not yet clear at this point whether the benefits are worth it.
Not every solution to every problem is worth it. Sometimes it's best to do nothing and spend the time on more worthwhile things, and perhaps a cheaper solution would present itself in the future.