Go has contempt for generics

Alex Makhotin alex at bitprox.com
Fri May 28 23:38:03 PDT 2010


Andrei Alexandrescu wrote:
> 
> That has Java 1994 written all over it.
> 

> (This happened with early Java as well; one hallmark of Java is that it talked out of existence all necessities of modern languages until it adopted them, invariably too late to be properly integrated.)

And what happened to Java?
Looking at the popularity of Java:
http://www.devtopics.com/most-popular-programming-languages/
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
http://langpop.com/

If the Go will reach the same results... future will tell.
And, by the way, where's the popularity of the D?

As I understand from the Go docs
http://golang.org/doc/go_lang_faq.html

> Why does Go not have generic types?
> 
> Generics may well be added at some point. We don't feel an urgency for them, although we understand some programmers do.
> 
> Generics are convenient but they come at a cost in complexity in the type system and run-time. We haven't yet found a design that gives value proportionate to the complexity, although we continue to think about it. Meanwhile, Go's built-in maps and slices, plus the ability to use the empty interface to construct containers (with explicit unboxing) mean in many cases it is possible to write code that does what generics would enable, if less smoothly.
> 
> This remains an open issue. 

As you can see there's no "contempt", if this word is applicable at all.

Russ Cox recently commented on the topic.
http://groups.google.com/group/golang-nuts/browse_thread/thread/3c24dd8e7b083e34/22fbbc72858f4121

>> The generic approach is more or less obvious:
> 
> Less, if you ask me.
> 
> http://golang.org/doc/go_lang_faq.html#generics
> is short but accurate.
> 
> The rest of your mail reads like someone reveling in
> having built something complex that actually works.
> It's an addictive feeling - why do you think there are
> so many C++ programmers? - but I think in general
> it is counterproductive.
> 
> It has been interesting to me to see programmers who
> have written substantial amounts of Go code, even
> outside the core Go team, say that on balance they
> don't really miss generics and would not want to see
> them unless they fit well with the rest of the language.
> (Petar just said something like that in one of his Tonika
> blog posts, and someone else said it earlier on the list.)
> 
> The kind of explicit type-oriented programming that
> seems inherent to the C++/Java/C# approach to "generics"
> is exactly the kind of heavyweight clumsy spell everything
> out for the compiler programming that Go strives so hard
> not to be.
> 
> Russ 

I hope this comment helps.


-- 
Alex Makhotin,
the founder of BITPROX,
http://bitprox.com


More information about the Digitalmars-d mailing list