top | item 19366741

An Update on Go and Generics in 2019

9 points| apatheticonion | 7 years ago |medium.com | reply

3 comments

order
[+] LordHeini|7 years ago|reply
Too sad that it will "take time".

I worked on 3 projects in Go and in 2 of those generics would have been very useful.

I ended up copy pasting a bunch of functions and changing their types (interfaces would have been even worse in those cases).

There is a library doing that automatically, like c++ templating but worse since it is not part of the compiler.

Combined with anti-features like null pointers, rather stupid and overly verbose error handling and awful dependency management, it makes for a language which often feels hindered by shortsighted oversimplification.

I kind of like the simplicity of Go. But they lobbed too many things over board without having proper replacements. And repeated dumb stuff from other languages which should be no part of any modern language (Billion Dollar Mistake ect.)

[+] tgirod|7 years ago|reply
Interesting read, but I think the first part would benefit from a detour toward interfaces, why they are not good enough to solve the sort problem, and how contracts can help.

IIRC it is along those lines :

You could define a `Lesser` interface with a method `Less(Lesser) bool`, and implement this interface on what you want to sort, but then you would have no way to assert at compile time that x and y are of the same type in `x.Less(y)`.

As I understand them, contracts allow you to assert things like this.

[+] PopsiclePete|7 years ago|reply
The blogspam must flow. How exactly was this an “update”? Just regurgitating what’s already out there and hasn’t changed in a year?