Yes it's true that discriminated unions and pattern matching is just inheritance and virtual dispatch turned inside out. But discriminated unions and pattern matching are easier to use, easier to understand than inheritance and virtual dispatch.
And you don't need to struggle with principles like "is-a relationship" which can be confusing.
But discriminated unions and pattern matching are easier to use, easier to understand than inheritance and virtual dispatch.
That seems incredibly subjective. It's 50/50 for me, I just go with the grain with the language I'm using. I'll admit that in practice pattern matching wins due to the depressing lack of multiple dispatch in OO and pseudo-OO languages.
And you don't need to struggle with principles like "is-a relationship" which can be confusing.
Why would you struggle with that question with inheritance and not DUs? what is it about DUs that make it not an issue?
And you don't need to struggle with principles like "is-a relationship" which can be confusing.