Hacker News new | ask | show | jobs
by throw_m239339 1990 days ago
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...

1 comments

I'm curious what's the issue with go routine and what kind of fix ADA bring?
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.
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)

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.