4 ms·
>If you follow the history of that particular issue, you'll see that the Go team's (official) view has always been that there are tradeoffs involved Only every
by coldtea 10y ago
>If you follow the history of that particular issue, you'll see that the Go team's (official) view has always been that there are tradeoffs involved
Only everybody who asks for generics knows that, and still wants them to go through and pay the price.
The "we'll only add them when there's a solution with no tradeoffs" is a red-herring, like "we'll add them on a day that doesn't end in -y".
>And I think most people will agree that Go has achieved a lot of success without them, so perhaps most use cases don't require generics after all.
In the same sense C has achieved quite a lot with buffer overflows, so what's the point in something like Rust?
- dmit 10y ago>Only everybody who asks for generics knows that, and still wants them to go through and pay the price. And those people are outnumbered by people who are comfortable and productive with the current Go implementation. Programming languages are not all placed on a single Bad<---->Good scale. There are many variables involved, and it makes sense to have local maxima like Java, Go, Clojure, C, Haskell, etc.
- coldtea 10y ago>And those people are outnumbered by people who are comfortable and productive with the current Go implementation. The only way to know that would be to be able to compare one implementation with and one without generics. But only one Go implementation exists. Perhaps there's some toy attempt by someone, but not anything that is equal in all other aspects to mainland Go but with Generics on top. Plus, since most of the burden falls on the compiler writers and most of the benefits to end users, it just takes the compiler writers to be "comfortable with the current Go implementation" for this to continue to remain Generic-less.
- dmit 10y agoHere's a question for you: what if the Go team add user-defined generic types to the language, and people start demanding HKTs? What then? Do you implement them and hope nobody asks for dependent types? Where do you draw the line?
- coldtea 10y agoWell, it's a soristic problem, but there are some clear heuristics: 1) tons of people have asked for Generics, few have asked for HKTs. 2) C++, C# and Java, programming languages with millions of users and extremely battle tested have Generics, no mainstream language at that level offers HKTs. 3) As a result of (2) a ton more people are familiar with Generics than HKTs, and so the latter are much less probable to be requested. And of course, if they do add Generics, and people ask for HKTs, they should consider what they do about that then and there, not now. No reason to never make a step towards somewhere just because you might (or will) be asked to also take a further one. Except if they believe that they are already at some optimal point (which is my case I think).
- dmit 10y agoWhat about all those people who came to Go from Python, JavaScript, Ruby and whatnot? They are mostly content with the current status quo, generics would just make the learning cliff steeper for them. And according to the Go devs, more people come to Go from Python than from, say, C++. So perhaps it makes sense to stay at that level, at least for now? All I'm saying is this doesn't seems like a simple equation to me. There are many possible solutions to the problem of building large, correct, maintainable, performant programs - and neither of the existing ones looks like a surefire winner given all the limitations.
- grey-area 10y agoIndeed, not many developers have moved from C++ to Go, though there are a few from Java who might miss generics. Here is some recent data on this: https://golangnews.com/stories/1490-results-of-the-gopher-language-poll https://golangnews.com/stories/1490-results-of-the-gopher-la...
- danenania 10y agoThis is probably a self-fulfilling cycle to some extent... the people using go are by definition willing to tolerate the lack of generics, while those for whom it's a dealbreaker won't be represented. If go did introduce generics, it might start appealing to other types of developers. Personally, I love most things about go, but its utter clumsiness at iteration and data transformation relegate it to a fairly limited number of use cases in my mind.
- openasocket 10y ago> And those people are outnumbered by people who are comfortable and productive with the current Go implementation. Citation needed. How do we know that the majority of Go users would prefer not to have generics? How do we know the number of non-Go users would be willing to use Go if it had generics is insignificant? Is there some large scale survey of Go users somewhere you can cite?
- lokedhs 10y ago> And those people are outnumbered by people who are comfortable and productive with the current Go implementation. Of course they are. The people who are not comfortable with the current implementation aren't using Go. It's a fallacy to only look at what the major users wants. It's similar to the “faster horses” fallacy.
- codygman 10y ago> Of course they are. The people who are not comfortable with the current implementation aren't using Go. Not true. What about those who write Go at work for instance?
- lokedhs 10y agoOf course, but there is a set of people who would be willing to use Go for new projects, but are not doing so because of this and other reasons.
- eternalban 10y ago> The "we'll only add them when there's a solution with no tradeoffs" is a red-herring, like "we'll add them on a day that doesn't end in -y". Russ actually addressed this at length: https://news.ycombinator.com/item?id=9622417 https://news.ycombinator.com/item?id=9622417
- coldtea 10y agoHow is that comment anything but a refusal to move on unless some magic tradeoff free solution appears? It even ends saying that "Programming language researchers are sometimes disappointed that Go hasn’t picked up more of the recent ideas from the literature, but those ideas simply haven’t had time to pass through the filter of practical experience. I believe generics is one of those ideas.". But Generics are neither some new PL topic, nor have they not passed the "filter of practical experience" (millions use them in C++, Java and C# alone). I'd rather they explicitly said: "It will take a total breakthrough in computer science regarding generics implementations for us to consider them for Go, and we wont ever care of paying the costs of any current, viable in practice for millions of programmers in other mainstream languages, approach".
- eternalban 10y ago> How is that comment anything but a refusal to move on unless some magic tradeoff free solution appears? Well I (somewhat) agree with that, but my take of it was Russ is basically saying existing approaches "don't work well with Go" and "recent ideas" are "not well understood" with the concern that "there's a princess in another castle after that one I am sure." Or put it another way, per his emphasis on the "engineering" nature of Go, it is not an issue of tradeoffs, rather a concern that a runaway train of complexity will follow. Or if you will excuse my Mexican French, the problem is the fucken type system :)
- majewsky 10y ago> How is that comment anything but a refusal to move on unless some magic tradeoff free solution appears? A programming language design is the combination of a set of features. The hard part in designing a language is working out how all these features interact with each other. For example, one feature of Go is that every type has a default value (0 for decimals, nil for pointers, empty string for strings, etc.). This property leads to the inability to include algebraic data types cleanly. To see this, consider this simple ADT (in Haskell syntax): data Either a b = Left a | Right b What's the default type here? It could be "Left(default-value-of-a)" or "Right(default-value-of-b)". You could introduce additional syntax to define the default value, but that increases complexity. You could introduce a rule how the default value is inferred in these cases, but that goes against the Rule of Least Surprise. You could remove the "default value for every type" feature that clashes with ADTs, but that causes problems elsewhere. Therefore Golang lacks ADTs and uses pointers and multiple return values instead.