News for hackers. Stuff that matters.
Re:Generic Methods in Go 1.27 by throwaw12 on Thursday August 20, 2026 @01:08PM (#49377328)
people working actively in "modern" Go codebases with generics, is it becoming like a Java/Spring kind of codebase?

I understand why you might need generics, but I hate how Java ecosystem exploits it so much that, reading code becomes so difficult, because it was inherited from 10 levels of parent classes and in some cases Java Beans get created based on generic types and their parent classes are abstract classes.

Re:Generic Methods in Go 1.27 by throw-the-towel on Thursday August 20, 2026 @01:37PM (#49377710)
I remember my coworkers having managed to write Java in pre-generics Go. The code had functions wrapped in functions wrapped in yet more functions, and interfaces only ever implemented by one type to replace the generics abuse. Life finds a way.
Re:Generic Methods in Go 1.27 by zimpenfish on Thursday August 20, 2026 @02:11PM (#49378123)
Yeah, Go people were always been perfectly capable of creating abominational messes before generics arrived. Once you've looked at an interface referencing an interface referencing an interface referencing an interface which is only ever instantiated by one (1) type, you realise that all hope has been lost and your only recourse is blatant sarcasm, pointed replies on Slack[0] and PRs, and finding the perpetrators after dark with a big sack of flour.

[0] Other corporate messaging systems are available.

Re:Generic Methods in Go 1.27 by pstuart on Friday August 21, 2026 @09:40AM (#49387908)
> Go people were always been perfectly capable of creating abominational messes before generics arrived

A poster child for this is k8s.

Re:Generic Methods in Go 1.27 by yencabulator on Saturday August 22, 2026 @11:25AM (#49400721)
Famously created by Java people, not "Go people".
Re:Generic Methods in Go 1.27 by pstuart on Saturday August 22, 2026 @12:25PM (#49401256)
Yes. It's a textbook case of trying to force your favorite language in rather than embrace the idiomatic use of the language.
Re:Generic Methods in Go 1.27 by bbkane on Thursday August 20, 2026 @01:50PM (#49377859)
Entropy finds a way :)
Re:Generic Methods in Go 1.27 by saturn_vk on Thursday August 20, 2026 @03:58PM (#49379437)
I’ve written generic code once or twice per year. Usage through libraries is higher, though it’s not very visible.
Re:Generic Methods in Go 1.27 by riobard on Thursday August 20, 2026 @01:13PM (#49377397)
> inherited from 10 levels of parent classes

This is not (yet) a thing in Go. Go does not have classes and inheritance. Interface is more like duck-typing.

Re:Generic Methods in Go 1.27 by Zanfa on Thursday August 20, 2026 @01:55PM (#49377926)
But you can do equally horrible inheritance-y things with embedded structs.
Re:Generic Methods in Go 1.27 by saturn_vk on Thursday August 20, 2026 @03:59PM (#49379447)
That’s composition, and it’s not really the same as inheritance
Re:Generic Methods in Go 1.27 by EspressoGPT on Thursday August 20, 2026 @03:49PM (#49379309)
That's right, embedded structs in Go are far less common than inheritance in Java though.
Re:Generic Methods in Go 1.27 by metadat on Thursday August 20, 2026 @02:07PM (#49378081)
Yes, though it's non-idiomatic and in my experience, rare to encounter in the wild for anything you'd actually want to use.
Re:Generic Methods in Go 1.27 by jerf on Thursday August 20, 2026 @02:02PM (#49378031)
"people working actively in "modern" Go codebases with generics, is it becoming like a Java/Spring kind of codebase?"

I have yet to encounter a 3rd party library that uses generics that isn't a data structure library of some sort. The only person I have seen doing crazy things with generics is... me. In my own code, for the most part [1]. In general I don't even see generics that are so much as parameterized by a meaningful interface like "type BlahBlah[R io.Reader]"; generics are so often parameterized by "any" that a casual reader might be forgiven for thinking that that is all a Go generic can do. As is often the case, the most complicated generic type signatures are the one in the standard library and even they aren't really all that bad, it's really just about the "~" operator allowing support for "all types that are either 'string' or something of the form 'type X string'".

I see the occasional person complain about how generics have ruined Go by making them too complicated. I push back on them with basically the previous paragraph. None of them have ever replied to press their point any farther. I interpret this to mean that their experience with the feature is in fact the same. At this point if you're buried in super complicated generics it is almost certainly someone on your own team and you should tell them to stop.

Similarly for iterators, by the way. The way Go did iterators is a bit odd to implement them yourself. Won't deny that. But it does compile down very efficiently, and only matters to the people writing the iterator not the consumer. Anyone who claims it has wrecked the language is invited to explain to me why it is that they are writing so many dozens of iterators all the time first, because as near as I can tell they aren't getting that from 3rd party libraries or the standard library.

[1]: The exception being https://github.com/thejerf/mtmap if you want to see something that I did find a use for, and you may have a use for, but is not something I would suggest using all the time. Very specific use case I had.

Re:Generic Methods in Go 1.27 by zbentley on Thursday August 20, 2026 @05:51PM (#49380751)
I’ve found generics useful at handling database-backed objects at the write boundary. Since the layout of those objects is generally pretty important, having middleware-ish things that handle interface/supertypes but return generic concrete types saves on a lot of reflection and casting.
Re:Generic Methods in Go 1.27 by ad_hockey on Thursday August 20, 2026 @02:56PM (#49378670)
I haven't seen that in the large codebase at work, for what it's worth. The thing that's surprised me about generics in Go is how rarely they're needed in practice. Very nice to have in the right place, but the vast majority of our source files still get along fine with plain old typed maps and slices.
Re:Generic Methods in Go 1.27 by eberkund on Thursday August 20, 2026 @01:51PM (#49377872)
I think Go is more commonly used in modern microservice architectures rather than in older monolithic architectures where the kind of Java code you're describing happens. Might have some impact on the level of complexity that can get out of hand.

In the Go codebases I have worked on, generics were not overused IMHO. It did allow us to get rid of some type specific helper functions and made collection based operations like sorting a lot nicer to work with.

Re:Generic Methods in Go 1.27 by pjmlp on Thursday August 20, 2026 @04:23PM (#49379743)
People like to blame Java for enterprise code, except they forget enterprise has been writing enterprisy code since Fortran, COBOL and Lisp days.

I have found Spring like magic with pre-processor macros, sed and awk, in the glory days of Yourdon Structured Method and enterprisy C code.

Re:Generic Methods in Go 1.27 by masklinn on Friday August 21, 2026 @07:28AM (#49386526)
Having had the displeasure of working with struts, enterprise definitely never needed generics to enterprise.
Re:Generic Methods in Go 1.27 by pjmlp on Friday August 21, 2026 @09:52AM (#49388088)
I guess you missed all the nice xBase, FoxPro, Clipper, COBOL, Smalltalk, C, C++ , 4GL frameworks that predated Struts.

Most of them without any kind of generics.

Re:Generic Methods in Go 1.27 by masklinn on Friday August 21, 2026 @10:56AM (#49389108)
I never used most of these at all, and the rest I never worked with in an enterprisey context, so I can not talk about those confluences from personal experience.
Re:Generic Methods in Go 1.27 by pjmlp on Sunday August 23, 2026 @08:05AM (#49408135)
Proving the point that pretending architecture astronauts appeared spontaneously after 1996 is kind out of place.

Many famous enterprise pattern books were published before 1996, even though many think they contain Java sample code.

Re:Generic Methods in Go 1.27 by nicoburns on Thursday August 20, 2026 @04:35PM (#49379909)
Rust has had generics for 10 years and doesn't have this problem. I think it's more a culture problem in Java than anything (and arguably a historical one).
Re:Generic Methods in Go 1.27 by cryptos on Friday August 21, 2026 @09:33AM (#49387831)
And in the end it might be a culture problem in the contexts Java is used in.
Re:Generic Methods in Go 1.27 by vrosas on Thursday August 20, 2026 @05:49PM (#49380740)
I have been a full-time go developer since 2015 and I have quite literally never written a line of generic go code. I can't even recall seeing any written at any {job} since they've been introduced...
Re:Generic Methods in Go 1.27 by mrkeen on Friday August 21, 2026 @02:30AM (#49384515)
Neither Go nor Java's generics is rich enough for the problems you describe. They give you the means to turn IntList into List<I>, but not into <L>Int or <L><I>.

So I doubt the famous AbstractProxyBeanInterceptors are coming from an overuse of generics.

Re:Generic Methods in Go 1.27 by pjmlp on Friday August 21, 2026 @09:50AM (#49388057)
The irony is that while people bash on Java, Objective-C manages to have even longer names.
Re:Generic Methods in Go 1.27 by dwaite on Friday August 21, 2026 @06:46PM (#49394639)
Java has its own problems with generics, such as the near-lack of runtime representation or the lack of a This/Self type, as well as limited variance, leading to signatures like `public abstract class Enum<E extends Enum<E>>`.

IMHO these all go back to design compromises due to the desire to make generics optional - but now, over two decades later, are Java generics really optional?

The ten levels of parent classes is its own issue with Java - with interfaces and class inheritance being a good half of your mechanisms for abstractions in the code base, with adapters making up the other half.