News for hackers. Stuff that matters.
Re:Golang: How to Update APIs for Generics by brabel on Thursday September 16, 2021 @02:55AM (#28548871)
They're still trying to decide basic stuff like how to transition existing APIs to generics!? Wow, that means it will be a long time for generics to land on stable Go.
Re:Golang: How to Update APIs for Generics by _ph_ on Thursday September 16, 2021 @06:50AM (#28550124)
No. The generics can be added without this discussion to be resolved. It is about upgrading existing APIs to make full usage of generics. Take math.Min for example. Currently it compares floats. Without changes, it continues to do exactly that. The question now is, how to have a new version math.Min that fully uses generics, without destroying backwards compatibility for existing code. Resolving this most elegantly is desirably, but not a necessity. Especially it can be added a few releases later than the generics themselves.
Re:Golang: How to Update APIs for Generics by arghwhat on Thursday September 16, 2021 @03:47AM (#28549164)
Because it's far from basic stuff when you have to consider stability guarantees.
Re:Golang: How to Update APIs for Generics by pjmlp on Thursday September 16, 2021 @05:49AM (#28549760)
You know how to avoid those problems?

By having them since the begining, it is not as other languages haven't gone through the path of bolting on generics after the fact, as an example for others to learn from.

Re:Golang: How to Update APIs for Generics by arghwhat on Thursday September 16, 2021 @10:33AM (#28552334)
You mean like how Rust had async from the beginning? Oh wait. I guess we'll have to wait till 2040 for these languages to be complete before we can have a release then.

The massive success Go has been suggest that their decision to start simple, without generics, was objectively a good one, even if unpopular to.somr.

Heck, not even sure if it'll really be Go anymore when it ships...

Re:Golang: How to Update APIs for Generics by pjmlp on Thursday September 16, 2021 @12:37PM (#28553929)
Good idea to bring Rust into the table, async is also not fully backed and there are several use cases that will only be taken care in years to come, if at all.

With incompatible runtimes.

So another good example of what happens when things aren't baked on 1.0 release.

If Go did not had UNIX/Plan 9 key persons and Google money attached to it, or killer projects like Docker and Kubernetes, it would have fizzled away.

As it is, even those that would rather not use it, must do so, specially when we use DevOps hats from time to time.

Re:Golang: How to Update APIs for Generics by tialaramex on Thursday September 16, 2021 @02:02PM (#28554981)
But it seems like this type of "replacing stdlib features" discussion mostly evaporates for Rust.

In Rust an edition changes the prelude and new code that looks the same now gets the desirable new behaviour, even though backwards compatibility is undiminished for old code.

It feels like several of the Golang proposals are in the same spirit (I noticed one explicitly invoking Rust) but as hacks rather than a built-in language feature.

Re:Golang: How to Update APIs for Generics by pjmlp on Friday September 17, 2021 @04:50AM (#28562872)
It only evaporates, because most people aren't language geeks that waste part of their life reading SIGPLAN and IEEE papers. :)

Currently in Rust async/await generators discussion has been put on hold as being a hot topic, and as library writer one can't still be sure the library will properly work across all async runtimes.

https://rust-lang.github.io/async-book/01_getting_started/03...

Same kind of 1.0 issues apply to Java, D, C#, C++,.... and they are specially bad in guest languages that take decisions on syntactic sugar for missing platform features, and when the platform adds those features, they usually end up with two ways of doing the same thing.

Re:Golang: How to Update APIs for Generics by tialaramex on Friday September 17, 2021 @12:09PM (#28567155)
This seems once again to have returned to talking about async, for whatever reason, rather than the topic "How to Update APIs for Generics".

> as library writer one can't still be sure the library will properly work across all async runtimes.

If you have assumptions that the runtime can't deliver, your library won't be useful with that runtime. True. Most obviously if you require async to mean "It just magically happens on another thread", and that's not what this runtime offers, too bad, that's not what you get.

It is conceivable that Rust will settle on Async always meaning Threads, and then this problem goes away, but I suspect it's far more likely (since Rust is adopted in embedded systems where nobody has any intention of "just" dropping in a complete threading system) that this persists, if you needed Threads then you'd better make sure you've actually got Threads, because duh, if there's only a single thread of execution then whenever you're not waiting for the async task to happen it isn't being worked on.

Latency has a similar issue, if you need latency guarantees you need a runtime with actual latency guarantees, Rust's async does not do that work for you.

But again, if down the road this is magically resolved (which I doubt) Rust can just ship a new edition with the new behaviour, which is the point you entirely ignored.

The problem is how to move forward, and I believe Editions are a significant improvement over the status quo for most languages in that regard. You can't expect to get everything correct in 1.0, and so you should already be planning for how to improve.

Re:Golang: How to Update APIs for Generics by arghwhat on Thursday September 16, 2021 @04:43PM (#28557295)
Those key persons are exactly the ones that decided Go should not have generics.

Heck, they're pretty much just succumbing to peer pressure.

Re:Golang: How to Update APIs for Generics by rubenv on Thursday September 16, 2021 @06:05AM (#28549845)
I for one like not having things rushed in which then cannot be changed later on.

Does this mean Go is perfect? Not at all.

It just means I'd rather have generics late than fundamentally broken.

Re:Golang: How to Update APIs for Generics by pjmlp on Thursday September 16, 2021 @06:09AM (#28549866)
For the time we have waited already, what is a couple of years more, right?

Now if that would have been part of Go 1.0....

Re:Golang: How to Update APIs for Generics by can3p on Thursday September 16, 2021 @07:21AM (#28550315)
So far I prefer this approach to any other. I know this type of discussion happens under any go submission, but still - need in generics is overrated, there a ton of code written for all sorts and purposes and scales and it works just fine. And all that without a gigantic marketing push which means that developers simply like it that way it is.

Go is about compatibility, being able to control your code base and being confident about results and I'd really prefer them to take their time thinking through a non-critical feature rather then rushing it and exploring all sorts of unexpected side effects down the road.

Re:Golang: How to Update APIs for Generics by pjmlp on Thursday September 16, 2021 @07:23AM (#28550336)
Indeed, only Google paychecks, and two historical figures of UNIX and Plan 9 history, no marketing at all.
Re:Golang: How to Update APIs for Generics by grumpyprole on Thursday September 16, 2021 @08:12AM (#28550722)
"Generics" or parametric polymorphism, first appeared in the 70's. So I don't think including this with Go 1.0 would have been rushing!
Re:Golang: How to Update APIs for Generics by arghwhat on Thursday September 16, 2021 @10:34AM (#28552350)
Yeah, about that: just because the theory exists doesn't make it less work to design new elegant typesystems around them.

Go actively decided against generics in the beginning to make a small and simple language. We will lose that now.

Re:Golang: How to Update APIs for Generics by grumpyprole on Thursday September 16, 2021 @11:19AM (#28552936)
As they will need to be retrofitted just like Java had to do, yes I'm sure there'll be warts. Had they been considered from the start, I'm sure it could have been much simpler.
Re:Golang: How to Update APIs for Generics by brabel on Thursday September 16, 2021 @06:37AM (#28550035)
I mean basic in that it's like the feature can't even be added if you don't solve that.
Re:Golang: How to Update APIs for Generics by arghwhat on Thursday September 16, 2021 @10:37AM (#28552376)
Of course it can, the problem isn't writing APIs, it's rewriting old APIs that have static types to also be generic without breaking old code that rely on the static types.

E.g., if you write the number constant "1" as arg to a method taking "float64", it's implicitly converted to that. If the method takes a T, you instead have an int.