On Monday, 21 January 2013 at 21:27:54 UTC, Nick Sabalausky wrote:
Much the same here, only times I've *ever* felt any need for a Variant
is when interfacing with something that's already variant or
nearly-variant. Or as a bloated workaround when I'm using a language
with really shitty (or no) template support.

I bet you use variants a lot more than you think.

Often the variants are not noticed, such as when using std.json, which implements a form of variant type. There are many uses of "hidden" variants, some are more generalized than others, but they are still variants.

I think what you are pointing out as being bad, are the situations where variant types are used for no actual purpose, where you gain nothing, and loose performance and possibly type safety depending on the richness of the implementation.

In addition, there are scripted languages that have no means to check even statically declared types to ensure they are being used correctly, and the only way to discover errors is during runtime. I think that's not really a language design issue, it's more of an implementation issue.

The worse languages of all, are the ones that will automatically create instances of variables without the programmer having to explicitly declare them. In those languages, a simple typo can lead to disaster. The reasoning behind such a design can only be to purposefully make programming dangerous and error prone just for laughs. I always do my best to avoid using those kinds of languages.

So in a general sense, I will argue that what you are complaining about is not the idea of the variant - it is a very useful concept - the problems you are pointing out are with poor design and implementation choices.

--rt

Reply via email to