News for hackers. Stuff that matters.
Re:The perfect language and why Go still isn't it by mijoharas on Sunday August 04, 2019 @03:20PM (#20608672)
I remember the first time I tried to use them.

I just wanted to make some small functions for logging different types of things. I wanted to use parametric polymorphism to dispatch to different functions depending on the type of the thing I passed in. I think I ended up creating a few `log_type_foo` and `log_type_bar` functions rather than the single `log` function I wanted. It looked really ugly to my eye.

The thing I really wanted was parametric polymorphism. I seem to remember reading something where the go people think this is equivalent to generics.

EDIT: clarity

Re:The perfect language and why Go still isn't it by majewsky on Sunday August 04, 2019 @05:20PM (#20609292)
Go supports parametric polymorphism by specifying arguments with an interface type.

  func DoWorkWith(foo Loggable) { ... }

  type Loggable interface {
    //for example
    LogTo(os.Writer)
  }