1. 15
  1. 6

    Basically people love Go except for the fact that it lacks Generics

    1. 10

      People who fill out surveys on the Go blog love Go. Not quite the same :P

      1. 4

        I hope the Go creators remain stalwart and don’t allow public opinion to sway their design decisions.

        1. 2

          I’d like to see the standard library evolve to allow more user-focused applications such as GUI and Android programming but otherwise I agree, the language itself is great.

        2. 4

          What’s interesting is golang has generics; they’re only for special blessed types though.

          The best argument I’ve heard for generics in the language is it allows a more functional style for things like filter and map. Today these boil down to type specific functions or functions that mix interface{}, type assertions and for loops.

          Really generics only add ergonomics, and when done poorly create amazing quagmires. I understand why the designers want to avoid user accessible generics.

          If done simply though, much like how the slice/map or make/copy/delete functions work today, it would be a powerful addition to the language, but like others have noted I would not hold my breathe for it.

          1. 5

            Interesting. When I think about generics in Go, I don’t think about being able to write map or filter. Writing out the for loops to do the equivalent doesn’t irk me that much, and it’s pretty easy to get right.

            The place where I miss generics the most is the ability to build reusable data structures. Some data structures are hard to get right, and those tend to be precisely the same data structures that one builds when you care about performance. This makes interface{} a double bummer, since you lose both type safety and you take a perf hit.

            There are some interesting data structures that use interface{}, but by convention, generally end up retaining type safety. The new context package is one such example. But there are other examples that suffer the problems above.

            With all that said, building these types of data structures feels pretty rare to me at $work, or at least, the data structures we need don’t have to be generic. So it ends up not being a huge problem. But it does happen from time to time.

            I basically agree with your comment but thought I’d just add my two cents as well. :-)

          2. 6

            I suspect that when you ask people what Go is lacking, that’s the first thing that comes to mind whether you think it’s a real issue or not.

            1. 2

              I like Go just fine without ‘em, but then again I don’t use it for everything.