Conversation

My first instinct is to say "but those aren't the same thing!" but if it's a feature-for-feature trade I'd happily give up interfaces for tagged unions. Can always use records with functions in them instead, they're not even that bad to use.
2
I thought the issue was more that they started out with the assumption that everything needed a default value. Anyway, that means it's hard to have a default for tagged unions (which should have given them a hint that defaults for everything is kinda ick, but egh).
2
1
I'm _guessing_ because they were coming from a C perspective and wanted to ensure everything was zero initialised to start off with because it was safer. And then a whole tower of design decisions were built atop that.
2
Where as a better solution is to ensure that things are always assigned a value on construction. That seems to give you much more room to move in the design space, and leads to less code that constructs things in invalid states (this is rampant from what I've seen).
1
1
There are some practical advantages to having a fixed initial value like zero... mostly related to allocator optimizations, AFAIK. But of course if those aren't actually reasonable values and always get changed in practice these optimizations are worthless.
2
1
Replying to
OCaml is a weird situation. Its GC is extremely optimized for some very specific kinds of programming (e.g. writing a Coq interpreter) and it requires considerable effort to beat it there. But many of its microoptimizations make language extension and compiler optimization hard.
2
2