News for hackers. Stuff that matters.
Re:Toward Go 2 by fusiongyro on Thursday July 13, 2017 @01:26PM (#14763228)
The paragraph I was looking for is this:

> For example, I've been examining generics recently, but I don't have in my mind a clear picture of the detailed, concrete problems that Go users need generics to solve. As a result, I can't answer a design question like whether to support generic methods, which is to say methods that are parameterized separately from the receiver. If we had a large set of real-world use cases, we could begin to answer a question like this by examining the significant ones.

This is a much more nuanced position than the Go team has expressed in the past, which amounted to "fuck generics," but it puts the onus on the community to come up with a set of scenarios where generics could solve significant issues. I wonder if Go's historical antipathy towards this feature has driven away most of the people who would want it, or if there is still enough latent desire for generics that serious Go users will be able to produce the necessary mountain of real-world use cases to get something going here.

Re:Toward Go 2 by crawshaw on Thursday July 13, 2017 @01:36PM (#14763323)
Several members of the Go team have invested significant effort in studying generics and designing proposals, since before Go 1.0. For example, Ian Lance Taylor published several of his previous efforts, which had shortcomings he was dissatisfied with.

I believe your impression of the Go team's position has been corrupted (likely unintentionally) by intermediaries.

Re:Toward Go 2 by wwweston on Thursday July 13, 2017 @03:06PM (#14764194)
While "fuck generics" might be a low-resolution characterization, it's not entirely inaccurate, and the efforts of Taylor (and perhaps others) notwithstanding, as long as anyone is writing things like "I don't have in my mind a clear picture of the detailed, concrete problems that Go users need generics to solve," there's reason to believe it's apt enough.

As other respondents to the GP comment show, it's not at all hard to come up with that ostensibly elusive picture if you're attending to it. So I suppose the obvious takeaway is that they're still not really attending to it. Which is fine, Go clearly has its niche and its fans, and people who don't want a pretty good Blub have other options.

Re:Toward Go 2 by skybrian on Thursday July 13, 2017 @07:48PM (#14766288)
This is frustrating. Substituting an insult for politely declining (while leaving the door open) is not "low-resolution" or "apt enough", it's almost entirely inaccurate. Politeness matters.
Re:Toward Go 2 by wwweston on Thursday July 13, 2017 @09:02PM (#14766671)
"low resolution" is a perfectly accurate description of "fuck generics", which like any two-word phrase can't entirely capture the attitude of the golang team, but nevertheless does seem to capture something of gestalt of their approach.

Finer resolution would be if fusiongyro had characterized the golang team as saying "fuck off developers who want generics," which wouldn't have been as polite as the phrase "I don't have in my mind a clear picture of the detailed, concrete problems that Go users need generics to solve," but whose semantics are otherwise equivalent.

Re:Toward Go 2 by skybrian on Thursday July 13, 2017 @09:11PM (#14766705)
No. Unless someone finds a quote, the low order bit is that they didn't use the word "fuck" or any other swear word at all. You can't use the word "fuck" to accurately quote someone who didn't use that word.
Re:Toward Go 2 by cannabis_sam on Friday July 14, 2017 @02:50AM (#14768035)
Take a look at this article/talk https://commandcenter.blogspot.com/2012/06/less-is-exponenti...

He's explicitly rude. Sets up a strawman argument with the developer who can't imagine programming without generics. Mocks the people who want generics. Gasps in faux disbelief that it could be solved by types.

And then, when he goes in for the kill, to show once and for all that generics are pointless garbage:

He attacks type hierarchies and inheritance... completely missing the point by conflating parametric polymorphism and subtype polymorphism.

I think "Fuck generics" does a decent job of summarazing the rudeness, misinformation and ill-thought out arguments that the article contains about generics.

Re:Toward Go 2 by mmargerum on Friday July 14, 2017 @02:02PM (#14771855)
Rich Hickey's Tweet came to mind:

If you think you know how I ought to spend my time, come over and mow my lawn while I expound on the problems of dev entitlement culture.

I'm fine with RSC, Commander Pike, and those other benevolent dictators continuing to make much better decisions that I certainly ever would and more importantly to be super careful with what they add to the language. I write Swift, JS, objC, and Go. Go is the preferred language because it's simple and I have the entire SDK in my head.

I use Go a lot. I can't say i've ever run into not having generics being a huge deal.

Let's face it, for most programmers out there, generics is for type safe collections. If slices and maps weren't built into Go then i'd prolly have moved to something else.

That said i'd like to see more built in data structures

Re:Toward Go 2 by coldtea on Friday July 14, 2017 @05:09AM (#14768537)
>You can't use the word "fuck" to accurately quote someone who didn't use that word.

Actually you very much can. It's the perfect word to describe certain attitudes, even if the person didn't use the word. It just translates to "who cares", "we don't need no stinking Generics", etc.

It can also convey many other things: http://reallifeglobal.com/how-use-word-fuck/

Re:Toward Go 2 by wwweston on Thursday July 13, 2017 @09:45PM (#14766808)
Bringing TOOWTDI from the realm of Python and Go to English, I see.

I suppose the argument I'm making does indeed depend on the premise that essential semantics of "fuck" can be conveyed in other ways. If you like, we could explore this by example.

Re:Toward Go 2 by kevhito on Thursday July 13, 2017 @08:50PM (#14766619)
Counting the weasel words.... 1. "might be" 2. "not entirely inaccurate" 3. "perhaps others" 4. "things like" 5. "the's reason to believe" 6. "apt enough"

And that's just in your first sentence.

My impression has always been that the Go core team is very open to the possible addition of generics, but also very wary of the very real downsides that generics have. Nothing I've ever seen from Rob or other core team members contradicts that. I'm open to citations if you can give any.

In contrast, a lot of Go users and proponents seem to be vehemently against generics, for wildly differing reasons. Some seem to be against them just for the lulz, others for crazy conspiracy theory or obscure philosophical reasons.

Me, I miss generics sometimes, but not enough to get riled up about it. I hope the Go folks come up with a clean, simple, and efficient way to get them, but until then I'm happy with the features Go has.

Re:Toward Go 2 by coldtea on Friday July 14, 2017 @05:07AM (#14768530)
>And that's just in your first sentence.

Yeah, god forbid someone is not absolute in their statements, but gives the benefit of the doubt. I'd say it only counts as "weasel" word when you don't say what you mean to say or want to hide your true intention/reality. But, for all the "maybe" etc, the parent made clear what he thinks: that the Go team doesn't care about Generics. He's not going two ways about it, for this to qualify as "weasel" wording.

>My impression has always been that the Go core team is very open to the possible addition of generics, but also very wary of the very real downsides that generics have.

Ten years on, and just some a handful of posts and "proposals" (not bigger than 1000-2000 words) written, for something that should have been there for the start (and for other languages with even less resources, like Julia, Nim, Rust, Crystal, Haxe, etc, has been), does not look like "very open".

I'd get the "We have a certain philosophy about Go, with which Generics don't match". Or "we don't like them, deal with it". But this back and forth, and ifs and buts ad inifinutum borders on the passive-aggresive treatment of the issue.

The "very real downsides" are the same old engineering tradeoffs every language had to make. "We'll only add them when we can have our cake and eat it too" is a weasel approach.

>Nothing I've ever seen from Rob or other core team members contradicts that. I'm open to citations if you can give any.

If by citations you mean "all talk but no walk" -- and even the talk being always hesitant and amounting to "we'll see", "if there is some magic way" (and the perennial "we're always open to it"), then yes, that has been a constant for a decade.

Now, I've just written ~3-5K lines of Go, and my company has just a few K or 10K lines of Go in production (mostly a C shop). But while I like a lot (static compilation for easy deployment, concurrency, standard library, go fmt, etc), one of the things that stops me using it more is the Generics situation.

Re:Toward Go 2 by dom96 on Friday July 14, 2017 @01:17PM (#14771425)
Have you given Nim a look? It sounds like it would be perfect for you. :)
Re:Toward Go 2 by jules on Thursday July 13, 2017 @09:53PM (#14766836)
What are the very real downsides that generics have?
Re:Toward Go 2 by fusiongyro on Friday July 14, 2017 @02:33AM (#14767973)
I always assumed the Go developers were more worried about the effect of this feature on compilation time than binary size. After all, Go shipped static binaries only for years. But making the type checker more intelligent is going to imply more time spent type checking. It could also add time to parsing unless they choose the syntax carefully.
Re:Toward Go 2 by jules on Friday July 14, 2017 @08:57AM (#14769412)
Do generics really add much compilation time? They sure do in C++ but that is because type checking C++ generics is based on substitution into the method body, which can have other generic calls inside of, which can lead to an exponential cascade and therefore exponential time compilation. Modern generics do not do that: a generic method invocation can be checked based on the type signature of the method alone.

For code generation you can do what Java does and erase generics (i.e. ignore them), in which case it will be no slower than code generation for manually erased code, which is what programmers have to write now. For good run-time performance you'd want to do specialisation, which may take longer but not much longer if the compiler is clever enough not to recompile the same method many times. C# does that and its implementation is actually fast enough for a JIT, let alone ahead of time compilation.

Re:Toward Go 2 by adrianratnapala on Friday July 14, 2017 @01:00AM (#14767593)
Even if you don't care about binary bloat (and I do care), it can introduce some of the same problems as dynamic typing.

If I am debugging some C++, and I find myself looking at templated function, then I can't easily see what types the template parameters are. Also it becomes hard to navigate to method calls etc.

C++ is a particularly bad example, because template metaprogramming is essentially typeless. But any form of polymorphism introduces these problems to some extent.

To be fair, that includes the run-time polymorphism already available in Go. Thus if generics allow us to replace some `interface{}` hacks with properly typed middle-men (even if they compile down to `interface{}`) then that would be genuine benefit.

Re:Toward Go 2 by mathw on Friday July 14, 2017 @02:38AM (#14767992)
Since C++ monomorphises every single template instantiation in a program, your debugger certainly should be able to tell you what the type parameters for that instance were!
Re:Toward Go 2 by Someone on Friday July 14, 2017 @03:31AM (#14768183)
A sufficiently smart linker will make that harder by removing functions that, byte for byte, are identical to one they already included in the executable ("identical code folding"; both gcc's gold linker and visual studio support that).
Re:Toward Go 2 by adrianratnapala on Friday July 14, 2017 @08:38PM (#14774367)
In my line of work I am very rarerly actully looking at a running executable with an interactive degger.

More often I am navigating through source code comparing it to logs, stack traces and other evidence that I can grab of what went wrong in production.

The source-level is important, because although I said "debugging" in my comment, what that very often comes to is first figuring out the intent of some other engineers from the thing they wrote -- and what they wrote is the source code, not the program state.

Re:Toward Go 2 by Retra on Thursday July 13, 2017 @10:07PM (#14766886)
Binary bloat and general difficulties with how one handles variance in light of people's expectations.
Re:Toward Go 2 by masklinn on Friday July 14, 2017 @06:21AM (#14768741)
> Binary bloat

That sure is a concern when just importing fmt increases your binary size from 900k to 1.6M…

Re:Toward Go 2 by sbov on Thursday July 13, 2017 @04:58PM (#14765171)
Did he compare those shortcomings with the shortcomings of not implementing generics at all? Because that is the tradeoff here. After decades of research, a decade of go, millions of lines of public and private code, a decade of feedback, and dozens of languages with generics, it's obvious that the perfect generic system isn't going to just happen, so it's not perfect generics vs imperfect generics, it's no generics vs imperfect generics.
Re:Toward Go 2 by kyrra on Thursday July 13, 2017 @02:08PM (#14763663)
Link to top-level proposal: https://github.com/golang/proposal/blob/master/design/15292-...

If you scroll to the bottom, you can see 4 large proposals written by Ian over the years.

Re:Toward Go 2 by pjmlp on Thursday July 13, 2017 @02:20PM (#14763788)
Except they seem to focus only on Java, .NET and C++, forgetting that generics were initially implemented in CLU back in 1975, and there were several programming languages since those days that had some form of generics being designed into them.
Re:Toward Go 2 by rsc on Friday July 14, 2017 @12:23AM (#14767452)
FWIW I have Liskov and Guttag (1986) on my desk. I haven't forgotten. I also explicitly address the "several since those days" in https://research.swtch.com/go2017#generics.
Re:Toward Go 2 by vram22 on Thursday July 13, 2017 @03:50PM (#14764568)
Any thoughts on Eiffel's implementation of generics?

https://en.wikipedia.org/wiki/Eiffel_(programming_language)#...

Re:Toward Go 2 by pjmlp on Thursday July 13, 2017 @03:54PM (#14764613)
I liked using it at the university back in the day, and didn't had to repeat code.

Eiffel is a very powerfull language with good tooling, just failed adoption, because licenses were too expensive and software industry still has issues valuing quality.

Re:Toward Go 2 by vram22 on Thursday July 13, 2017 @04:09PM (#14764724)
Interesting to hear your experience. I had read a good amount about Eiffel and also large parts of Bertrand Meyer's book Object-Oriented Software Construction (quite a thick book too, and which uses the syntax and semantics of Eiffel, or something close to it, IIRC [1]), some years ago. Had found the language very interesting and also was impressed by it (and by the book). Read some case studies / success stories about it, which were good too. He and his team seem to have taken a lot of pains and thought a lot about the design as well as implementation of the language, from both an academic and industrial use perspective - so it seemed to me.

There is also an interesting anecdote about use of Eiffel in the book, here:

https://en.wikipedia.org/wiki/Object-Oriented_Software_Const...

That section shows the the 1st edition of the book did use Eiffel (as I said above).

Re:Toward Go 2 by pjmlp on Thursday July 13, 2017 @04:54PM (#14765136)
With Eiffel tools you got the IDE with interactive development, including a VM for rapid prototyping. Then you would use the AOT compiler (via compilation to C) to produce shippable binaries.

So combining the easiness of interactive development with performance when it was time to ship the product.

It was also available before Java was a thing.

This is what I always kind of missed with Java and .NET, the previous generation of languages (Eiffel, Modula-3, Oberon(-2)) all had a mix of interactive development and AOT compilation for shipping release builds.

Re:Toward Go 2 by hota_mazi on Thursday July 13, 2017 @05:23PM (#14765373)
You seem to imply that Eiffel's solution was superior to Java's but nothing could be further from the truth.

The Eiffel compiler required four distinct sequential processes (note: not phases. I really mean that four programs needed to be run in sequence, and each of these four programs implemented who knows how many passes). Eiffel generated C++, huge executables, was incredibly slow (even with contract stuff turned off).

It was very hard to debug, with gdb routinely giving up on the complex .o generated. It was a very verbose language that implemented all known features under the sun, a bit like Ada and Scala.

Eiffel didn't take off for some very solid reasons.

Re:Toward Go 2 by rbehrends on Thursday July 13, 2017 @07:08PM (#14766076)
> The Eiffel compiler required four distinct sequential processes (note: not phases. I really mean that four programs needed to be run in sequence, and each of these four programs implemented who knows how many passes). Eiffel generated C++, huge executables, was incredibly slow (even with contract stuff turned off).

This was not an inherent problem of the language, but one of the implementation.

I know this because I wrote a compiler for an Eiffel dialect for my Ph.D. thesis and there have been other Eiffel compilers without these shortcomings.

Also, EiffelStudio – which seems to be what you are talking about – generated C code, not C++ and had the option to generate an intermediate representation instead that could be mixed with compiled code.

> It was a very verbose language that implemented all known features under the sun, a bit like Ada and Scala.

It was actually pretty minimalist, not at all like Ada or Scala.

Code was verbose because (1) programmers were encouraged to annotate methods with contracts and (2) exactly because it was minimalist and didn't have a lot of alternative ways of expressing the same functionality.

Edit: There are two hard parts about writing an Eiffel compiler.

1. Getting the semantics of feature renaming during inheritance right. If you aren't careful, it's easy to introduce errors during this step.

2. Doing separate compilation for mutually dependent classes. This is where much of the complexity of the EiffelStudio compiler comes from. Java solved the problem by simply not allowing separate compilation in those cases. If class A has a member of type B and B has a member of type A, they need to be compiled together.

Everything else that's involved in writing an Eiffel compiler does not require more than than what you learn in your typical compiler course. (Though, obviously, experience will get you better results.)

Re:Toward Go 2 by vram22 on Thursday July 13, 2017 @07:33PM (#14766194)
>Also, EiffelStudio – which seems to be what you are talking about – generated C code, not C++ and had the option to generate an intermediate representation instead that could be mixed with compiled code.

I think that must be what I was referring to by my mention about melting or freezing in a nearby comment. Didn't remember the technical details. Interesting feature. Wonder if other languages have something like that.

Re:Toward Go 2 by rbehrends on Thursday July 13, 2017 @07:49PM (#14766303)
That's EiffelStudio's Melting Ice stuff [1]. One of Bertrand Meyer's trademarks is his penchant for coming up with funny names for such features.

(Edit: Reading over it again, I realize that this may be read as criticism. To clarify, while I disagree with Meyer on some things, this isn't about disagreement. He is a teacher at heart – in fact, a very good teacher – and you can see some of his habits for keeping students engaged sometimes carry over into his writing.)

You don't see this approach really anymore, because these days it's so cheap to just generated unoptimized native code if compilation speed is an issue.

Obviously, if you have a JIT-compiler, then something similar happens internally in that some methods will be compiled, while others will be left in IR form (and sometimes, methods will even revert to using their IR). This was technology from back when CPU speed was still expressed in MHz.

OCaml had and still has both a bytecode and a native code format (for similar reason), but they cannot be mixed. OCaml's bytecode still sees use for (1) the bootstrap process, which allows you to build OCaml from scratch, (2) to run OCaml code on oddball architectures that the native compiler doesn't support, (3) to run code in the timetraveling debugger, and (4) when you need compact rather than fast executables.

OCaml's bytecode interpreter makes use of the fact that OCaml is statically typed and therefore doesn't incur nearly as much of a performance penalty as bytecode interpreters for dynamically typed languages.

[1] https://www.eiffel.org/doc/eiffelstudio/Melting%20Ice%20Tech...

Re:Toward Go 2 by vram22 on Thursday July 13, 2017 @08:14PM (#14766448)
Interesting, thanks for all the info.

>Obviously, if you have a JIT-compiler, then something similar happens internally in that some methods will be compiled, while others will be left in IR form (and sometimes, methods will even revert to using their IR).

I was going to say (in my parent comment to which you replied) that maybe that Eiffel's Melting Ice tech is something like Java JIT tech, but wasn't sure if they were the same thing.

Re:Toward Go 2 by pjmlp on Friday July 14, 2017 @02:12AM (#14767898)
Yes I implied just that.

The others already replied why.

Why on earth would one need to use gdb, given the nice graphical debugger of EiffelStudio?

Also it was way faster than code produced by Java, which I remind only got a JIT with version 1.3 and to this day only third party commercial JDKs do offer support for AOT to native code.

Java is also quite verbose. Verbose languages are quite good for large scale development.

On real life the majority of code is read not written, so I rather have it verbose and comprehensible than trying to make sense of a line full of hieroglyphs.

Re:Toward Go 2 by vram22 on Thursday July 13, 2017 @05:53PM (#14765615)
>It was a very verbose language

(Haven't worked much on Java recently, but did use it a fair amount some years ago.)

Isn't Java roughly equally verbose as Eiffel?

>that implemented all known features under the sun

At least based on looking at the Wikipedia article for Eiffel, it does not seem to have implemented functional programming, unless the article is out-of-date, or unless the agent mechanism supports FP somehow (not sure about that last bit).

Re:Toward Go 2 by coldtea on Friday July 14, 2017 @05:12AM (#14768548)
>* The Eiffel compiler required four distinct sequential processes (note: not phases. I really mean that four programs needed to be run in sequence, and each of these four programs implemented who knows how many passes). Eiffel generated C++, huge executables, was incredibly slow (even with contract stuff turned off).*

That sounds like unrelated to the semantics of the language.

Re:Toward Go 2 by vram22 on Thursday July 13, 2017 @06:01PM (#14765672)
>With Eiffel tools you got the IDE with interactive development, including a VM for rapid prototyping. Then you would use the AOT compiler (via compilation to C) to produce shippable binaries.

I seem to remember that there was some intermediate form of language translation too - something called melting or freezing or some such (might have been two different things). This was for EiffelStudio, probably, not generic Eiffel stuff.

>This is what I always kind of missed with Java and .NET, the previous generation of languages (Eiffel, Modula-3, Oberon(-2)) all had a mix of interactive development and AOT compilation for shipping release builds.

Interesting. Didn't know that that generation had both. As an aside, I had read a good description about Modula-2 (not -3) in a BYTE article (IIRC, years ago), and it seemed to me at the time that it was a good language. Having had a good amount of Pascal background before doing a lot of C, I was interested to try out Modula-2, but probably didn't have access to any compiler for it at the time. Later I read that Delphi's feature of units for modularity may have been inspired by Modula-2's modules, along with the concept of separate compilation.

Re:Toward Go 2 by pjmlp on Friday July 14, 2017 @05:48AM (#14768656)
Units in Turbo Pascal come from UCSD Pascal.

The OOP features in Turbo Pascal are based on Object Pascal, which was designed at Apple for their Lisa and Mac OS systems programing language, with input from Niklaus Wirth.

Turbo Pascal was the reason why most PC developers never had too much love for Modula-2, because by Turbo Pascal 4.0 we had all the goodies from Modula-2 with case insensitive keywords.

Also, the compilers were more expensive than Turbo Pascal ones.

Incidentally Martin Odersky was the author of Turbo Modula-2, the short lived Modula-2 compiler sold by Borland.

I usually thank my technical school for having us go through Turbo Basic and Turbo Pascal before getting into Turbo C.

We were using Turbo Pascal 5.5 (I already knew 3.0 and 4.0) and 6.0 was still hot out of Borland's factory, which is why I've always been a fan of strong typed systems programming.

Re:Toward Go 2 by vram22 on Friday July 14, 2017 @10:49AM (#14770188)
Interesting info ...

Turbo Pascal was the Pascal I'd used too, for a good while. Loved that environment. Really fast dev time and a fun language to work in.

Re:Toward Go 2 by rbehrends on Thursday July 13, 2017 @08:06PM (#14766408)
The key difference between Eiffel and Java generics is that Eiffel allows for covariance by design. Obviously, this is unsafe and runtime type checks had to catch these cases. The goal was originally to resolve this through additional static constraints [1], but in the end the downsides always outweighed the benefits.

In the end, Eiffel stuck with covariance and a type system that is technically unsound, because the simplicity of the type system outweighed any hypothetical gains from making it fully sound.

Practical problems with Eiffel's generics arise mostly from the fact that, like Java, constrained genericity inherently relies on nominal subtyping, which makes it less expressive than it could be.

[1] https://www.cs.princeton.edu/courses/archive/fall98/cs441/ma...

Re:Toward Go 2 by vram22 on Saturday July 15, 2017 @07:47PM (#14779739)
I'll check that out, thanks.
Re:Toward Go 2 by Sean1708 on Friday July 14, 2017 @12:20PM (#14770995)
Would you mind going into a bit more depth about Eiffel's generics? It's not obvious to me from Wikipedia how they differ from normal parametric polymorphism.
Re:Toward Go 2 by vram22 on Friday July 14, 2017 @02:44PM (#14772214)
Did you read this, which is linked to from my earlier link?

https://en.wikipedia.org/wiki/Generic_programming#Genericity...

I may not be able to throw more light on it than that, sorry, since I'm not an expert on these areas, just interested.

Re:Toward Go 2 by Sean1708 on Friday July 14, 2017 @05:45PM (#14773445)
Thanks, I completely missed that "Basic/Unconstrained genericity" was a subsection of "Genericity in Eiffel" when I first saw that page.
Re:Toward Go 2 by vram22 on Friday July 14, 2017 @06:03PM (#14773568)
NP.
Re:Toward Go 2 by masklinn on Thursday July 13, 2017 @02:40PM (#14763949)
> Except they seem to focus only on Java, .NET and C++

C# isn't mentioned in any of the previous proposals, only Java, C++ and C.

Re:Toward Go 2 by _old_dude_ on Thursday July 13, 2017 @05:53PM (#14765613)
C# does generics specialization at runtime, hard to do if you have no JIT :)
Re:Toward Go 2 by davidp on Thursday July 13, 2017 @07:07PM (#14766067)
Thanks for the tip, you made me go google some things! [0]

Do you need a full-on JIT, or just a runtime? [1]

[0]: https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...

[1]: https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...

Re:Toward Go 2 by AlphaSite on Thursday July 13, 2017 @10:28PM (#14766979)
As I understand it it’s JIT in name only, doing the compilation on first run and then never again.
Re:Toward Go 2 by pjmlp on Friday July 14, 2017 @02:04AM (#14767870)
That is also a JIT, dynamic compilation doesn't require recompiling the code all the time.

The AS/400 uses a kernel level JIT, binaries are only JITted at installation time or explicitly via the command line.

The Lisp environments also only used JIT once.

Some implementations of Oberon would use bytecode instead of native code and JIT on module load.

There are many other examples.

Re:Toward Go 2 by e12e on Thursday July 13, 2017 @07:25PM (#14766160)
This made me wonder if there's been efforts to fork golang and add generics as a proof of concept? In theory it should be much easier than a few of the crazy things people have done with c over the years?
Re:Toward Go 2 by pjmlp on Saturday July 15, 2017 @12:18PM (#14777406)
It would be an wasted effort given the community's high resistance to them, better spend those hours contributing to a project where users value the work given for free.
Re:Toward Go 2 by vec on Thursday July 13, 2017 @05:02PM (#14765208)
I'm not even a Go developer, I just played with it a bit a couple of years ago and used it for a small one-off internal API thing, and I can think of a dozen real-world use cases for generics off the top of my head.

  * type-safe containers (linked lists, trees, etc.)
  * higher order functions (map, reduce, filter, etc.)
  * database adapters (i.e. something like `sql.NullColumn<T>` instead of half a dozen variations on `sql.NullWhatever`)
  * 99% of functions that accept or return `interface{}`
I appreciate that they seem open to the idea for v2, but "the use case isn't clear" is absurdly out of touch with the community. Using `interface{}` to temporarily escape the type system and copy/pasting functions just to adjust the signature a bit were among the first go idioms I learned, and they both exist solely to work around the lack of generics.
Re:Toward Go 2 by spyspy on Thursday July 13, 2017 @08:30PM (#14766529)
It's generally the opinion of the Go community that map, reduce and filter are bad ideas due to how easily they are abused. A for loop gets the job done easily enough. If you've ever worked with data scientists working with Python, you'll quite often see them all chained together, probably with some other list comprehensions thrown in until it becomes one incomprehensible line.
Re:Toward Go 2 by pcwalton on Thursday July 13, 2017 @10:32PM (#14766991)
If that's the case, then the Go community is wrong.

For loops do not get the job done easily enough. I've lost count of the number of times I've had to do contortions in order to count backwards inclusive down to zero with an unsigned int. With a proper iterator API, it's trivial.

Furthermore, for loops are a pain to optimize. They encourage use of indices everywhere, which results in heroic efforts needed to eliminate bounds checks, effort that is largely unnecessary with higher level iterators. Detecting the loop trip count is a pain, because the loop test is reevaluated over and over, and the syntax encourages complicated loop tests (for example, fetching the length of a vector over and over instead of caching it). For loop trip count detection is one of the major reasons why signed overflow is undefined in C, and it's a completely self-inflicted wound.

I'm generally of the opinion nowadays that adding a C-style for loop to a language is a design mistake.

Re:Toward Go 2 by concede_pluto on Thursday July 13, 2017 @11:36PM (#14767254)
It's also strange that a language that wants to encourage parallelism requires for loops, and specifies that they always run sequentially. Java 8 can put map/reduce with a thread pool in the standard library precisely because it doesn't use a for loop; imagine how tedious and repetitive the Go version would be: https://docs.oracle.com/javase/tutorial/collections/streams/...
Re:Toward Go 2 by Sharlin on Friday July 14, 2017 @03:30AM (#14768180)
To be fair, I don't think Go prioritizes parallelism as much as it does concurrency.
Re:Toward Go 2 by fmap on Friday July 14, 2017 @07:11AM (#14768911)
> For loops do not get the job done easily enough.

There was a nice paper at this years POPL which (in my opinion) allows you to substantiate this claim.

The paper is "Stream Fusion to Completeness", by Oleg Kiselyov, Aggelos Biboudis, Nick Palladinos, and Yannis Smaragdakis. The actual question in the paper is how to compile away stream operations to imperative programs using for/while loops and temporary variables. On the other hand, if we look at the output of the compiler we can see how complex it is to express natural stream programs using only for/while loops.

For instance, even very simple combinations of map/fold/filter create while loops and make it difficult to detect the loop trip count afterwards (in fact, you need an analysis just to detect that the loop terminates). If you combine several such streams with zip, the resulting code makes a nice entry for obfuscated code contests. Finally, if you use flatMap the resulting control flow doesn't fit into a for/while loop at all...

So for/while loops are not simpler than stream processing primitives and unless you explicitly introduce temporaries (i.e., inline the definition of map/fold/etc.) you quickly end up with very complicated control flow.

Re:Toward Go 2 by skybrian on Friday July 14, 2017 @11:42AM (#14770649)
This all depends on what "the job" being done well enough is. You can't use a research paper to refute the experience of the many programmers who successfully use for loops to get their work done. That's a statement about usability, not expressiveness.

If you want to show something else is easier to use, you'd have to do a user study, and even that's not going to be universally applicable since it depends on the previous experiences of the user population being tested. It's why these things tends to be debated as a matter of taste.

Re:Toward Go 2 by di4na on Friday July 14, 2017 @01:16PM (#14771413)
Interestingly there are user study, mainly on kids.

They all show that the natural expression is through declarative programming and that for loop are never what comes naturally.

Re:Toward Go 2 by skybrian on Friday July 14, 2017 @02:02PM (#14771859)
Interesting. Links?
Re:Toward Go 2 by lewisl9029 on Thursday July 13, 2017 @11:02PM (#14767114)
Yes, people can get crazy with inline anonymous function chaining/composition, and that can quickly get out of hand in terms of maintainability and readability, but deeply nested imperative loops is often much, much worse to debug and understand, because the intermediate steps are not nearly as explicit as in a functional chain/composition that simply takes data and returns data at every step.

Regardless, these are simply cases of people writing bad code, and nobody is claiming map/reduce/filter is a panacea for bad code.

Functional composition/chaining works best with small, well-named single purpose functions that compose/chain together into more complex functionality (with appropriate names at every non-trivial level of chaining/composition). You can't easily compose/chain imperative loops this way (at least not without wrapping them in functions that take data, and returns transformed data, by which point you might as well use map/reduce/filter to transform the data to begin with to get rid of the impedance mismatch).

Re:Toward Go 2 by runeks on Friday July 14, 2017 @03:05AM (#14768097)
> If you've ever worked with data scientists working with Python, you'll quite often see them all chained together, probably with some other list comprehensions thrown in until it becomes one incomprehensible line.

It's not incomprehensible, it's just phrased a different way from what you're used to.

A lot of programming boils down to mutating local or global state, by executing lines of code -- each of which mutating the contents of some variable somewhere -- in order, one at a time. But this is just one style of programming, and is not the only one. When using map, filter, reduce etc. we, instead, construct a path through which data flows, where each line modifies some aspect of the data, as it flows through the path. This is essentially what Functional Reactive Programming is, although you can get the same effect using a pure language and function composition.

Re:Toward Go 2 by jpttsn on Friday July 14, 2017 @04:04AM (#14768310)
> It's not incomprehensible, it's just phrased a different way from what you're used to.

What would be incomprehensible?

Re:Toward Go 2 by coldtea on Friday July 14, 2017 @05:24AM (#14768588)
Code that's badly written.

As opposed to code that just uses chained map, reduce etc as opposed to nested or sequential for loops.

One is a difference is skill, clarity etc, the other is a difference in style (imperative vs fp).

Re:Toward Go 2 by rsc on Friday July 14, 2017 @12:25AM (#14767464)
> It's generally the opinion of the Go community that map, reduce and filter are bad ideas due to how easily they are abused.

There is a germ of truth here - sometimes list comprehensions make code harder to understand than if you just wrote an if statement or a loop - but you've overgeneralized. I don't think anyone on the core Go team seriously thinks that map and reduce are bad ideas when Google relies so heavily on MapReduce (and its successors).

Re:Toward Go 2 by jnwatson on Friday July 14, 2017 @12:33AM (#14767496)
"Ability to abuse" isn't a good criteria for language design. I've seen plenty of abuse of Go channels, but I'm not going to make the argument you should remove them.

Python's comprehensions are among the most powerful, easy to use, concise capabilities of any language I've used. You can address the abuse issue with coding guidelines: no more than 2 deep. Done.

Re:Toward Go 2 by rbehrends on Thursday July 13, 2017 @08:54PM (#14766637)
The same argument applies, mutatis mutandis, to imperative iteration constructs such as range.
Re:Toward Go 2 by coldtea on Friday July 14, 2017 @05:22AM (#14768579)
>It's generally the opinion of the Go community that map, reduce and filter are bad ideas due to how easily they are abused.

How easily are they abused?

Because it's the opinion of the programming community, including the brightest programmers out there, that FP, and map, reduce and filter are totally fine and dandy.

Re:Toward Go 2 by piinbinary on Thursday July 13, 2017 @09:02PM (#14766670)
I would also love Result<Err,MyThing> in as a return type in place of (err, myThing)
Re:Toward Go 2 by bjz_ on Friday July 14, 2017 @06:39AM (#14768795)
Yeah, using a tuple for what clearly should be a disjoint union is infuriating. I really don't buy the gopher argument that 'it is hard to understand'.
Re:Toward Go 2 by zemo on Thursday July 13, 2017 @08:18PM (#14766468)
> I'm not even a Go developer

> Using `interface{}` to temporarily escape the type system

tbh if you program Go correctly, you use interface{} pretty rarely.

Re:Toward Go 2 by camus2 on Thursday July 13, 2017 @09:05PM (#14766680)
> tbh if you program Go correctly, you use interface{} pretty rarely.

It's a bit like saying "if you program C correctly, you use (void *) pretty rarely.". that's not the case, Go maintainers themselves keep on adding API with interface {} everywhere. Are you saying they are not programming Go correctly?

Re:Toward Go 2 by kernelbandwidth on Thursday July 13, 2017 @03:47PM (#14764541)
The request for use cases in Go seems a bit like begging the question to me. Since Go doesn't have generics, anything designed in Go will necessarily take this into account and design around this lack. So it's relatively easy to show that Go doesn't have a compelling use case for generics, since the designs implemented in Go wouldn't (usually) benefit from generics!

Rust has generics and traits/typeclasses, and the result is my Rust code uses those features extensively and the presence of those features greatly influences the designs. Similarly, when I write Java, I design with inheritance in mind. I would have trouble showing real world use cases for inheritance in my Rust code, because Rust doesn't have inheritance and so the designs don't use inheritance-based patterns.

Essentially, how does one provide real world evidence for the utility of something that's only hypothetical? You can't write working programs in hypothetical Go 2-with-generics, so examples are always going to be hypothetical or drawn from other languages where those tools do exist.

Re:Toward Go 2 by Pxtl on Thursday July 13, 2017 @10:05PM (#14766877)
It reminds me of the old urban planning line "You can't decide on the necessity of a bridge based on the number of people who swim across the river".

Users who have heavy need for genetics have already moved away from Go.

Re:Toward Go 2 by erikpukinskis on Thursday July 13, 2017 @05:34PM (#14765462)
This suggests that both generics and inheritance are unnecessary.
Re:Toward Go 2 by camus2 on Thursday July 13, 2017 @09:11PM (#14766709)
And if you look at C you'll see that interfaces and struct methods are also unnecessary, GC is also unnecessary, bound-checked arrays are also unnecessary.

The question is, do you want to write type safe code? which is memory safe? which has bound-checked array? or not? Assembly makes all that stuff unnecessary as well. This is not a good argument, especially when Go std lib is getting all these type unsafe API using interface {} everywhere. That is precisely what generics are for, to allow writing parametric functions (sort) or type safe containers instead of sync.Map like in the std lib.

If you care about type safety and code re-use then generic programming is a necessity. What do you think append, copy or delete are? these are generic functions. All people are asking is the ability to define their own in a type safe fashion.

Are these use cases Russ Cox don't know they exist?

Re:Toward Go 2 by erikpukinskis on Sunday July 16, 2017 @02:42PM (#14783491)
What's unsafe about using one of the C libraries that do bounds checking, etc?

The argument about assembly is a red herring. Let's compare:

1) In addition to writing your business functions, learn these additional control structures to obtain safety

2) When writing your business functions, also use these well reviewed functions that enforce type and memory safety when moving code across interfaces.

3) Port all of your code to assembly, write you own memory safety control structures from scratch.

You see the difference? The choice in your mind between "add control structures to the language" and "do everything painstakingly by hand" but we are advocating a third option, which is: use well reviewed libraries written with only the basic control structures.

The reason I am advocating that is the more control structures you have the harder it is to analyze code. You end up slowly moving your codebase to a point where only people with deep deep knowledge of an advanced programming language can read it.

I think culturally, in 2017, programmers underestimamte how much can be done with just functions and literals and well written helpers.

The reason for that is we are rewarded (psychologically and professionally) for learning new control structures, but not as often for writing better code using the beginner structures.

Re:Toward Go 2 by masklinn on Friday July 14, 2017 @06:27AM (#14768759)
Assemblies over the ages denote that so are loops, functions[0] and named variables, you can do everything using addresses, offsets and jumps.

They sure are useful to readability and maintainability.

[0] which can obviously be used to replace looping constructs anyway

Re:Toward Go 2 by chongli on Friday July 14, 2017 @03:37AM (#14768201)
Thanks to Turing equivalence, all programming languages are unnecessary. We should all go back to writing machine code.
Re:Toward Go 2 by kccqzy on Thursday July 13, 2017 @05:44PM (#14765546)
It only suggests you can't easily give an example because the language is forcing a design where such things aren't needed. Sort of like linguistic relativity.
Re:Toward Go 2 by XorNot on Thursday July 13, 2017 @06:41PM (#14765938)
Which still proves the parent's point: it's not necessary. The question is what absolutely can't be done without them (probably nothing) so a better question is how much design/engineering/test time could be saved with them?

On the latter part I'm fairly cynical these days, since I'm presently on a team where the lead embraced a Scala-DSL heavy, functional design and the net result has been a total loss of project velocity because when we need to prototype a new requirement, the push back has been paraphrasing "oh, could you not do that in <core product> and handle it somewhere else?" - so we end up with a bunch of shell scripts cobbled together to do so.

Re:Toward Go 2 by kccqzy on Thursday July 13, 2017 @07:37PM (#14766220)
> what absolutely can't be done without them

Of course nothing can't be done without them. With or without generics or inheritance the language is still Turing complete.

Re:Toward Go 2 by stormbrew on Thursday July 13, 2017 @01:58PM (#14763562)
If I were in the "go community" I would be pretty annoyed by this quote. I would find it dismissive of the literal years of people pointing at areas of their code that are bloated and less safe due to not having generics.

It doesn't seem to me that there's a shortage of people pointing out real-world use cases at all, and I'm looking from the outside in.

Re:Toward Go 2 by liveoneggs on Thursday July 13, 2017 @03:10PM (#14764227)
the use of the monotonic click example is also interesting because of the similar tone of responses to that issue. I think it's just the rsc way.

basically it goes like: > If google isn't screaming about it, it's not important. > If google has a workaround, then it's fixed.

Re:Toward Go 2 by grey-area on Friday July 14, 2017 @01:37AM (#14767755)
As a maintainer, you're bombarded with reasonable requests (I think around 10 a day on the Go project). Part of your job is to turn down hundreds of these and pick the few that benefit the most people from a diverse set of users, and also don't break anything or extend the api surface too much. Then whatever you choose people complain vociferously. Sometimes good requests get ignored in that noise.

Choosing is hard, and while they could improve I think the Go maintners have done a pretty good job, and are willing to admit mistakes.

Re:Toward Go 2 by rattray on Wednesday July 19, 2017 @11:51AM (#14805188)
> and are willing to admit mistakes.

Admitting a mistake on "generics" would probably go a long way towards credibility for the team.

No matter how many excellent decisions they've made that have delicately balanced opinions and tradeoffs, this one hasn't gone over well, and it's very widely known.

Re:Toward Go 2 by saghm on Thursday July 13, 2017 @02:01PM (#14763588)
I haven't programmed in Go, but from what I understand, Go's explicit error handling isn't enforced by the type system, as you can leave off an `if err { ... }` check and everything still compiles. I think adding a generic result/error type (like the Result type in Rust or the Either type in Haskell) would be a pretty useful feature, as currently the error handling sits in kind of a weird place between forced handling and traditional exceptions.
Re:Toward Go 2 by the_duke on Thursday July 13, 2017 @03:28PM (#14764392)
I have no idea why you are being downvoted.

In Rust, this was handled the right way. The Result type forces you to at least actively dispose of the error.

In Go, it's just way too easy to leave an error unhandled.

Re:Toward Go 2 by kibwen on Thursday July 13, 2017 @06:19PM (#14765816)
> The Result type forces you to at least actively dispose of the error.

Sort of: by default, an unused value of the `Result` type produces a compiler warning. Like all warnings in Rust, this category of warnings can be promoted to a hard error for all users with a single line of code. And unlike other languages where compiler warnings are uniformly ignored, there is a strong culture in Rust of making sure that code compiles warning-free (largely due to the fact that the compiler is rather selective about what to issue warnings about, to help avoid useless false positives and warning spew (there is a separate project, called "clippy", for issuing more extensive warnings)).

Re:Toward Go 2 by steveklabnik on Thursday July 13, 2017 @07:53PM (#14766323)
I think you're thinking of Result<(), E>, whereas they're thinking of Result<T, E>, that is, you only get that warning if you don't care about the Ok value of the Result. If you need the value, you also need to deal with the error in some fashion.
Re:Toward Go 2 by XorNot on Friday July 14, 2017 @04:26AM (#14768379)
This seems like a no-op to me. My stack of code tools always warns me of unhandled errors (insert argument about maybe the compiler should be doing it I guess?) but I've never understood how a Result type provides any real benefit over the usual error-tuple Go uses.

In both cases I have to either write a handler immediately after the call, or I'm going to fail and toss it back up to whoever called me.

Errors-should-be-values has always seemed like a bizarre statement to me. Like, fine, but they're still errors - their core feature will be that I stop what I want to do and handle them. And in that regard I much prefer exceptions (at least Python style exceptions) because most of the time I just want to throw the relevant context information up to some level of code which knows enough to make a decision on handling them. The thing I really want is an easy way to know all the ways something can fail, and what information I'm likely to get from that, so I can figure out how I want to handle them.

Re:Toward Go 2 by saghm on Friday July 14, 2017 @02:55PM (#14772282)
> In both cases I have to either write a handler immediaitely after the call, or I'm going to fail and toss it back up to whoever called me.

The main difference as I see it is that in Rust, you can't get the success value if there's an error, so you're forced by the compiler to handle any error if there is one. With tuples, you're free to just look at one element regardless of the value of the other.

Re:Toward Go 2 by morecoffee on Friday July 14, 2017 @03:10AM (#14768116)
In order to maintain compatibility with other interfaces, they have to return error in several places. Take bytes.Buffer, which return errors even when they are impossible. Same with http.Cookie(). It promises it will only ever be http.ErrNoCookie, but that isn't going to make static analysis tools happy.
Re:Toward Go 2 by imsofuture on Thursday July 13, 2017 @02:06PM (#14763646)
Go's errors are really nice (if a bit repetitive) in my opinion. Type signatures enforce that you accept and acknowledge an error returned from an invocation, but leave it up to you to handle, pass along, or silently swallow.
Re:Toward Go 2 by hdhzy on Thursday July 13, 2017 @03:32PM (#14764417)
So... Just like checked exceptions in Java?
Re:Toward Go 2 by imsofuture on Thursday July 13, 2017 @04:40PM (#14764990)
Yes, it's somewhat similar in that the compiler checks if you have handled or chosen not to handle an error. You're not allowed to ignore it (through omission).
Re:Toward Go 2 by baq on Thursday July 13, 2017 @05:24PM (#14765382)
yeah but better because you don't break the world if you add a new exception to a public method.
Re:Toward Go 2 by concede_pluto on Thursday July 13, 2017 @11:47PM (#14767311)
Declaring that every method throws Exception doesn't break the world any more than every Go function returning an argument of type error. You're intentionally saying pretty much anything could go wrong and nobody can plan ways to recover.
Re:Toward Go 2 by acdha on Thursday July 13, 2017 @03:05PM (#14764185)
Does that mean it now throws an error if you use the common punt like `foo, _ := …` and never check `_`?
Re:Toward Go 2 by growse on Thursday July 13, 2017 @04:38PM (#14764968)
No, because using `foo, _` you're explicitly saying that you don't care about the error.
Re:Toward Go 2 by imsofuture on Thursday July 13, 2017 @04:37PM (#14764957)
No, but that's what I mean as intentionally ignoring.
Re:Toward Go 2 by wheaties on Thursday July 13, 2017 @01:45PM (#14763423)
If they want to "learn" about generics perhaps they can read the literature of the past 30yrs and look at how other languages have adopted those learnings: Java, C#, Haskell, OCaml and Coq.

Look, even allowing type aliases to become part of an interface declaration would be a HUGE win. You can't currently write portable arbitrary data structures without reimplementing them with a code generator. Ugh!

Re:Toward Go 2 by seanwilson on Thursday July 13, 2017 @02:26PM (#14763850)
> If they want to "learn" about generics perhaps they can read the literature of the past 30yrs and look at how other languages have adopted those learnings: Java, C#, Haskell, OCaml and Coq.

Yeah, I find it strange how languages are trending at a glacially slow pace to having the same features that strongly typed functional programming languages have had for literally decades. It's like we're going to be using actual functional programming languages eventually but the only way it'll happen is to very slowly change what everyone is currently using in small steps.

Static types, immutability, type inference and non-null variables are popular design choices right now but they've been in functional programming languages for nearly 50 years. I'm still waiting for inductive types and pattern matching to turn up in a mainstream language and seeing them talked about like they're new concepts.

Re:Toward Go 2 by JBReefer on Thursday July 13, 2017 @02:46PM (#14763996)
C# is adding pattern matching in the upcoming release, and to your point, people are acting like it's the new hotness.
Re:Toward Go 2 by masklinn on Thursday July 13, 2017 @02:55PM (#14764080)
That's not exactly surprising, the C# community has been doing that since the beginning of the language, anything not in the language is pointless academic wankery, and as soon as Microsoft announces it it's the best innovation in computing history since Microsoft was created.

Source: got to interact with the community between the C# 1.0 and 4.0 releases (2.0 added generics, 3.0 added lambdas, neither feature was considered of any use to a Productive Developer up to the day when Microsoft officially announced them).

Re:Toward Go 2 by seanmcdirmid on Thursday July 13, 2017 @03:08PM (#14764210)
> That's not exactly surprising, the C# community has been doing that since the beginning of the language, anything not in the language is pointless academic wankery, and as soon as Microsoft announces it it's the best innovation in computing history since Microsoft was created.

That isn't true inside Microsoft. Many of the people who work on C# are the same academic wanks that work on Scala or F#. C# has a different user base from those languages though, so they still have to be careful what they add to the language, and many language features are planned 3 or 4 versions in advance.

Re:Toward Go 2 by masklinn on Thursday July 13, 2017 @04:36PM (#14764948)
> That isn't true inside Microsoft.

No, that was not intended as included in "the C# community". Hell, SPJ used to work at Microsoft (he may still do, but he used to).

> the people who work on C# are the same academic wanks that work on Scala or F#

I'm sure you mean wonks, but I liked the typo.

> C# has a different user base from those languages though, so they still have to be careful what they add to the language, and many language features are planned 3 or 4 versions in advance.

I have no issue with the evolution of C# rate or otherwise, only with a number of its users.

Re:Toward Go 2 by seanmcdirmid on Thursday July 13, 2017 @08:17PM (#14766462)
Ugh, that was bad embarrassing typo.

C# has a specific audience, and the language designers cater to them pretty well. I really really like C# as a language, and I don't mind delayed access to certain features that I already like from other languages.

You probably have a beef with some C# users not because of their choice of language, but with the field they work in (primarily enterprise) tends to breed a certain kind of attitude that other techies don't like very much.

Re:Toward Go 2 by hinkley on Thursday July 13, 2017 @05:52PM (#14765607)
Clearly they finally learned the lessons of Apple. Old is busted, new is perfect.

(says a man planning to purchase his 5th Macbook Pro later this year)

Re:Toward Go 2 by seanmcdirmid on Thursday July 13, 2017 @03:04PM (#14764178)
It is new to C#, which is slowly catching up to Scala and F# in that regards. Mads Torgesen is good friends with Martin Odersky, in fact, when I first met Mads back in 2006 or so, they were talking about adding pattern matching to C#. C# is a much more conservative language, and it makes sense it would take a while to add.

There are good reasons to use C#, so when it gets a new feature that other languages have had for years, well, it is newsworthy.

Now when will javascript get pattern matching?

Re:Toward Go 2 by herrschnapps on Thursday July 13, 2017 @04:36PM (#14764951)
It's just become a Stage 0 proposal: https://github.com/tc39/proposal-pattern-matching
Re:Toward Go 2 by seanmcdirmid on Thursday July 13, 2017 @08:18PM (#14766467)
Woo hoo, can't wait. Especially with what TypeScript can do with this.
Re:Toward Go 2 by _old_dude_ on Thursday July 13, 2017 @06:02PM (#14765689)
There is a paper, Pizza into Java: Translating theory into practice, from Odersky and Wadler at POPL 97 about how to mix generics, lambda and pattern matching in a Java like language.

C# and Java are slowly catching up :)

Re:Toward Go 2 by dvlsg on Thursday July 13, 2017 @04:21PM (#14764826)
There's a proposal for it! Stage 0? Stage 1? Don't remember what stage it's in off the top of my head, but it looks promising.
Re:Toward Go 2 by mathw on Friday July 14, 2017 @02:43AM (#14768014)
I think the reason for that enthusiasm is not so much that it's the new hotness (although it is some people's first encounter with the idea), but that it's now available in a mainstream language that their employer will actually let them use (in about five years when they finally bother upgrading Visual Studio).
Re:Toward Go 2 by masklinn on Thursday July 13, 2017 @02:50PM (#14764027)
Surely if Go is considered mainstream so is Swift?
Re:Toward Go 2 by chongli on Friday July 14, 2017 @03:44AM (#14768221)
strange how languages are trending at a glacially slow pace

Human behaviour is strange when you expect rationality. Sour grapes is such a pervasive cognitive bias that one has to wonder why it exists since it's obviously irrational. I think it's likely that it presents a major advantage in the psychology of group cohesion.

Re:Toward Go 2 by masklinn on Thursday July 13, 2017 @01:54PM (#14763512)
> perhaps they can read the literature of the past 30yrs

40, nearing on 45:

> Milner, R., Morris, L., Newey, M. "A Logic for Computable Functions with reflexive and polymorphic types", Proc. Conference on Proving and Improving Programs, Arc-et-Senans (1975)

Re:Toward Go 2 by endymi0n on Thursday July 13, 2017 @02:04PM (#14763620)
Guess what: they did.

https://news.ycombinator.com/item?id=8756683

They just weren't ready to make any of the significant tradeoffs other languages have to do in order to support them.

Whether that's a good outcome, I'm not fully sure - but there's definitely a lot of research in that area.

Re:Toward Go 2 by pcwalton on Thursday July 13, 2017 @02:21PM (#14763797)
The basic tradeoff is monomorphization (code duplication) vs. boxing (in Go speak, interface{}). The problem with saying "well, this is a tradeoff and both sides have downsides, so we won't do anything" is that the tradeoff still exists—it's just something that manually has to be done by the programmer instead of something that the compiler can do. In Go, the monomorphization approach is done with code duplication (either manually or with go generate), while the boxing approach is done with interface{}. Adding generics to the language just automates one or both of the approaches.

The idea that the monomorphization/boxing tradeoff can be dodged by not having generics in the language is a fallacy. In Go, today, you as a programmer already have to decide which side of the tradeoff you want every time you write something that could be generic. It's just that the compiler doesn't help you at all.

Re:Toward Go 2 by masklinn on Thursday July 13, 2017 @02:36PM (#14763919)
> The basic tradeoff is monomorphization (code duplication) vs. boxing (in Go speak, interface{}).

And even that is not the whole story, just because you reify generics does not mean you have to monomorphise everything, Microsoft's C# compiler only monomorphises value types.

Also Go may box in other contexts than interfaces depending on escape analysis (according to https://golang.org/doc/faq#stack_or_heap).

Re:Toward Go 2 by slrz on Friday July 14, 2017 @10:35AM (#14770078)
The FAQ entry does not state that the Go compiler boxes escaping variables (it doesn't, AFAICT). How did you arrive at that conclusion?
Re:Toward Go 2 by vram22 on Thursday July 13, 2017 @03:45PM (#14764524)
>monomorphization

Does that mean writing a separate version of an algorithm for each type or types that you want it to handle? Like a sort for ints, a sort for floats, etc., even if the logic is otherwise the same (or almost)?

Not a PL design or theory expert, just interested.

Re:Toward Go 2 by pcwalton on Thursday July 13, 2017 @03:46PM (#14764535)
Yes, it means specializing the code and generating a separate version of the function for each type it is instantiated with.
Re:Toward Go 2 by vram22 on Thursday July 13, 2017 @04:47PM (#14765065)
Got it, thanks.
Re:Toward Go 2 by willtim on Thursday July 13, 2017 @03:30PM (#14764405)
In Haskell (and I believe Scala), one can use pragma hints to specify to the compiler when to specialise, if performance becomes a problem. So I don't see this as an argument against parametric polymorphism.
Re:Toward Go 2 by slavapestov on Thursday July 13, 2017 @04:37PM (#14764963)
> The basic tradeoff is monomorphization (code duplication) vs. boxing (in Go speak, interface{}).

There is also the approach taken by Swift, where values of generic type are unboxed in memory, and reified type metadata is passed out of band. There's no mandatory monomorphization.

Re:Toward Go 2 by pcwalton on Thursday July 13, 2017 @04:54PM (#14765135)
Really by "boxing" I mean "dictionary passing" (I've also seen the term "intensional type analysis" for it). That encompasses approaches like Java as well as those of Swift.

Hybrid approaches in which the compiler (or JIT!) decides whether to monomorphize or use vtables are also possible.

Re:Toward Go 2 by slavapestov on Thursday July 13, 2017 @05:02PM (#14765202)
"Dictionary passing" is a good term for this implementation strategy, I haven't heard it named before. Do you know of any other languages that take a similar approach?
Re:Toward Go 2 by dbaupp on Thursday July 13, 2017 @05:48PM (#14765579)
Re:Toward Go 2 by slavapestov on Friday July 14, 2017 @04:34PM (#14772951)
I thought Ocaml still boxed values, so there's no equivalent of value witness tables?
Re:Toward Go 2 by dbaupp on Sunday July 16, 2017 @09:48PM (#14785127)
Sure, but it still does basically the same thing of passing around witness tables. Values happen to have a uniform representation, but this seems seems like variation within a cluster of languages that do similar thing rather than something fundamentally new.
Re:Toward Go 2 by dbaupp on Thursday July 13, 2017 @04:53PM (#14765128)
The Swift approach shares many of the same characteristics and trade-offs as "true" (aka Java-style) boxing. Of course, it does avoid some downsides of that, but also brings along some additional ones.
Re:Toward Go 2 by slavapestov on Thursday July 13, 2017 @05:07PM (#14765252)
I think the main difference is that the Swift approach ends up being more memory-efficient, eg consider Swift's Array<Int> is stored as an array of integer values compared to a Java's ArrayList<Integer> where each element is boxed.

Also the Swift optimizer can clone and specialize generic functions within a module, eliminating the overhead of indirection through reified metadata.

Re:Toward Go 2 by dbaupp on Thursday July 13, 2017 @05:53PM (#14765620)
Yes, there's some pitfalls of Java that Swift avoids, like compulsory allocation, but it fundamentally has the same style of indirection (often pointers to stack memory rather than heap, but still pointers), type erasure and pervasive virtual calls, and brings with it even more virtual calls due to needing to go through the value witness table to touch any value (which might be optimised out... or might not, especally with widespread resilience).

The compiler specializing/monomorphizing as an optimisation shows that Swift has a hybrid approach that tries to balance the trade-offs of both (like many other languages, like Haskell, and, with explicit programmer direction, Rust), but the two schemes still fall into the broad categories of monomorphizing vs dictionary passing, not something fundamentally different.

Re:Toward Go 2 by slavapestov on Friday July 14, 2017 @04:33PM (#14772944)
Oh, hi Huon.
Re:Toward Go 2 by masklinn on Thursday July 13, 2017 @02:18PM (#14763772)
> Guess what: they did.

Yeah as pointed out in that very thread by pjmlp:

    As usual, it lacks discussion about generics in:
    Eiffel
    Ada
    Modula-3
    D
    MLton
    .NET
    Rust
    Haskell
    OCaml
    Sather
    BETA
    CLU
Oh wait, they're pointing out that none of these is even remotely being discussed in the article hinting that they did not, in fact, and much prefer taking down strawmen they built from some sort of daguerreotypes of Java and C++.

> They just weren't ready to make any of the significant tradeoffs other languages have to do in order to support them.

Ah yes, the ever so convenient but never actually clarified "tradeoffs", which only ever happen for generics but oddly enough apparently don't happen for any other feature.

> there's definitely a lot of research in that area.

That there is, would be nice if Go's designers ever bothered actually using it.

Re:Toward Go 2 by fmap on Friday July 14, 2017 @07:37AM (#14769004)
Nitpick, but the idea is even older, going back at least to Girard (1971) and Reynolds (1974). :)

I don't know exactly what the problem is for Go. There are tradeoffs, e.g., just with the type system: impredicative, stratified or predicative quantification, implicit subtyping or explicit type instantiation, value restrictions, variance handling for mutable inductive types, Hindley-Milner or bidirectional typechecking, etc. There are more tradeoffs with the implementation. Fortunately, these are all well understood by now.

However, it is also true that many mainstream languages famously got generics wrong. What's most infurating about this situation is that a lot of research just gets ignored. If the question is really "should Go have generics whose design is based on C++ templates and/or Java generics" then the only sane answer is a resounding no.

Re:Toward Go 2 by lngnmn on Friday July 14, 2017 @02:53AM (#14768049)
The classic Wizards lecture on generic '+ is good enough argument.

The numeric tower of lisps is the canonical use case of what generic functions are good for.

Smalltalk, the second greatest language after Lisp, is also good example.

Re:Toward Go 2 by pjmlp on Thursday July 13, 2017 @02:21PM (#14763796)
You forgot CLU in 1975. :)
Re:Toward Go 2 by TheDong on Thursday July 13, 2017 @01:30PM (#14763271)
The fact that go1.9 will include a "sync.Map" type which should be generic, but can't be due to the language's limitations should already answer that.

See also all of the "container" portion of the stdlib: https://golang.org/pkg/container/

All of those should be generic, but aren't.

Clearly there's already sufficient demand for generic collections just based on the stdlib and the fact sync.Map was seen as needed.

Re:Toward Go 2 by jerf on Thursday July 13, 2017 @03:35PM (#14764448)
"All of those should be generic, but aren't."

I think even more damning then "these should be generic" is that there should be more of them. The real problem is the lack of generics inhibits the introduction of more data structures because they are hard to use.

It is true that arrays and maps/hashes take you a long way, but there's a lot of other useful data structures in the world. And despite the fact they may look easy at first, data structure code tends to be notoriously difficult to write both correctly and with high performance.

Re:Toward Go 2 by xienze on Thursday July 13, 2017 @02:05PM (#14763637)
> All of those should be generic, but aren't.

They aren't because the prevailing attitude is "what do you need generics for? Just do a cast!"

The issue is the Go developers are unwilling to consider generics until someone can come up with a problem that absolutely, positively cannot be solved without generics. And of course there isn't one.

Re:Toward Go 2 by bpicolo on Thursday July 13, 2017 @02:21PM (#14763798)
I mean, having to cast after every single call to heap is a problem.

Go is turing complete already, so all problems are already able to be solved. :)

Re:Toward Go 2 by jadbox on Thursday July 13, 2017 @02:07PM (#14763661)
Agree- having map, filter, reduce with strong type guarantees will be a huge boon. Imagine being able to map over a collection and the code hints will understand the new output types in the chain. This is something you cannot have when your higher order ops are all typed to Interface {}.
Re:Toward Go 2 by djur on Thursday July 13, 2017 @05:22PM (#14765368)
Unfortunately, Go is a language whose original creator is of the opinion that map/filter/reduce are just ways to make your program "fit on one line"[1], and that you should just use a for loop[2].

[1]: https://groups.google.com/forum/#!topic/golang-nuts/RKymTuSC... [2]: https://github.com/robpike/filter

Re:Toward Go 2 by piinbinary on Thursday July 13, 2017 @01:55PM (#14763519)
I'm not sure why this is being downvoted. These are perfect examples of where generics would make a genuine improvement.
Re:Toward Go 2 by maxekman on Thursday July 13, 2017 @03:16PM (#14764281)
The sync.Map case for generics is a perfect example. Thanks for bringing it up.
Re:Toward Go 2 by zerr on Thursday July 13, 2017 @01:36PM (#14763327)
They should look up the usage of empty interfaces [in the wild or in-house].
Re:Toward Go 2 by munificent on Thursday July 13, 2017 @01:45PM (#14763414)
This is a great point. Other analysis one could do:

1. Look at uses of cast operators in a codebase. How many of those would be eliminated by making the surrounding operation generic?

2. Go through the language spec and see how many features could be moved out of the language and into the core library if generics were supported.

Re:Toward Go 2 by kccqzy on Thursday July 13, 2017 @05:39PM (#14765499)
Re:Toward Go 2 by zyxzkz on Friday July 14, 2017 @01:47AM (#14767797)
That's an awesome trick, using angle brackets that aren't angle brackets!
Re:Toward Go 2 by kccqzy on Thursday July 13, 2017 @07:41PM (#14766238)
It really reminds me of early C macros where people use the ## operator to synthesize monomorphized versions.
Re:Toward Go 2 by fanf2 on Friday July 14, 2017 @12:31PM (#14771087)
The ## operator is an ANSI C feature, so not really "early". In pre-ANSI preprocessors you had to abuse the lexer to paste tokens, e.g. by relying on // being deleted - nowadays comments are replaced by space.
Re:Toward Go 2 by coldtea on Thursday July 13, 2017 @02:05PM (#14763634)
>This is a much more nuanced position than the Go team has expressed in the past, which amounted to "fuck generics," but it puts the onus on the community to come up with a set of scenarios where generics could solve significant issues.

It seems to me to be the same "Generics is some foreign concept we just heard of, and we're not sure how to implement them in Go yet, but we'll consider it if we chance upon some magical optimal way" that has been the official party line of Go since forever...

Even the "we are asking you for proposals" part has been there since a decade or so...

Re:Toward Go 2 by xienze on Thursday July 13, 2017 @01:50PM (#14763476)
> This is a much more nuanced position than the Go team has expressed in the past, which amounted to "fuck generics," but it puts the onus on the community to come up with a set of scenarios where generics could solve significant issues.

Nah, this is pretty much the same answer they've been giving all along, lots of handwaving about how generics are so cutting edge that no one can figure out how to use them effectively yet ("we just can't wrap our heads around this crazy idea!")

In other words, don't count on them in Go 2.

Re:Toward Go 2 by untog on Thursday July 13, 2017 @02:04PM (#14763626)
It strikes me as a pretty odd statement, though. I'll admit that I'm not very familiar with Go, but surely you can look back at the benefits of generics in other languages? Go is hardly so specialised that you can't learn a single lesson from elsewhere.
Re:Toward Go 2 by Touche on Thursday July 13, 2017 @02:09PM (#14763684)
I agree, I didn't find the statement refreshing at all, I found it insulting. You damn well know the use-cases for generics. If you still don't like it; fine, say that explicitly. Don't pussyfoot around it and play the "we just don't know that much about it yet" lie.
Re:Toward Go 2 by callesgg on Thursday July 13, 2017 @01:36PM (#14763324)
Not having generics makes it hard to do proper type safe functions and libraries.

My specific problem when i realized it was an actual problem was when i tried to connect to a sql databse and working with a proper ORM.

Re:Toward Go 2 by weberc2 on Thursday July 13, 2017 @02:48PM (#14764016)
Why does an ORM need generics? I ask because I've built something very like an ORM in Go and I didn't have any problem without generics. ADTs on the other hand...
Re:Toward Go 2 by steveklabnik on Thursday July 13, 2017 @04:13PM (#14764756)
The strongest typed ORM I've ever used is http://diesel.rs/

This code (okay I made the use line up because it's not on the website and I'm lazy, you do need one though):

  use some::stuff::for::the::dsl;
  
  let versions = Version::belonging_to(krate)
      .select(id)
      .order(num.desc())
      .limit(5);
  let downloads = version_downloads
      .filter(date.gt(now - 90.days()))
      .filter(version_id.eq(any(versions)))
      .order(date)
      .load::<Download>(&conn)?;
is completely, statically typed, with zero runtime overhead. Generics + type inference makes sure that everything is valid, and if you screw it up, you get a compiler error (which honestly are not very nice at the moment).

Thanks to generics, all of this checking is computed at compile time. The end resulting code is the equivalent of

  let results = handle.query("SELECT version_downloads.*
    WHERE date > (NOW() - '90 days')
      AND version_id = ANY(
        SELECT id FROM versions
          WHERE crate_id = 1
          ORDER BY num DESC
          LIMIT 5
      )
    ORDER BY date");
but you get a ton of checking at compile time. It can even, on the far end of things, connect to your database and ensure things like "the version_downloads table exists, the versions table exists, it has a crate_id column, it has a num column", etc.

You can absolutely create an ORM _without_ generics, but it cannot give you the same level of guarantees at compile time, with no overhead.

Re:Toward Go 2 by weberc2 on Thursday July 13, 2017 @04:36PM (#14764955)
Ah, I think the bit where generics is useful is in making sure the value types are consistent (i.e., that you're not building a query that subtracts an int from a string or compares a date to a bool). This still doesn't guarantee that the types will match with the database columns, but it is a step up from the non-generic alternative.
Re:Toward Go 2 by steveklabnik on Thursday July 13, 2017 @04:40PM (#14764984)
It can check that they match with the columns, yeah.

It also heavily relies on generic types to ensure that everything is well-formed, and to provide zero overhead.

Re:Toward Go 2 by weberc2 on Thursday July 13, 2017 @06:15PM (#14765786)
How does the compiler know the types of the database columns? That information has to come from somewhere. Also, type checking is negligible from a performance perspective, so I the "zero overhead" is of minimal interest.
Re:Toward Go 2 by steveklabnik on Thursday July 13, 2017 @07:46PM (#14766279)
> How does the compiler know the types of the database columns?

There's two variants on a single way: basically, a "schema.rs" file contains your schema. You can write it out, and (with the help of migrations) it will update it when you create a new migration, or, you can have it literally connect to the DB at compile time and introspect the schema.

> Also, type checking is negligible from a performance perspective, so I the "zero overhead" is of minimal interest.

Ah, but it's not "the type checking is fast", it's the "diesel can generate hyper-optimized outputs that don't do runtime checks". Like, as an interesting example, Diesel can (well, will be, this has been designed but not implemented yet) actually be _faster_ than a literal SQL statement. Why? The SQL literal is in a string. That means, at runtime, your DB library has to parse the string, check that it's correct, convert it to the databases' wire format, and then ship it off. Thanks to strong generics, since the statements are checked at compile time, none of those steps need to be done at runtime; the compiler can pre-compile that DSL into postgres' wire format directly.

The reason this hasn't actually been implemented yet is that it's admittedly a tiny part of the overall time, and the Diesel maintainers have more pressing work to do. I use it as an example because it's an easier one to understand than some of the other shenanigans that Diesel does internally. It couldn't remove this kind of run-time overhead without generics.

Re:Toward Go 2 by weberc2 on Friday July 14, 2017 @09:05AM (#14769457)
This is all very neat, but I think Go could do all of this too, except that "query compile time" would happen on application init or on the first query or some such. Still, very cool and good work to the diesel team!
Re:Toward Go 2 by kuschku on Friday July 14, 2017 @11:03AM (#14770290)
The whole point of an ideal type system is that if code compiles, it is provably correct and won’t have bugs.

Few typesystems come close to that (Coq is one of the few languages where the system might be advanced enough), but generally you want to completely remove entire classes of errors.

Re:Toward Go 2 by weberc2 on Saturday July 15, 2017 @10:00AM (#14776632)
I don't disagree, but I also don't see how our comments relate... Are you sure you meant to reply to me?
Re:Toward Go 2 by kuschku on Saturday July 15, 2017 @11:52AM (#14777258)
Yes, because Go couldn’t do all that on compile, which is the entire issue. It can’t prove the type safety of your SQL query at compile time, or the type safety of your generics usage.
Re:Toward Go 2 by steveklabnik on Friday July 14, 2017 @09:14AM (#14769506)
Sure, and you get runtime errors instead of compile time errors. That's the point.
Re:Toward Go 2 by weberc2 on Saturday July 15, 2017 @10:02AM (#14776646)
I understand; I wasn't comparing the languages, only making an observation.
Re:Toward Go 2 by Keats on Thursday July 13, 2017 @07:50PM (#14766304)
There is a macro (http://docs.diesel.rs/diesel/macro.infer_schema.html) that connects to the database and builds up structs for the table in the database it's connecting to.
Re:Toward Go 2 by weberc2 on Friday July 14, 2017 @09:07AM (#14769467)
Very cool, but that's not "because of generics" then. Not to denigrate the feat.
Re:Toward Go 2 by hinkley on Thursday July 13, 2017 @06:02PM (#14765692)
I keep meaning to pick up Rust, still looking for some entry point that's interesting enough to get me off my butt.

How (well) does diesel deal with migrations? I've seen other ORMs fall down the stairs trying to deal with schema modification over time.

Re:Toward Go 2 by weberc2 on Thursday July 13, 2017 @06:18PM (#14765810)
I think you meant to respond to Steve. I'm not a Rust guru (I keep trying it, but I don't have any applications for which it's reasonable to trade development time for extreme performance). I definitely don't know anything about diesel.
Re:Toward Go 2 by leshow on Friday July 14, 2017 @11:55AM (#14770761)
You have a migrations dir that contains the changes to schemas over time, so you can always get your table in to the state it needs to be in.
Re:Toward Go 2 by hinkley on Thursday July 13, 2017 @07:05PM (#14766053)
I keep meaning to pick up Rust, still looking for some entry point that's interesting enough to get me off my butt.

How (well) does diesel deal with migrations? I've seen other ORMs fall down the stairs trying to deal with schema modification over time.

Re:Toward Go 2 by steveklabnik on Thursday July 13, 2017 @07:37PM (#14766215)
You write raw SQL files that do exactly what you want them to do: https://github.com/rust-lang-nursery/thanks/tree/master/migr... each of these has an up.sql and a down.sql

"diesel migraiton run" will run all pending migrations, there's revert/redo as well. "diesel migration generate" can generate these files and directories for you; it doesn't yet (that I know of) have helpers to write the SQL though (like Rails does for its migrations).

On deploy, it runs the migrations first https://github.com/rust-lang-nursery/thanks/blob/master/buil...

I believe there are some interesting improvements coming down the line in the future, but for now, it works pretty well.

Re:Toward Go 2 by callesgg on Thursday July 13, 2017 @03:02PM (#14764156)
In my specific case it was the fact that i could not have one insert function or one update function.

I would need one for each and every struct(table).

These days there is a tool that can generate all those struct methods: https://github.com/vattle/sqlboiler

So from the ORM perspective we (as the community) have worked around it.

Re:Toward Go 2 by staofbur on Thursday July 13, 2017 @03:44PM (#14764508)
This is incidentally where .Net was around the 1.1 release (2003ish) We had code generation frameworks kicking out swathes of boiler plate.

Now Repository<T> and for us around 200,000 lines of code are gone and only one narrow set of tests to execute.

Re:Toward Go 2 by weberc2 on Thursday July 13, 2017 @04:23PM (#14764835)
I guess I don't see how generics would help you reduce the number of insert/update functions. The basic problem of an ORM is to map struct fields to columns; I don't see how generics would help you here. Can you write the generic pseudocode you want to write?
Re:Toward Go 2 by rmrfrmrf on Thursday July 13, 2017 @11:17PM (#14767166)
I would guess something like:

    class Collection<T implements Entity> {
        void insert(T entity) {
            String vals = entity.props.map(escapeSql).join(",");
            String qs = entity.props.map(x => "?").join(",");
            PreparedStatement p = db.prepare("insert into %s (%s) values (%s);", this.tableName, qs, vals);
            db.submit(p);
        }
    }
Re:Toward Go 2 by weberc2 on Friday July 14, 2017 @09:00AM (#14769427)
Go supports that today. Slice is a generic collection. Map will need to become for loops, but that's minor.
Re:Toward Go 2 by slantedview on Thursday July 13, 2017 @04:01PM (#14764662)
The idea that we don't need generics because we can generate code is kind of ridiculous, and certainly doesn't pass the simplicity smell test.
Re:Toward Go 2 by weberc2 on Thursday July 13, 2017 @04:25PM (#14764847)
He wasn't making that argument...
Re:Toward Go 2 by slantedview on Thursday July 13, 2017 @09:54PM (#14766843)
Neither did I say he was. He was linking to a library that works around the lack of generics by generating code.
Re:Toward Go 2 by slantedview on Thursday July 13, 2017 @03:34PM (#14764443)
The idea of needing to come up with use cases for generics is baffling. The existence of generics in numerous other languages already support of plethora of use cases. I really don't get that statement at all.
Re:Toward Go 2 by 43224gg252 on Thursday July 13, 2017 @05:32PM (#14765441)
Then why don't you come up with a legitimate use case?
Re:Toward Go 2 by slantedview on Thursday July 13, 2017 @09:59PM (#14766858)
Because generics have been around for decades, and anyone who can't be bothered to look into the use cases for a feature that spans numerous languages over that time period doesn't deserve the time it takes someone else to spoon feed this information to them. This goes for the author of the article as well.
Re:Toward Go 2 by treehau5 on Thursday July 13, 2017 @07:53PM (#14766322)
I think this is a fair question. We have a lot of pseudo-intellectuals here that think 90% of their job isn't writing business functions. Not having generics in Go has not hindered me at all in performing the objectives of my business. Everyone wants generics, no one knows why. When I had generics in my previous two roles where I used Java and C# respectively, I can count on two fingers the number of times I needed them, and once was because a library forced me to.
Re:Toward Go 2 by slantedview on Thursday July 13, 2017 @10:08PM (#14766892)
> Everyone wants generics, no one knows why

This is such a troll'ish statement, but I'll respond anyways because maybe you actually are just that uninformed. Without generics any number of libraries that utilize generic function blocks - Func [1] in C#, Callable [2] in Java, etc., and do things like return the function's type parameter as a method result, would not be possible. This is exceedingly common, at least in libraries. If you want to know how common, let me refer you to my friend http://google.com.

Just because something isn't valuable to you, personally, doesn't mean it's not valuable. As in all aspects of life, not everyone is you.

1. https://msdn.microsoft.com/en-us/library/bb549151(v=vs.110)....

2. https://docs.oracle.com/javase/7/docs/api/java/util/concurre...

Re:Toward Go 2 by herewego- on Friday July 14, 2017 @01:40AM (#14767762)
I am another developer who has never really suffered as a result of a lack of generics. Personally I really like how dead easy golang code is to read and understand. God forbid golang become a language where untold amounts of logic can be packed into a single line of code, resulting in near mathematical levels of complexity which always require more time to understand. Like most complex concepts in life, I suspect the number of developers who can effectively use these tools is rather small compared to the number of people who think they "need" them. But hey, I'm a vim programmer who doesn't like to have to rely on a bloated IDE to be able to deal with the code that I am interacting with so I might be a minority.
Re:Toward Go 2 by solomatov on Thursday July 13, 2017 @01:48PM (#14763448)
I would start using Go in my projects if it introduces generics. It's a show stopper for me.
Re:Toward Go 2 by Spiritus on Thursday July 13, 2017 @02:01PM (#14763593)
The question is _why_ do you need generics, for what use case(s), etc? Saying “I need generics otherwise I won’t use Go” is exactly the type of feedback they don’t want.

It seems like you’d have valuable feedback given that it’s a “showstopper” for you.

Re:Toward Go 2 by littlestymaar on Thursday July 13, 2017 @03:33PM (#14764432)
Not the GP, but you can think about generics as a better kind of interfaces :

- performance wise: no dynamic dispatch, means no virtual function call, means faster code.

- type safety: let say I want a data structure that can store anything but everything in it must be the same type. You just can't do that with Go's current type system without introspection (which is cumbersome and really slow).

Generics already exists in Go : maps, slices and channels and generic, and it was mandatory for performance reason. The problem of not having generics is that the community can't build its own implementation of useful data structures : for instance, until the last release Go lacked a thread-safe map. That's fine, let's use a library for that … Nope, can't implement that because, “no generics”.

Generics are rarely useful in your own code, but they allow people to create good abstractions in their libraries. Without generics, the ecosystem growth is limited.

Re:Toward Go 2 by brandonbloom on Thursday July 13, 2017 @04:44PM (#14765038)
> you can think about generics as a better kind of interfaces

No, you can't, because generics don't provide the key feature of interfaces: run-time dynamism.

You could make a case that static polymorphism and dynamic polymorphism could be accomplished by a single mechanism, as traits do in Rust, but you can't say generics are "better" than interfaces, since they solve a different set of problems, with different implementation strategies, despite related theoretical foundations.

> The problem of not having generics is that the community can't build its own implementation of useful data structures

This is not true either, although it is true that it is harder to do this sort of thing in Go, the result may in fact not be as fast as you can achieve with monomorphisation, and you may have to write more code by hand.

The "trick" is the Go model is to provide an interface (which yes, potentially unnecessarily uses a dynamic mechanism) to implement indirect operations. For example the Swap function of https://golang.org/pkg/sort/#Interface enables https://golang.org/pkg/container/heap/#Interface - which is a reusable data structure. Compiler-level static-generics for slices and arrays, combined with indirecting through array indexes, enables you to avoid boxing when instantiating the heap interface. The data structure can be instantiated with an interface once, so there is no dynamic lookup for heap operations, but there is still a double indirect call.

Yes, this is less convenient than proper generics, but this doesn't mean you can't do these things.

Furthermore, I've never actually needed to do this outside of sorting (which is, absolutely, is annoying) in large projects. Almost every time I need a specialized data structure, I usually need it for performance reasons, and so hand-specializing for my needs tends to be worthwhile anyway.

> Generics are rarely useful in your own code, but they allow people to create good abstractions in their libraries.

I'd like to see something like templates or generics for Go, but I definitely don't want Java-style "fake" generics without code specialization. Furthermore, I found that the vast majority of generics-heavy libraries back in my C# days were more trouble than they are worth, despite meaningful opportunities for better performance with value types. Copy/paste almost always resulted in a better outcome.

Re:Toward Go 2 by shaan7 on Friday July 14, 2017 @05:53AM (#14768670)
> Yes, this is less convenient than proper generics, but this doesn't mean you can't do these things.

Yep, assembly is less convenient than Go, but it doesn't mean you can't write programs using assembly.

Re:Toward Go 2 by abiox on Thursday July 13, 2017 @02:52PM (#14764051)
> for what use case(s)

i almost feel this is like asking bjarne what use cases there are for 'classes' in c-with-classes. it's a structural language change that (depending on implementation details) can have sweeping ramifications on how one writes code.

type parameterization allows for the expression of algorithms, idioms and patterns wholly or partially separate from concrete type details. i'm sure others can better sell the topic though.

Re:Toward Go 2 by Touche on Thursday July 13, 2017 @02:12PM (#14763706)
Do you not see how this is an insulting question? You know very well the use cases for generics. You do not need users to present new ones. You can literally Google "generics use cases" and get hundreds of thousands of results that directly answer that question.
Re:Toward Go 2 by Spiritus on Thursday July 13, 2017 @02:20PM (#14763784)
Did you even read the blog post? Such feedback was explicitly asked for.
Re:Toward Go 2 by AaronFriel on Thursday July 13, 2017 @02:33PM (#14763893)
I think the problem everyone has swallowing that ask is that the value of generics is that it's so widely taught, with so many use cases, and so much literature (academic and otherwise) that the suggestion that they need use cases is laughable.

What use cases do they need other than the extremely large body of public knowledge on the matter, and why would one more example change anyone's mind?

To me this represents the epitome of the insular and outwardly hostile attitude that the Go team has toward good ideas elsewhere in the CS world. Would it really make a difference to the team if I or anyone else were to hunt down specific examples and present them with problems solved with generics and stronger type systems?

I doubt it.

Re:Toward Go 2 by weberc2 on Thursday July 13, 2017 @02:51PM (#14764037)
Off topic, but any chance UNI is your alma mater? I think we may have been there at the same time, judging by your name and some of your comments.
Re:Toward Go 2 by AaronFriel on Friday July 14, 2017 @11:25AM (#14770502)
Aye.
Re:Toward Go 2 by lomnakkus on Thursday July 13, 2017 @02:36PM (#14763910)
Asking for use cases when the use cases and benefits are already well-known seems pretty disingenuous to me. (Of both you and the blog post.)

... but, hey, just to indulge you, a few off the top of my head:

- Generic containers in libraries (aka not built-in)

- Parametricity to restrict user-supplied implementations of interfaces; not quite as valuable in a language with casts, etc., but still reasonably valuable.

- To give a sound account for the currently-magic built-in types.

That should be enough, frankly, but I'm sure I could come up with more if I were to spend 5 more minutes on it...

Can we stop pretending that they don't know of any compelling use cases now?

Re:Toward Go 2 by randomdata on Thursday July 13, 2017 @10:26PM (#14766969)
There are many different ways to provide generics (templates, typeclasses, etc.), each with their own pros and cons. It's not simply a matter of "add generics". And what solution they do come up with is going to bring the given cons those who would be better served by a different generics solution.

The Go team have been long criticized for choosing the option that fits Google, but not the rest of the world. This seems like their attempt to think about what others are doing with the language, beyond their insular experience, so they don't end up with something that fits Google perfectly but falls apart everywhere else.

If they don't take the time to learn how people intend to use generics in Go, the best solution for Google, and Google alone, is what we will get.

Re:Toward Go 2 by lomnakkus on Friday July 14, 2017 @01:09AM (#14767627)
Then they should ask for that instead.

It's not unreasonable to ask "how do we implement this in the best way?", but I'll note a) that's not what was asked, and b) I have a hard time believing that code at Google is so incredibly "special" that they need a special kind of generics. Also, if Google is such a unique snowflake why not ask the Google people directly rather than the "Go community"?

Re:Toward Go 2 by randomdata on Friday July 14, 2017 @06:02AM (#14768695)
> "how do we implement this in the best way?"

They asked for use cases from a wide range of people to ensure they implement it in the best way. Subtly different, but essentially the same request.

> I have a hard time believing that code at Google is so incredibly "special" that they need a special kind of generics.

I didn't say they need special generics. I said the approach that works best at Google may not be the best approach for the population at large. If Google is best served by C++-style generics, while the community as a whole would be better served by Haskell-style generics, why just jump in and do it the C++ way before seeing how others might want to use it?

> Also, if Google is such a unique snowflake why not ask the Google people directly rather than the "Go community"?

Because they are trying to avoid the mistake of using one datapoint like Go has struggled with in the past? They know what works in Google, but that doesn't necessarily work for everyone else. See: Package dependencies, among many.

Re:Toward Go 2 by lomnakkus on Friday July 14, 2017 @11:59AM (#14770808)
> They asked for use cases from a wide range of people to ensure they implement it in the best way. Subtly different, but essentially the same request.

Phrasing is important, and obviously (from the reactions of me and others in the thread) the phrasing was way off and perceived as condescending and lazy.

> I didn't say they need special generics. I said the approach that works best at Google may not be the best approach for the population at large. If Google is best served by C++-style generics, while the community as a whole would be better served by Haskell-style generics, why just jump in and do it the C++ way before seeing how others might want to use it?

OK, so you said they don't need a special generics, but then say that they do. I must not be understanding what you're trying to say. (If this is about choosing trade-offs, then see the other poster who talked about trade-offs. Executive summary: Not doing generics is also a trade-off.)

Also: ASK GOOGLE.

> Because they are trying to avoid the mistake of using one datapoint like Go has struggled with in the past? They know what works in Google, but that doesn't necessarily work for everyone else. See: Package dependencies, among many.

You can't have it both ways. Either Google is important enough to it in a way that works for them, or the community is more important and they get to choose.

Anyway, I'm done with this conversation. I think we may be seeing this from viewpoints that are so different that it's pointless to continue.

I'm not sure how to argue constructively with someone who says "I'm not saying X, but..." and then immediately states a rephrasing of "X". I'm sure that's not what you think you are doing, but that's the way I'm seeing it, FWIW.

Re:Toward Go 2 by randomdata on Friday July 14, 2017 @01:30PM (#14771534)
> Phrasing is important, and obviously (from the reactions of me and others in the thread) the phrasing was way off and perceived as condescending and lazy.

Maybe, but I don't know that we should be attacking someone's poor communication ability. I'm sure I've misunderstood at least one of your points too. Let's just focus on what was actually asked for: Use-case examples.

> OK, so you said they don't need a special generics, but then say that they do.

There isn't an all encompassing 'generics'. Generics is a broad category of different ways to achieve reusable statements across varying types, in a type-safe manner. To try and draw an analogy, it is kind of like functional and imperative programming. Both achieve the function of providing a way to write programs, but the paradigms differ greatly. Each with their own pros and cons.

If imperative programming is the best choice for Google, that doesn't mean the community wouldn't be better served by functional programming, so to speak. And when it comes to generics, there are quite a few different paradigms that can be used, and not easily mixed-and-matched. They are asking for use-cases to determine which generics paradigm fits not only the needs at Google, but the needs everywhere.

> Also: ASK GOOGLE.

The Go team is Google. They have asked Google. Now they are asking everyone else. I'm not sure how to make this any more clear.

> Either Google is important enough to it in a way that works for them, or the community is more important and they get to choose.

In the past Google was seen as the most important, and they have been widely criticized for it. This is them moving in a direction that favours the community. And they are still being criticized for it... Funny how that works.

Re:Toward Go 2 by lomnakkus on Friday July 14, 2017 @02:12PM (#14771944)
> There isn't an all encompassing 'generics'. Generics is a broad category of different ways to achieve reusable statements across varying types, in a type-safe manner. To try and draw an analogy, it is kind of like functional and imperative programming. Both achieve the function of providing a way to write programs, but the paradigms differ greatly. Each with their own pros and cons.

Yes, thank you. Everybody in this thread already knows that. PICK ONE.

(EDIT: I should also add: Since Go is structually typed and has mutable variables, that should be a good indication of what to do and what not to do. See e.g. Java arrays, variance and covarince.)

> If imperative programming is the best choice for Google, that doesn't mean the community wouldn't be better served by functional programming, so to speak. And when it comes to generics, there are quite a few different paradigms that can be used, and not easily mixed-and-matched. They are asking for use-cases to determine which generics paradigm fits not only the needs at Google, but the needs everywhere.

And now you're trying to bring imperative vs. functional into this?

I think IHBT... and this really is my last comment in this thread. Have a good $WHATEVER.

Re:Toward Go 2 by randomdata on Friday July 14, 2017 @02:23PM (#14772072)
> Yes, thank you. Everybody in this thread already knows that. PICK ONE.

They are picking one, based on the use-cases that will be given to them in the near future. I don't understand what your point is here.

> Since Go is structually typed and has mutable variables, that should be a good indication of what to do and what not to do.

That may be true, but the worst case scenario is that they learn nothing from the examples they get. You don't have to provide any if you feel it is a useless endeavour. If it gives them comfort, so be it.

> And now you're trying to bring imperative vs. functional into this?

It wasn't clear if you understood what I meant by there being different ways to provide generics. I struggled to write it as eloquently as I had hoped and the analogy was meant to bridge what gaps may have existed.

It's almost like communication can be difficult. Where have I see that before? Hmm...

Re:Toward Go 2 by lomnakkus on Friday July 14, 2017 @03:02PM (#14772328)
(Just to end it. I was intrigued.)

> It's almost like communication can be difficult.

We can agree about that! :)

> Where have I see that before? Hmm...

Not sure what you mean (ironically?).

Have a good night :).

Re:Toward Go 2 by Spiritus on Thursday July 13, 2017 @02:45PM (#14763983)
I was merely suggesting to indulge the author, especially now that generics might actually happen.
Re:Toward Go 2 by cyphar on Thursday July 13, 2017 @05:35PM (#14765468)
The problem is that the community did indulge the author and the other Go maintainers 5 years ago and their was an apparent refusal to see lack-of-generics as an issue, almost as though Turing-completeness was sufficient justification to not include them.

"Find us examples and show us so we can ponder this further" is incredibly condescending after we did that 5 years ago and they decided to stall (or to use the author's term, "wait") on the issue. Honestly I think it might be too late for generics to be added, because the large body of existing interfaces aren't generic and likely would have a very high transition cost.

Re:Toward Go 2 by lomnakkus on Saturday July 22, 2017 @07:39PM (#14830064)
(A bit late to your comment, but I found it valuable:)

It's actually a classic bulshitting tactic by people who have no actual argument. Effectively, it's "well, we'll defer a choice until we can PROVE that decision X is PERFECT in EVERY way."

That's not to say: IF there's a real, quantifiable doubt, then by all means, continue to discuss (but preferably set time limits), but to do that you MUST set out precisely what the problems are, what potential solutions could (and couldn't) be, etc. etc. Not just vague "this feels wrong" objections.

Re:Toward Go 2 by coldtea on Thursday July 13, 2017 @02:16PM (#14763748)
Because I like both reusable implementations of algorithms across compatible types AND type safety.

It's not rocket science.

And because it's 2017.

Re:Toward Go 2 by xenadu02 on Thursday July 13, 2017 @03:36PM (#14764456)
Create an ordered set or bloom filter type for Go and let us know how you make out.
Re:Toward Go 2 by slantedview on Thursday July 13, 2017 @03:37PM (#14764468)
> The question is _why_ do you need generics

Why do we need anything beyond assembler?

Re:Toward Go 2 by GenericsMotors on Friday July 14, 2017 @07:02AM (#14768881)
Try implementing LINQ in Go, while using no runtime type assertions at all and maintaining compile-time type safety (ie: no interface{}).

Then you'll wish you had generics. :)

Re:Toward Go 2 by the_mitsuhiko on Thursday July 13, 2017 @02:16PM (#14763750)
The benefits of generics are well understood.
Re:Toward Go 2 by Spiritus on Thursday July 13, 2017 @02:23PM (#14763821)
So why is he requesting feedback on the matter?
Re:Toward Go 2 by AaronFriel on Thursday July 13, 2017 @02:34PM (#14763896)
Bad faith.
Re:Toward Go 2 by ryeguy on Thursday July 13, 2017 @09:31PM (#14766765)
That's what we're all trying to figure out.
Re:Toward Go 2 by solomatov on Thursday July 13, 2017 @09:04PM (#14766678)
Collections, for example. Functional reactive programming. Things like I write in Java now: https://github.com/JetBrains/jetpad-mapper

I remember when Java started to have generics in 1.5. It was very hard to go back to 1.4 after having used that. I feel that I just can't program without them any longer.

Re:Toward Go 2 by nemo1618 on Thursday July 13, 2017 @02:27PM (#14763856)
You might be interested in my side project: https://github.com/lukechampine/ply

It's a small superset of Go that allows you to call map/filter/reduce methods on any slice. It's not true generics (you can't define your own generic functions or types) but it covers the most common use case for me: declarative data processing.

Re:Toward Go 2 by Shorel on Thursday July 13, 2017 @03:05PM (#14764192)
What do you use?
Re:Toward Go 2 by treehau5 on Thursday July 13, 2017 @03:22PM (#14764326)
Conversely, I would stop using Go in my projects if it introduces generics.

If Go wants to be more sophisticated, there are other sophisticated languages I can use out there like Haskell, Rust, F#, Scala, etc. The problem I have learned in my career is "sophistication" usually gets in the way of getting things done because now you have all these clever developers full of hubris creating these novel implementations that nobody else in the world understands, and your project fails but hey -- at least you have a dope, terse, generic implementation -- totally rad.

Re:Toward Go 2 by Daishiman on Thursday July 13, 2017 @04:11PM (#14764741)
So you'd rather take a half-dozen, half-assed implementations of templates, macros, flaky cast-to-interface things and a bunch of incompatible weirdness rathern than a singular, reasonably effective pattern that's been proven successful over literally hundreds of programming languages?
Re:Toward Go 2 by slantedview on Thursday July 13, 2017 @03:37PM (#14764464)
> Conversely, I would stop using Go in my projects if it introduces generics

Depending how they're implemented, you might not have to use them (even via libraries). Not using the language altogether is a bit dramatic.

Re:Toward Go 2 by erikpukinskis on Thursday July 13, 2017 @05:46PM (#14765559)
That's never really true, because using a language means using other people's libraries, and using libraries means debugging and extending them, so you eventually end up needing to work with anything the language can serve up.

This is my beef with JavaScriot these days... They introduced a slew of new, in my opinion insane, control structures, and while I can avoid them in my code, they are still slowly polluting my dependencies, and adding obscure runtime requirements for my projects.

Re:Toward Go 2 by HarkMamilton on Thursday July 13, 2017 @01:40PM (#14763370)
I think this is too little, too late. Anyone who saw an advantage to using generic programming is already using something else. They've already invested resources in something besides Go; why spend the effort to switch back for what will, at best, probably be very mediocre support for parametricity compared to whatever they're already using?
Re:Toward Go 2 by cat199 on Thursday July 13, 2017 @01:51PM (#14763489)
This presumes that:

a) generic programming is a new thing

b) any of those people you mention aren't using go for some things and other things where this feature is desired

c) that the feature will 'at best' be at level X

d) that level X won't be enough to satisfy some use cases

and a whole host of other things, not least of which the fact that go itself was invented to suit some purpose after other languages existed, and has been successful for many users

Re:Toward Go 2 by matthewowen on Thursday July 13, 2017 @02:47PM (#14764004)
Most of the projects which will use Go have not begun yet. Adding support means people may use Go for those future projects.
Re:Toward Go 2 by resf on Thursday July 13, 2017 @04:03PM (#14764676)
The opposite side of that coin is that other programming languages do already exist.

Any new language is already playing catch-up to reach the state of the art. Go is 10 years old and in those 10 years has made astonishingly little progress at implementing basic features such as error handling, because the designers cannot escape their bubble.

The most sensible thing to do is to kill Go, not to improve it. The root problem is not the lack of this or that feature, but the bizarre beliefs of the people running the project.

Re:Toward Go 2 by johnwilkesbooth on Thursday July 13, 2017 @04:57PM (#14765160)
> The most sensible thing to do is to kill Go, not to improve it.

Care to expand this? It's pretty clear that you don't find Go suitable for your own use cases, but I've found it to be an extremely productive language, despite the fact that it may have a couple of warts.

Re:Toward Go 2 by tomovo on Thursday July 13, 2017 @01:37PM (#14763345)
Go 2, codename "Hell with generics". Just kidding of course. I am sure some useful form of generics will eventually find its way in.
Re:Toward Go 2 by tomovo on Thursday July 13, 2017 @01:42PM (#14763393)
More importantly though, looking at C++ I think it may be hard to come up with a generics system that doesn't lend itself to abuse and ridiculous mega constructs. I would love to see something that provides power in ways that disallow craziness (Boost Spirit kind) but provide enough power to avoid all the cases that suffer without generics.
Re:Toward Go 2 by twblalock on Thursday July 13, 2017 @02:19PM (#14763778)
The craziness is preferable to passing void* or Object or Interface{} everywhere. At that point, you might as well use a language without strong typing, for all the safety you're going to get. You can end up with just as much craziness with void* and Object and Interface{}.

The Go team needs to stop trying to control what people do with their language. If people come up with crazy implementations, it's their own problem. It's up to the Go community to provide alternatives to prevent those crazy implementations from becoming standardized in Go programming culture. Refusing to implement generics because programmers might abuse them is paternalistic and counterproductive.

Re:Toward Go 2 by tomovo on Thursday July 13, 2017 @03:15PM (#14764273)
"If people come up with crazy implementations, it's their own problem."

Some people are turned away from C++ after seeing random bits of crazy language/template misuse, although when used sanely C++ could've served them nicely for their job.

Same thing is going to happen to Swift very soon.

https://engineering.kitchenstories.io/comfortable-api-reques...

Those function signatures are definitely not... self-documenting, I'd say.

Re:Toward Go 2 by dbaupp on Thursday July 13, 2017 @04:35PM (#14764935)
Those signatures seem complicated to me because there's a pile of arguments and some of them are functions with extra annotations, not because there's generics involved. The equivalent signatures using interface{} (or maybe something more precise) would be likely just as noisy, if not more so.
Re:Toward Go 2 by tumdum_ on Thursday July 13, 2017 @03:31PM (#14764408)
Using interface{} you never get implicit/silent conversion, so Go type system is strong (and static obviously). It just lack parametric polymorphism.
Re:Toward Go 2 by eropple on Thursday July 13, 2017 @01:45PM (#14763421)
Both C# and Java have taken different approaches to constrained generics that are still really useful for about...I dunno, the 90% case (C# has reified generics and so it's more like 95%, but type erasure also has its pluses when you're off-roading around in a framework somewhere). Scala goes a little further and covers, like, the 99% case, and plenty of inadvisable ones too.
Re:Toward Go 2 by int_19h on Thursday July 13, 2017 @02:17PM (#14763760)
C++ doesn't have generics, it has templates, which are effectively a syntax-constrained form of macros. That's why it lends itself to abuse (or creative use, depending on your take on macros).
Re:Toward Go 2 by tomovo on Thursday July 13, 2017 @03:20PM (#14764311)
So C++ generates separate code for each template type and C# and Java do a typecheck at compile time and reuse the same codepath for all types at runtime?
Re:Toward Go 2 by pjmlp on Thursday July 13, 2017 @03:47PM (#14764546)
.NET does a mixture of C++ and Java, meaning generic instatiations for value types get their own version of the code, instatiations for reference types get a shared version.
Re:Toward Go 2 by int_19h on Thursday July 13, 2017 @04:16PM (#14764780)
It's worth noting that in case of C#, it's really an implementation detail. It could just as well share all instantiations by boxing and adding a bunch of runtime checks - the language semantics wouldn't change because of it.

In C++, on the other hand, separate compilation of template for each instantiation is effectively part of language semantics, because it has numerous observable effects.

Re:Toward Go 2 by vram22 on Thursday July 13, 2017 @04:01PM (#14764667)
"2 Hell with generics", or "Go 2 Hell with generics"

/jk 2

Re:Toward Go 2 by pjmlp on Thursday July 13, 2017 @02:18PM (#14763771)
I would already be happy if they supported generics like CLU did in 1975, no need for nothing too fancy.
Re:Toward Go 2 by hota_mazi on Thursday July 13, 2017 @05:20PM (#14765350)
That's a charitable way to look at the comment.

My more cynical reaction is that someone who doesn't understand the benefit of generics or can't even come up with examples where generics are superior to their alternative should not be allowed anywhere near a language design discussion.