3 ms·
You confuse parametric polymorphism with reusability. The former is merely one of several ways to achieve the latter. The Go way for reusability usually consist
by _ak 11y ago
You confuse parametric polymorphism with reusability. The former is merely one of several ways to achieve the latter. The Go way for reusability usually consists of interfaces.
- dcsommer 11y agoCode reuse is totally possible in Go. I never said otherwise. However, there may be unnecessary ergonomic and safety issues due to lack of generics. In particular, you may end up casting / type asserting when you really shouldn't have to.
- deleted 11y ago[deleted]
- dragonwriter 11y agoInterfaces and parametric polymorphism are not alternative approaches to solving the same problem, which is why many languages that feature parametric polymorphism also feature interfaces or similar constructs [0] (and why some languages that had interfaces for a long time later added parametric polymorphism [1].) [0] e.g., Haskell typeclasses [1] e.g., Java