Go has contempt for generics

Jonathan M Davis jmdavisProg at gmail.com
Fri May 28 18:39:09 PDT 2010


Andrei Alexandrescu wrote:

> 
http://www.reddit.com/r/programming/comments/c93iy/go_at_io_frequently_asked_questions/
> 
> "Do you have plans to implement generics?
> Many proposals for generics-like features have been mooted both publicly
> and internally, but as yet we haven't found a proposal that is
> consistent with the rest of the language. We think that one of Go's key
> strengths is its simplicity, so we are wary of introducing new features
> that might make the language more difficult to understand. Additionally,
> the more Go code we write (and thus the better we learn how to write Go
> code ourselves), the less we feel the need for such a language feature."
> 
> That has Java 1994 written all over it.
> 
> 
> Andrei

I had a professor who felt that Java hadn't become a "real" language until 
it added generics. Things were too nice and neat before that. Now, there are 
a number of things - particularly surrounded generics - which are fairly 
complicated and nuanced in Java (frequently because they did generics by 
erasure). So, there's definitely more to trip you up, but it's more useful 
too.

There are definitely choices which can be made with a language which reduce 
the number of programming errors, but there are a lot which also seriously 
restrict you. Sure, Java worked without generics. It works without function 
pointers too. But the lack of generics was frustrating, and the lack of 
function pointers is still frustrating. The ommission seems alsmost 
criminal. You _can_ do a lot with a really stripped down language, but if 
you strip out too much, it can be highly frustrating for the programmer, and 
it will likely lead to other types of bugs when programmers are forced to do 
things differently.

But if Go doesn't have generics then that's a _huge_ difference from D, 
since D's templates are definitely some of the most powerful out there. And 
some of the language features - such as static if - make it possible to do 
stuff in D that would require template metaprogramming in C++, so D has 
actually simplified things by making the language more powerful. 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.

- Jonathan M Davis


More information about the Digitalmars-d mailing list