digitalmars.D - Go has contempt for generics
- Andrei Alexandrescu (11/11) May 28 2010 http://www.reddit.com/r/programming/comments/c93iy/go_at_io_frequently_a...
- Jonathan M Davis (26/41) May 28 2010 I had a professor who felt that Java hadn't become a "real" language unt...
- Andrei Alexandrescu (6/10) May 28 2010 If Go has only a black stare as a response to problems usually tackled
- Jonathan M Davis (26/39) May 29 2010 Curse you for making me increase my vocabulary! ;) Nice word, lacuna...
- Andrei Alexandrescu (7/10) May 29 2010 Yah, it's not the generics per se. That's why I mentioned "response to
- bearophile (6/7) May 28 2010 Java today can be the most used language, so despite its faults, probabl...
- Jonathan M Davis (12/22) May 28 2010 I'd argue that Java suffers from the fact that they added generics late ...
- Walter Bright (3/7) May 28 2010 Another way to say that is that if the cost of simplifying the language ...
- Andrei Alexandrescu (11/16) May 28 2010 No language has plenty of time for anything. And the major problem with
- Alex Makhotin (18/57) May 28 2010 And what happened to Java?
- Andrei Alexandrescu (3/15) May 29 2010 Not because of that!
- bearophile (5/8) May 29 2010 D didn't have templates for some time.
- BCS (4/15) May 29 2010 --
- Don (3/10) May 29 2010 I agree with that. Over time, D has moved very strongly in that
- Andrei Alexandrescu (6/17) May 29 2010 Clearly we're still exploring what the best way to carve the territory
- Sean Kelly (2/12) May 29 2010 So they've simplified the language at the cost of more complex user code...
- Andrei Alexandrescu (5/21) May 29 2010 Exactly. This "the more code we write the less we felt a need for
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
May 28 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. AndreiI 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
May 28 2010
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
May 28 2010
Andrei Alexandrescu wrote:On 05/28/2010 08:39 PM, Jonathan M Davis wrote: [snip some good points]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. 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 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 DavisSo, 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
May 29 2010
On 05/29/2010 04:42 AM, Jonathan M Davis wrote: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.Yah, it's not the generics per se. That's why I mentioned "response to problems usually tackled by generics in contemporary languages". More dynamic languages achieve things in different ways. But Go seems to claim that built-in arrays, hashes, and channels are all you'll ever need that's generic. I believe that's a mistake. Andrei
May 29 2010
Andrei Alexandrescu:That has Java 1994 written all over it.Java today can be the most used language, so despite its faults, probably it was good enough. Even if Go has no templates, it has plenty of time to add them five years from now :-) (And in the end templates aren't the only way to design a type-generic language). Bye, bearophile
May 28 2010
bearophile wrote:Andrei Alexandrescu:I'd argue that Java suffers from the fact that they added generics late in the game. Generics by erasure brings no benefits except backwards compatability, and they cause a whole host of problems for people trying to use them. Yes, you _can_ add things like generics into the language later, but it can be quite disruptive to do so, and the result could be subpar due to constraints such as backwards compatability. Sure, you _can_ use a language without generics (and many other features) and get a lot done, but I'd argue having simplicity as your prime directive tends to lead to an inefficient tool for the programmer. Simplicity should be a goal, but there are times that it should be overridden by other goals. - Jonathan M DavisThat has Java 1994 written all over it.Java today can be the most used language, so despite its faults, probably it was good enough. Even if Go has no templates, it has plenty of time to add them five years from now :-) (And in the end templates aren't the only way to design a type-generic language). Bye, bearophile
May 28 2010
Jonathan M Davis wrote:Sure, you _can_ use a language without generics (and many other features) and get a lot done, but I'd argue having simplicity as your prime directive tends to lead to an inefficient tool for the programmer. Simplicity should be a goal, but there are times that it should be overridden by other goals.Another way to say that is that if the cost of simplifying the language is pushing the complexity off onto the user code, it's a poor tradeoff.
May 28 2010
On 05/28/2010 08:44 PM, bearophile wrote:Andrei Alexandrescu:No language has plenty of time for anything. And the major problem with Go is that its authors seem to not get type genericity at all and try to pretend it doesn't exist. That is a pernicious mistake that will cost that language dearly. (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.) FWIW my impression of Go is veering quickly from "well what can you ask? it's unfinished" to active dislike. They don't know what they're doing. AndreiThat has Java 1994 written all over it.Java today can be the most used language, so despite its faults, probably it was good enough. Even if Go has no templates, it has plenty of time to add them five years from now :-) (And in the end templates aren't the only way to design a type-generic language).
May 28 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.htmlWhy 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/22fbbc72858f4121I hope this comment helps. -- Alex Makhotin, the founder of BITPROX, http://bitprox.comThe 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 is exactly the kind of heavyweight clumsy spell everything out for the compiler programming that Go strives so hard not to be. Russ
May 28 2010
On 05/29/2010 01:38 AM, Alex Makhotin wrote:Andrei Alexandrescu wrote:Not because of that! AndreiThat 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/
May 29 2010
Jonathan M Davis:Yes, you _can_ add things like generics into the language later, but it can be quite disruptive to do so, and the result could be subpar due to constraints such as backwards compatability.D didn't have templates for some time. Maybe compile-time function execution plus a type type can replace the need for C++/D/Java style generics :-) Bye, bearophile
May 29 2010
Hello bearophile,Jonathan M Davis:They showed up much closer to v0.01 than v1.00Yes, you _can_ add things like generics into the language later, but it can be quite disruptive to do so, and the result could be subpar due to constraints such as backwards compatability.D didn't have templates for some time.Maybe compile-time function execution plus a type type can replace the need for C++/D/Java style generics :-) Bye, bearophile-- ... <IXOYE><
May 29 2010
bearophile wrote:Jonathan M Davis:Yes, you _can_ add things like generics into the language later, but it can be quite disruptive to do so, and the result could be subpar due to constraints such as backwards compatability.D didn't have templates for some time.Maybe compile-time function execution plus a type type can replace the need for C++/D/Java style generics :-)I agree with that. Over time, D has moved very strongly in that direction. I wonder how far that approach could ultimately be taken.
May 29 2010
On 05/29/2010 10:52 AM, Don wrote:bearophile wrote:Clearly we're still exploring what the best way to carve the territory is, but one trend is clear: * Type-parameterized types and functions for generic programming * Compile-time function evaluation for generative programming AndreiJonathan M Davis:Yes, you _can_ add things like generics into the language later, but it can be quite disruptive to do so, and the result could be subpar due to constraints such as backwards compatability.D didn't have templates for some time.Maybe compile-time function execution plus a type type can replace the need for C++/D/Java style generics :-)I agree with that. Over time, D has moved very strongly in that direction. I wonder how far that approach could ultimately be taken.
May 29 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."So they've simplified the language at the cost of more complex user code. They should have just said that they haven't found a proposal they like yet and left it at that.
May 29 2010
On 05/29/2010 10:43 AM, Sean Kelly wrote:Andrei Alexandrescu Wrote:"Do you have plans to implement generics?http://www.reddit.com/r/programming/comments/c93iy/go_at_io_frequently_asked_questions/Exactly. This "the more code we write the less we felt a need for genericity" reflects very poorly - just not on genericity. AndreiMany 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."So they've simplified the language at the cost of more complex user code. They should have just said that they haven't found a proposal they like yet and left it at that.
May 29 2010