4
Tabala
8y

Golang has to add generics in version 2.

Comments
  • 1
    Not going to happen. It's a performance waste that can be solved with many different techniques.

    https://appliedgo.net/generics/
  • 1
    So what can we do with functional programming? With out generics there will be no proper way to implement functions like map,filter,reduce and ... and it would be a too bad for a language like go
  • 0
  • 0
    I have read all the articles about it but there is noway to implement map,reduce,filter and ... in golang now without using reflect library.
  • 0
    @Tabala then use reflect. It exists for a reason, and if it's the only way to do what you need, use it
  • 0
    @iam13islucky
    Reflect has horribble effect on performance of a program especially if you use it for purposes of functinal programming
  • 1
    @Tabala and, so do generics, at least according to what I've seen for why they don't want it. If you don't want to use reflect, then reevaluate why you need generics and find a go-like solution. All else fails, use anther language.
  • 0
    Who of you tried to hammer a nail with a screwdriver driver? Because from the conversation you guys are having it feels like you all try to hammer nails with a screwdriver and screw a screw with a hammer...

    Use the correct fucking tool for the job! If it doesn't suit you don't fucking use it for the job!
  • 0
    @nocgod so you can't read the manual either? FFS, Golang doesn't have generics for a reason — because THEY AREN'T NEEDED and implementing them would compromise on other aspects of the compilers and runtime. This is just like asking for inheritance. If you don't like it, use something else. The Golang team isn't going to compromise on a language just because a few devs can't comprehend that's not how it's done. If you want to do it differently, then use a less opinionated language. This is worse than the thread W3C had to lock because people kept bitching about observables being removed — it was removed in favor of proxies which are a blessing compared to the runtime mess observables created.
  • 0
    @Neotelos and what did I say? Use what suits the job don't fit the job for the language. Read the fucking rant
  • 0
    You guys are more royalist than the king. The golang team had said that generics may be well added at some point slices and maps are already using generics and using interface{} and reflect instead of it will cause a huge cost on performance if you are worry about that:
    "Regarding generic programming, some built-in functions are in fact type-generic, but these are treated as special cases; Rob Pike calls this a weakness of the language that may at some point be changed. The Google team that designs the language built at least one compiler for an experimental Go dialect with generics, but did not release it."

    And refer to the official website of golang:

    "Why does Go not have generic types?
    Generics may well be added at some point. We don't feel an urgency for them, although we understand some programmers do."

    At last who thinks generics are not needed in golang may be is not familiar to serious problems of programming without them.
Add Comment