News for hackers. Stuff that matters.
Re:Go Replaces Interface{} with 'Any' by egeozcan on Tuesday December 14, 2021 @05:24PM (#29558950)
I don't see why that wouldn't be possible to implement now that the generics are here.
Re:Go Replaces Interface{} with 'Any' by linkdd on Tuesday December 14, 2021 @05:27PM (#29558975)
Which is exactly why I said:

> I cannot wait for the Result monad.

Generics make this possible, and will be a huge improvement to Go's error handling.

I'm not saying it will solve everything, but it's a huge step nonetheless.

Re:Go Replaces Interface{} with 'Any' by xyzzy_plugh on Tuesday December 14, 2021 @07:16PM (#29560114)
I think you will find that Go's error handling will not change as much as you suggest. The majority of developers are extremely cautious of generics and found the status quo to be the best balance between readability and conciseness.

Convenience is not a goal of the language, generally.

Re:Go Replaces Interface{} with 'Any' by saghm on Wednesday December 15, 2021 @01:29AM (#29562775)
> The majority of developers are extremely cautious of generics and found the status quo to be the best balance between readability and conciseness.

Most people who use Go have specifically chosen to use it though (or at least sought out opportunities, given that it's not something entrenched like Java being used due to inertia), so yes, most of them are fine with how Go is or they wouldn't be using it in the first place. If Go had generics from the start, I'd imagine most users would be fine with that too due to self-selection.

Re:Go Replaces Interface{} with 'Any' by Aeolun on Tuesday December 14, 2021 @11:16PM (#29562029)
It doesn’t need to be part of the core language. Everyone can make their own monad, or use the one from a library.
Re:Go Replaces Interface{} with 'Any' by egeozcan on Tuesday December 14, 2021 @06:01PM (#29559333)
I seem to have lost track of how the discussion reached that point, thanks for the clarification.
Re:Go Replaces Interface{} with 'Any' by eru on Tuesday December 14, 2021 @11:54PM (#29562259)
Depends on how generic you want this.

In Haskell, you can have functions that work generically over option-types, error-able types, lists, functions, tuples, etc.

In Rust, you have to specifically implement functionality for all of these.

But eg your 'map' function in Rust still works for all lists, no matter what item type. In Go before this change, you had to write a different map function for each item type that could be in your list.

In Haskell, the same 'map' function works for lists, functions, error-able types etc.