Live data from Hacker News

Proposal: Go should have generics

github.com

131–140 of 439 posts

Re: Proposal: Go should have generics

#131
post #94

Earlier quoted context omitted.

I had the same feeling first. But practically in my code, I found that ok, you need to copy/paste a bit first but then if it works it stays there, you are not "sorting" new kind of "types" every day. The time spent on coding is way more "around" the algorithms than "within" them. I suppose that we will see more and more code generators which will practically remove the need of generics. We already use them without co…

> you are not "sorting" new kind of "types" every day You'd be surprised.

I am writing a chemoinformatics database, so for my practical use, these are a lot of lines of codes with pretty involved algorithms and I am practically not annoyed by the lack of generics.

For the ones down-voting me, have you coded something in Go, big enough to be a real in production project, where at the end the lack of generics is a real issue (performance because using interfaces or maintenance because copy/paste to have the performance)?

Re: Proposal: Go should have generics

#133
post #23

Earlier quoted context omitted.

I don't see why you'd choose Go instead of a JVM language like Java, you get the language simplicity (plus features like Generics) and the performance upside too.

Memory usage and as a consequence of that excessive GC pauses. I'm not looking at any JVM language again before they introduce value types in a couple of years (maybe).

I build soft real time simulation systems in Java. GC pauses haven't been a problem since 1.2 was released around 2000. Memory usage isn't a concern either for big applications, as there's not a lot of overhead in the runtime. There is the fact that one can't embed value types directly in objects, but I don't find that a problem in practice.

Re: Proposal: Go should have generics

#134
post #107

Maybe instead of adding generics to Go it's time to look into alternative programming languages which already implement generics, like for example Nim.

Nim has generics but doesn't have interfaces, which makes things even worse in my opinion.

True. But Nim does have type classes, which in some ways are much better. Interfaces like the ones in Go can be easily emulated using closures.

Re: Proposal: Go should have generics

#135

As long as programmers that are comfortable with (and prefer) 30+/40+ year old PL paradigms are at the helm of Go's design, it's not very likely the language will grow Generics. To paraphrase Max Plank: "A new language-level feature does not triumph by convincing its opponents and making them see the light, but rather because its opponents eventually die, and a new generation grows up that is familiar with it."

Only Max Planck was talking about questions of truth.

Re: Proposal: Go should have generics

#136
post #65

Earlier quoted context omitted.

Generics become complicated when you have other subtype relationships, don't they? (That's why SML, OCaml and Haskell don't really do inheritance, isn't it?)

Go doesn't do inheritance either. It has type embedding, but it's not the same. In the most recent of Ian Lance Taylor's proposals (Type parameters, 2013 [1]) he summarizes: > The implementation description is interesting but very complicated. Is any compiler really going to implement all that? It seems likely that any initial implementation would just use macro expansion, and unclear whether it would ever move beyon…

> Go doesn't do inheritance either. It has type embedding, but it's not the same.

It does have interfaces though.

Re: Proposal: Go should have generics

#137
post #77

I can feel the pain on the Sort issue. I've personally found sorting annoying in Go - I had a bunch of structs representing data entities from a database that all had the same field and I wanted to be able to sort them by this field. Seemed like a LOT of work (basically implementing the same sort that was 99% identical for every struct) or use weird reflection-workarounds to get this to happen. In Java I would not ev…

Write a code generator. That's the best solution at this moment.

Or go the JS route and write a transpiler. Language is lacking? Make a new one.

Re: Proposal: Go should have generics

#138
post #124
post #110

Earlier quoted context omitted.

This is stupidly easy with http://dl.acm.org/citation.cfm?id=2738008 - I opened an issue for considering something like this for go https://github.com/golang/go/issues/15295 hopefully I didn't err in posting it :)

are you really posting a paid article on HN?

The article on Sci-Hub https://sci-hub.io/http://dl.acm.org/citation.cfm?doid=28138...

Re: Proposal: Go should have generics

#139
post #9
post #2

"The intent is not to add generics to Go at this time, but rather to show people what a complete proposal would look like. We hope this will be of help to anyone proposing similar language changes in the future." This started in 2010. Hopefully an illustration that go's developers are not against generics in general, this ought to quell some of the negativity... Pick one of the four proposals you like :)

They better implement something very near by, Swift is coming for them.

I haven't really looked at Swift properly but from what I see on the iOS dev blogs I follow, it's a lot more complex than Go and I can't see how productivity / etc. would be improved sufficiently to make the learning and general brain investment worthwhile for me.
Post reply on HN