Re:One Way to Represent Things
by gonzo41 on Thursday February 25, 2021 @07:34AM
(#26262144)
I don't think the addition of sum types broadly will be the panacea that people think. Software does need to be maintained, simpler things are easier to maintain.
[ Parent
| on HN ]
What simpler alternative is there? The OOP way would be to always hide data. This certainly has a different set of trade-offs, and sometimes requires the visitor pattern. Maintainable and simple are not words I would use to describe these cases.
The other alternative is to emulate sum types through run-time type information or using code generation like protobuf. I also fail to see how these approaches are simpler or more maintainable.
Sum types are not a panacea for all software development ills, but they're the simplest and most direct solution to a concrete problem: My data is either this type or that type.
Re:One Way to Represent Things
by TazeTSchnitzel on Thursday February 25, 2021 @07:54AM
(#26262234)
Sum types are simpler, and harder to misuse, than the common alternatives (unions or dynamic typing).