D popularity

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Mon Jan 21 15:49:13 PST 2013


On Tue, 22 Jan 2013 00:14:13 +0100
"Rob T" <alanb at ucora.com> wrote:

> 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.
> 

But under dynamic typing, those "bad" situations are the vast majority
of cases.

> 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.
> 

Totally agree. That's one of the biggest reasons I can't stand Python.

> 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.
> 

Right. Having a variant available is certainly fine. I'd never argue
against that. But designing a language specifically around variants -
that's a misguided design mistake.



More information about the Digitalmars-d mailing list