News for hackers. Stuff that matters.
Re:Switching from C++ to Rust by nicoburns on Monday March 13, 2023 @08:19PM (#35145355)
Does your code ever contain class hierarchies with a fixed set of classes? Or variables where certain values have special case meaning? Those are the cases where Sum Types make things immeasurably nicer than the alternatives.
Re:Switching from C++ to Rust by zabzonk on Monday March 13, 2023 @08:29PM (#35145461)
> Does your code ever contain class hierarchies with a fixed set of classes?

no - one of the advantages of OO programing is that class hierarchies (should you feel the need to use them, which mostly i do not) can be expanded. or indeed contracted.

> Or variables where certain values have special case meaning?

very, very rarely (i would say never, in my own code) but of course we have the null pointer as a counter-example. to which i can say: don't use raw pointers.

Re:Switching from C++ to Rust by jjnoakes on Monday March 13, 2023 @09:09PM (#35145913)
Do you have any large open source code bases that you could share?
Re:Switching from C++ to Rust by kaba0 on Tuesday March 14, 2023 @05:45AM (#35149180)
The Visitor pattern, which is a must in certain niches is exactly analogous to pattern matching over a sum type, and I am fairly certain that I can objectively say that the latter is a million times more readable and maintainable.

It doesn’t make OOP obsolete, though, at all. Certain other areas are better expressed as hierarchies, e.g. GUI nodes.