3 ms·
When designing Virgil, I left out ADTs for the longest time. I had programmed a bit in ML, and knew I would eventually want them. I finally added them to Virgil
by titzer 5y ago
When designing Virgil, I left out ADTs for the longest time. I had programmed a bit in ML, and knew I would eventually want them. I finally added them to Virgil circa 2016. It's really impossible to emulate them with objects, because objects typically have identity, whereas ADTs, IMHO, shouldn't. The pattern matching and exhaustiveness checking that ADTs give you allows you to write very concise programs that you can be sure cover all the cases.
Extensibility in OO languages can be great for many things, but ADTs excel at expressing a fixed set of data shapes, forcing programmers to think carefully and break things down into a fixed set of cases. When you've handled all the cases, you're done!