News for hackers. Stuff that matters.
Re:Seven years of Go by stcredzero on Thursday November 10, 2016 @02:37PM (#12923497)
I miss generics, not because I would write new generic functions all the time, but because a few key generics provide infrastructure that increases the beauty of programs dramatically.

The problem is this: Have you ever worked in a mature codebase with generics, where they haven't somehow been overused? Please tell me where that is!

Re:Seven years of Go by pcwalton on Thursday November 10, 2016 @03:13PM (#12923846)
I've also worked on codebases that have overused the && operator. Should we remove that in favor of nested if?
Re:Seven years of Go by stcredzero on Thursday November 10, 2016 @04:45PM (#12924704)
Only if the cost-benefit works out, and there isn't a better solution.
Re:Seven years of Go by pcwalton on Thursday November 10, 2016 @04:56PM (#12924812)
And that's clearly the case with generics.
Re:Seven years of Go by stcredzero on Thursday November 10, 2016 @05:00PM (#12924864)
You're seriously saying that generically? All languages should simply have them? Not so sure you should dismiss the context like that.
Re:Seven years of Go by aikah on Saturday November 12, 2016 @10:06AM (#12938137)
> You're seriously saying that generically? All languages should simply have them? Not so sure you should dismiss the context like that.

Point me to a successful statically typed language born after 2005 that doesn't have some form of generics. Go has generics by the way, you just can define your own in user land, which is a stupid limitation.

Re:Seven years of Go by Someone on Thursday November 10, 2016 @03:42PM (#12924136)
Almost any powerful new feature in any language initially gets overused, but that isn't a reason to ban it.

Class hierarchies, for example, got heavily overused before people discovered that composition most of the time is the better option, exceptions got overused before people learnt to only use them in exceptional cases, and dependency injection and XML (one of the first environments with strong support for it) got overused in Java programs.

Generics are going the same way, if they haven't already (JavaScript modules will get there, too, but that seems at least a generation of programmers away)

Also, the only difference I see between generics (with a bit of 'compile-time reflection') and go generate is that the former may be too magical for some, while the latter requires programmers to do more work (writing special comments to use existing functionality, and writing AST manipulation code to write new ones) and that it generates files only because the compiler wants to see them.

Re:Seven years of Go by richard_todd on Thursday November 10, 2016 @03:12PM (#12923837)
Having personally fallen into the trap of overusing C++ templates on a project, I understand the point. However, I did not go on to reject the idea that templates should be in the language.

Backing away from specific suggestions, I think it's healthy to recognize that Go has a boilerplate/DRY problem--not just with error handling!--, and it would be nice to address it in some way. If not with generics, then with something.

Re:Seven years of Go by aikah on Thursday November 10, 2016 @04:32PM (#12924601)
As opposed to codebases that abuse interface {} and reflection ? I'd take the complexity of generics over this.
Re:Seven years of Go by wtetzner on Thursday November 10, 2016 @03:47PM (#12924175)
Overused in what way? Do you have an example of what you mean by that?

I'm having a hard time understanding where using generics would cause problems.

C++ templates, sure, but those are much more powerful than just having parametric polymorphism.

Re:Seven years of Go by stcredzero on Thursday November 10, 2016 @05:04PM (#12924902)
C++ templates, sure

C++ templates! I keep on running into places where I'm debugging, then I find myself in a maze formed by template overuse, then debug around that instead.

just having parametric polymorphism

I think that could be workable in Go. I can imagine how debugging that would be straightforward.

Re:Seven years of Go by runT1ME on Thursday November 10, 2016 @04:41PM (#12924667)
Yes, constantly. I've rarely seen generics overused.
Re:Seven years of Go by stcredzero on Thursday November 10, 2016 @04:58PM (#12924842)
Send me contact info.