On Sunday, December 20, 2020 at 11:38:54 AM UTC-8 Martin Hanson wrote: > I think people who want generics added to Go should go and program in Java > or C++. > <troll mode>Perhaps you should switch to Python if you don't want generics?</troll mode>
> Adding generics to Go will ruin the beautiful simplicity of the language > and I haven't found a single example in which adding generics to Go pays > off. > Can you provide concrete examples of code that would become more complicated and/or slower with the addition of generics? I'm genuinely researching it. >From what I see, most of complexity in other generic systems comes from co/contra-variance support which Go lacks, or in case of C++ from overcomplicated pattern-matching. Even with the examples of having two almost identical functions reverse > some list, one of ints and one of strings, seriously!? We already have tons > and tons of open source reusable code that covers all use cases which > people complain about. > Go is unnecessary verbose in many places (for example, it lacks a very-much-needed map_keys(m) function). Moreover, lack of generics doesn't allow us to create custom collections with type safety (e.g. sync.Map). Adding generics means that we're opening the door to the beginning of > bloating Go with all the crap that Java, C++ and all the other complex > languages has gotten over the years, and Go was designed specifically > without that clutter. So we add generics, then what? Java itself is not particularly complex in practice (its generic implementation is Turing-complete, but in practice complex generics are not used), most of the complexity comes from over-engineered third-party libraries. > Classes? > We already have classes. > Adding generics to Go ruins that beautiful simplicity that went into the > design and the added complexity just isn't worth it! The standard library > have managed just fine without generics and so have we! > The standard library actually has two generic types: map and array, along with a bunch of magic functions (like copy and delete). In general, Go managed to tread a very fine line between "overcomplicated nonsense" and "stupidly verbose" pretty well. So I suggest trusting the language maintainers. They are doing a great job! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/91349770-e8cc-4d01-ab8d-0ea6cc9a89e6n%40googlegroups.com.