by rickbdjvdjb · 5y ago · 0 comments
That's entirely accurate. A bag is "too expressive", in that sense. Sometimes you want to constrain the kind of container so you don't put the wrong kind of thing in there.
Another analogy: types. "Any" will let you use anything, but sometimes you want to say "only allow Integers here".
If we act like we're not actually dealing with bags at a fundamental level, we might mislead ourselves and spread the belief that the rules and labels around the bags are what matters. No, they help you (temporarily) to use the bags in a specific way in some context.
In fact, computers are extremely expressive, (bag like) things. The constraints are auxiliary. I think it's important that we keep reminding us what programming is and that it serves a direct purpose, while the bureaucracy is a support structure at best.
Constraints enable reasoning, both automatic and manual.
Loops fit the single-core CPU hardware paradigm extraordinarily well. As soon as you start targeting modern hardware, more constrained recursion/iteration schemes start to buy a lot more in terms of both developer time and compiler complexity.
In addition to that, the Set is more "expressive" than the list in the right context. Or rather it expressing things more directly.
Generally a list is ordered by contract, whereas whether or not a set is ordered depends on the implementation.