Live data from Hacker News

Why Generics?

blog.golang.org

71–80 of 261 posts

Re: Why Generics?

#71

I hope this doesn't happen. I love golang because it is simple and easy to read. Both will go away when generic programmer start to write unreadable meta-programming class which "you don't need to understand, just use them". I admire golang devs for being opinionated and stand up for the core lines of their language so far. I see generic as renouncing these principles.

This. If I really need generics I'll use a different language.

This reminds me the discussion about first version of iPhone how so many people were advocating why adding copy&paste functionality was a bad idea.

Re: Why Generics?

#72

I hope this doesn't happen. I love golang because it is simple and easy to read. Both will go away when generic programmer start to write unreadable meta-programming class which "you don't need to understand, just use them". I admire golang devs for being opinionated and stand up for the core lines of their language so far. I see generic as renouncing these principles.

This. If I really need generics I'll use a different language.

Must every popular language evolve into C++ or Common Lisp?

Re: Why Generics?

#73

Earlier quoted context omitted.

That's because you write a particular kind of program. Notice that there are no good ORMs or numerical libraries. Both of these are use cases for generics. Of course it doesn't help that the go community is convinced that ORMs are evil (which is just posthoc rationalization for being unable to write one).

“I can see the value so those that can’t are inferior.” You basically just post hoc rationalized their indifference for ORMs by making them sound incompetent As if there are no other arguments for avoiding them that perhaps seem valuable to people that are not you? It sounds reasonable to me you conjured the hot take, acknowledged it was post hoc rationalization on your part, but posted anyway, projecting your capaci…

The point wasn't that Go programmers are too incompetent to implement an ORM, it's that they are actually unable to given the limitations of the language.

Re: Why Generics?

#74
Maybe this is unfair, but it’d be great if the Go devs could just say “generics will work similarly to [C# / Java / Swift / D / whatever], except that we’ll address [problems] with [adjustments]”.

Rather than going through this whole rigmarole of resisting adding generics too early because all existing implementations are bad, then slowly reinventing the wheel from scratch, then finally ending up with something pretty similar to one of those other languages anyway.

It’s OK not to make something completely new and different. It’d be useful to explicitly say which language(s) you’re borrowing from because you can then more clearly call out the differences and explain the reasons for them.

Re: Why Generics?

#75
post #70

Go has generics. What it actually lacks is user-defined generics. Which shows the absurdity of the situation. The fact that it has generics demonstrates that generics are a useful and important feature. And yet they think their provided generics cover every possible use-case of generics that you will reasonably need in to use in Go.

And yet, the core devs have never said they don't want generics, only they didn't want a poor implementation.

Also, there's a bit of hilarity about commenting this on a blog.golang.org where the first sentence is "This article is about what it would mean to add generics to Go, and why I think we should do it." being posted by a core Go dev....

Re: Why Generics?

#76
The proposed syntax feels like a caricature to me. That something like this could be easily possible:

    func (c Connection) Read(type T Writeable)(into *T) (int, error) {
This is quite securely inside shark-jumping territory.

Also; I haven't seen Rob Pike's name really anywhere in these blog posts or discussions, or on any recent Go blog entry. Is he still involved with the Go project day-to-day? I always got the impression that he was one of the bigger anti-generics voices on the team internally.

Re: Why Generics?

#78
post #30

why are people obsessed with simplicity? there's a quotation my Einstein that I like to keep in mind: "make things as simple as they can be but no simpler". the implication being that if you make things too simple then you actually break things. lack of generics makes for software that's actually more complex than it needs to be. Take for example Swift: lots of complex features (protocols, all manner of functional tr…

C++ solves all problem that can be solved with Go, but with a lot more features. Why are we not using C++ where Go is currently being used? By your logic, this shouldn’t be the case.

I'm pretty sure C++ is used for exactly the game thing Go is used for. And C++ is used for a lot of other things as well. In fact, you will probably have trouble finding a problem that wasn't solved by C++ by somebody. Scientific computing, server process, CRUD applications, embedded applications, AI, graphics, programming languages, libraries, etc.

C++ has a lot more features and therefore it's actually able to be used for a lot more things. People that don't need a language that can be used for every possible computing problem think that maybe C++ is a tad too complicated. Those people certainly have a point.

Re: Why Generics?

#79

I hope this doesn't happen. I love golang because it is simple and easy to read. Both will go away when generic programmer start to write unreadable meta-programming class which "you don't need to understand, just use them". I admire golang devs for being opinionated and stand up for the core lines of their language so far. I see generic as renouncing these principles.

This. If I really need generics I'll use a different language.

That's great if you get to pick the language you use for every project. Not all of us get that luxury.

Re: Why Generics?

#80
post #7

Earlier quoted context omitted.

I have yet to find one practical application for generics in the apps I've built in Go.

If you're writing loops that build up some accumulator, you could use generics. Even if you don't see that.

You could use generics for that kind of code, but that doesn’t necessarily mean you need them.

If you’re thinking of functional stream operators, many people think plain imperative iteration is easier to write (and easier to read).

Post reply on HN