Hacker News new | ask | show | jobs
by AntiMS 1302 days ago
Like:

- `go generate` for embedding resources into the executable. So intuitive and beautiful.

- Strict curating. It's the kind of language that things don't get into unless they're the right solution.

- Performance! Python was my favorite language before Go got sufficiently mature. It was refreshing to have that much efficiency coming from Python.

- `if err != nil {`, dammit!

- Imports referring to the location where the code can be got. `import "github.com/fogleman/gg"` for instance.

- `go fmt`. Nuff said.

- Tabs as the standard indentation character.

- `fallthrough`

- `init()`

Dislike:

- nil. I wish nil had a smller role in the language. It's an agreed best practice in Go that a zero value should be a ready to use thing. I feel like that would be easier to do (and more true of the core language) if the zero value of a slice/map was an empty slice/map, the zero value of a pointer was a pointer to a zero value of the type it points to, etc. Maybe this can't be done for all types (function and interface types, for instance), and maybe there are good reasons for the way it is that I'm not smart enough to realize, but if it could be done for some types, it would be nice.

Things I Pretty Much Eschew:

- Generics are limited. Maybe I'm missing something, but I doubt I'll be using generics as they are very extensively at all. If we could make generic types that would be something I could see myself using more.

- Embedding. It's rare I find a use for that.

- `defer`, honestly.

1 comments

> If we could make generic types

What do you mean by this? Methods?

Generics as currently implemented in go are so limited that you may as well stick with interfaces for anything but trivial boilerplate or textbook data structure/algorithm implementations.

For example, it's currently impossible to define type constraints with user-defined interfaces embedded:

  ```
  // this is legal
  type MyConstraint interface {
    int64 | float
  }

  type SomeAPI interface {
    AMethod() error
  }

  // Nope
  type CantHaveThisConstraint interface {
    int64 | float | SomeAPI
  }

  // NOPE
  func SomeGeneric[T CantHaveThisConstraint](...) {
  }
  ```
It's true that doesn't work because you can't mix types with methods and types with no methods. But that's a far cry from "Go doesn't have generic types" or "may as well stick with interfaces for anything but trivial boilerplate".