3 ms·
Generics aren't included for two reasons: 1. They haven't figured out a way to implement them without impacting performance significantly 2. They're not as ne
by chimeracoder 14y ago
Generics aren't included for two reasons:
1. They haven't figured out a way to implement them without impacting performance significantly
2. They're not as necessary as you might think.
While they're open to adding them if #1 changes, in response to #2, I find I don't miss them as much as I would have thought - and that's coming from a strong advocate of statically typed, functional languages. In idiomatic Go, I just don't need them as often as I would have thought, and the interfaces are well-designed enough to make up for much of the difference.
http://golang.org/doc/go_faq.html#Why_doesnt_Go_have_feature_X http://golang.org/doc/go_faq.html#Why_doesnt_Go_have_feature...
- azth 14y agoI have read those same arguments over and over. Just because generics do not come up as often does not mean they won't make programs safer and/or faster. Almost all of the workarounds I have seen for the lack of generics can easily be applied to Java for instance. There were several questions that came up on the Go mailing list asking how to convert certain code to make it more "idiomatic". The resulting code had several layers of indirection, interfaces composed of interfaces, and so on, that ironically it would have looked much more concise, and would have been type safe in a more "traditional OO" language like Java.
- jlgreco 14y agoNot sure why you would expect to hear anything but the same thing over and over, in response to the same complaint being raise.. over and over. I don't think anyone denies that adding generics, if done properly, would improve the language. The only real controversial thing being suggested is that generics are not worth an implementation that is not up to standards. Personally, I think that is a reasonable position.
- deleted 14y ago[deleted]
- gnuvince 14y agoWhen people mention that they don't find generics necessary, they should mention the type of work they do. For someone building an application, I can believe that one can do without generics, and still get a good application out. However, for someone writing a library, I think that their absence will be much more noticeable.