Go has contempt for generics

Jonathan M Davis jmdavisProg at gmail.com
Sat May 29 02:42:45 PDT 2010


Andrei Alexandrescu wrote:

> On 05/28/2010 08:39 PM, Jonathan M Davis wrote:
> [snip some good points]
>> So, while
>> some folks seem to want to draw comparisons between Go and D, it sounds
>> like there are definitely things about them which are drastically
>> different, not only in the design, but in the philosophy behind the
>> design.
> 
> If Go has only a black stare as a response to problems usually tackled
> by generics in contemporary language, I wouldn't call that a different
> philosophy, I'd call that a lacuna therein.
> 
> Andrei

Curse you for making me increase my vocabulary! ;) Nice word, lacuna...

In any case, while I would agree with you that it generally works better for 
a language to have generics of some kind, there are plenty of languages 
which get by just fine without them. I haven't looked into Go at all, so I 
don't know how they would affect it if you added them or what frustrations 
currently exist without them. But you can have perfectly good languages 
without generics, and there probably are languages where it would be a bit 
awkward or needless to have them (probably primary in functional and/or 
dynamically-typed languages). It could be that Go works great without them, 
so I'm not sure that it's necessarily a lacuna, but certainly my first 
reaction without looking more closely into the matter would be that it 
probably is a lacuna. But whether it really is a lacuna or not would really 
depend on what they have and how the lack of generics affects them. 
Certainly, on Java's and C#'s parts, it was a lacuna until they added them.

So, I guess that I'm agreeing with you on the condition that Go really is 
the kind of language that should have generics, but not being familiar with 
the language, I can't really say.

Regardless, I'm very glad that D has powerful generics in its templates. And 
they retain and improve on some of the more powerful aspects of C++'s 
templates rather than being used pretty much purely for container types like 
in C# and Java. But given your involvement in the project and how big you 
are on templates and template metaprogramming, that should come as no 
surprise. That would also be suggestive of why you'd find a language without 
them to be lacking.

- Jonathan M Davis


More information about the Digitalmars-d mailing list