4 ms·
I think OO caught on because it encourages people to organize their thoughts, and good structure alone brings a tremendous improvement in code. I think the rea
by ben509 6y ago
I think OO caught on because it encourages people to organize their thoughts, and good structure alone brings a tremendous improvement in code.
I think the reaction to it is more the "everything is mutable" approach most OO languages took, which led to things that looked organized but that were a hot mess of side-effects.
With dataclasses (or attrs) you can cut back on that by freezing everything, and still get the clarity of methods that lay out the essential functionality of a type.
In their own example, "get_items" and "save_items" make a bit more sense if they're stashed away in the Client namespace, and you can see that they're essential to what a Client does.
And while Oil's conjecture is probably right, I'm not sure it survives if you add the caveat, "in that same language."
For instance, Python doesn't have a native way of expressing sum types outside of inheritance. That's not to say inheritance, especially an always open style, is a good way of working with a sum type, it's just the only native way.