7 ms·
> This question is called variance, and different languages have very different answers to this, but once generics are reified, the chosen variance strategy is
by bunderbunder 7y ago
> This question is called variance, and different languages have very different answers to this, but once generics are reified, the chosen variance strategy is baked into the runtime.
Which, realistically, is probably the only principled way to do things if you want to be doing much with variant generics in a cross-language way.
The Java way, "I pick my variance strategy, you pick yours, and we'll both pass everything around as a List<Object> at runtime and just hope that our varying decisions about what their actual contents are allowed to be never cause us any nasty surprises for each other at run time," is not type-safe and can lead to nasty surprises at run time. It's easier, sure, but easier is not necessarily better.
- pron 7y agoExcept, realistically, of all the polyglot runtimes, the ones that have good interop erase and the one that doesn't reifies.