Live data from Hacker News

Generic interfaces

go.dev

11–20 of 78 posts

Re: Generic interfaces

#11
post #7

If I'm being honest, the magic of Go was lost when generics were introduced. It now feels akin to Java, which I guess was inevitable and for anyone to really take it seriously maybe it needed to get here. But I am not a fan of generics. While that level of abstraction and composability is clever, it also lends itself to more complexity and systems that can be harder to concretely understand. Just an opinion that I kn…

No one is forcing you to use the full scope of language features for every project.

This kind of argument comes up every time a new C# language version rolls out - as if it's a breaking change and now everyone is going to be forced to refactor for it.

The only other way I can read this is in terms of wishing others would use tools in the way you prefer, which is clearly a waste of energy.

Re: Generic interfaces

#13
> At this point, you might feel pretty overwhelmed. This is rather complicated and it seems unreasonable to expect every Go programmer to understand what is going on in this function signature. We also had to introduce yet more names into our API. When people cautioned against adding generics to Go in the first place, this is one of the things they were worried about.

One of the key benefits of Go, at least for me, was not having to think about any of this at all ever.

Whenever I touch generics, I find myself engrossed in the possibility of cleverly implementing something. Hours will pass as I try to solve the fun puzzle of how to do the thing using generics, rather than just solve the problem at hand.

Re: Generic interfaces

#14
I find C++ templates simpler than Go generics. With C++, you can at-least get to a design solution. With Go generics: oops this is not possible, oops that is not possible - all because of strange language limitations.

Go's Generics are a crippled implementation - they don't really deserve the feature title of 'generics'. (Its like saying you support regex, but don't support groups and repeat operators and you can only match them to special types of strings.)

Re: Generic interfaces

#16
post #13

> At this point, you might feel pretty overwhelmed. This is rather complicated and it seems unreasonable to expect every Go programmer to understand what is going on in this function signature. We also had to introduce yet more names into our API. When people cautioned against adding generics to Go in the first place, this is one of the things they were worried about. One of the key benefits of Go, at least for me, w…

It exchanges it for code-generation pain. Which one is worse is on a case-by-case basis.

I imagine that people who prefer code-generation just like the idea of it having a higher skill/investment floor to add it to a project so most projects instinctively avoid it.

While people who prefer generics jump at it even when it is not necessary or doesn't bring a lot of benefits.

But those are human problems, not so much shortcomings of those two techniques themselves.

Re: Generic interfaces

#18

“Maybe generics like in java and C# actually made sense after all.“ Welcome to civilization, golang. Were there ever any language developers with more hybris?

I think of it less as hybris and more of a (failed) experiment. It was deliberately built as a 'stupid' language for fresh undergrads, lacking design experience.

It is a technical solution for a people problem. It is better to guide and to mentor people in designing the right abstractions. What we should learn from this experiment is that this is the wrong approach.

Re: Generic interfaces

#19
post #15

Sort of wild that the Go blog doesn't have Go syntax highlighting...

It makes more sense if you know about Rob Pike:

https://groups.google.com/g/golang-nuts/c/hJHCAaiL0so/m/kG3B...

>Syntax highlighting is juvenile. When I was a child, I was taught arithmetic using colored rods (http://en.wikipedia.org/wiki/Cuisenaire_rods). I grew up and today I use monochromatic numerals.

The language creator really hates it (and most modern editor tooling).

Re: Generic interfaces

#20
post #19
post #15

Sort of wild that the Go blog doesn't have Go syntax highlighting...

It makes more sense if you know about Rob Pike: https://groups.google.com/g/golang-nuts/c/hJHCAaiL0so/m/kG3B... >Syntax highlighting is juvenile. When I was a child, I was taught arithmetic using colored rods ( http://en.wikipedia.org/wiki/Cuisenaire_rods ). I grew up and today I use monochromatic numerals. The language creator really hates it (and most modern editor tooling).

It's definitely weird in this day and age, but in the Go code examples... I don't miss it.

Paraphrasing, but if you need syntax highlighting to comprehend code, maybe your code is too complicated.

Post reply on HN