News for hackers. Stuff that matters.
Re:A Proposal for Adding Generics to Go by azhenley on Tuesday January 12, 2021 @01:09PM (#25750812)
How many different proposals for generics have there been?
Re:A Proposal for Adding Generics to Go by throw_m239339 on Tuesday January 12, 2021 @01:28PM (#25751189)
Actually not that much, I remember 2 very different proposals, including this one.

The previous one was confusing as F and the antithesis of the simplicity Go claims it abides by. It felt very much like a plot to add generics without ever using the word generics anywhere and looking too much like Java/C#/...

The current proposal is basically what you'd expect from generics in a programming language, but a bit more limited.

It took basically 10 years, a generation of developers, to quell the opposition against generics in Go, to end up with generics...

They might even have unknowingly followed the ADA implementation except that Go's type inference makes them even easier to use.

> To use a generic type, you must supply type arguments. This is called instantiation.

https://go.googlesource.com/proposal/+/refs/heads/master/des...

This is basically how generics as packages in ADA works. I would add that ADA solved many existing problems in Go decades ago...

https://en.wikibooks.org/wiki/Ada_Programming/Generics

> The generic procedure can be instantiated for all the needed types.

Now all Go needs to do is to look at how Ada tasks work in order to fix every single issue with Go routines...

Re:A Proposal for Adding Generics to Go by wejick on Tuesday January 12, 2021 @01:33PM (#25751294)
I'm curious what's the issue with go routine and what kind of fix ADA bring?
Re:A Proposal for Adding Generics to Go by boyter on Tuesday January 12, 2021 @02:25PM (#25752085)
Not familiar with Ada but the inability to stop running goroutines from outside it is annoying and leads to a lot of state telling them to exit. Sometimes I just want it to stop now.
Re:A Proposal for Adding Generics to Go by wejick on Tuesday January 12, 2021 @02:39PM (#25752293)
It's not like on pthread where we have a trhead handler, that will complicate many things.

Like you said, We stop the go routine by telling it to exit the function, it's quite straightforward I think. Not more than a channel and switch case (+ context)

Re:A Proposal for Adding Generics to Go by rbranson on Tuesday January 12, 2021 @03:33PM (#25753156)
How would you expect that to actually work though? If a goroutine could be arbitrarily stopped at any point, that would trivially lead to degenerate program states. A lock could be held open or another goroutine could be waiting on it for a message.
Re:A Proposal for Adding Generics to Go by nappy-doo on Tuesday January 12, 2021 @01:12PM (#25750883)
I think this makes the third official attempt. I have high visibility into the process, and I think it's likely this one will stick. It'll likely take 2 releases (as Ian stated) to get it done.
Re:A Proposal for Adding Generics to Go by wejick on Tuesday January 12, 2021 @01:31PM (#25751242)
It's very good to witness the journey of generic, how the team is very cautious and dedicated to bring Go way of perfection.

IMO This is something that can't be done by a committee of so called industry players.

Re:A Proposal for Adding Generics to Go by EwanToo on Tuesday January 12, 2021 @01:13PM (#25750895)
There's been quite a few early proposals and drafts. This is the first one that I'm aware of that Google have agreed to implement.
Re:A Proposal for Adding Generics to Go by spf13 on Tuesday January 12, 2021 @01:14PM (#25750920)
This is the first. There have been several designs previously, each of which was refined based on feedback, culminating in this proposal.
Re:A Proposal for Adding Generics to Go by dgb23 on Tuesday January 12, 2021 @01:15PM (#25750946)
I have observed it from afar and my impression is that this is a close to final step in a long series of careful iteration, discussion and research.