News for hackers. Stuff that matters.
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