3 ms·
Haskell has fully-featured generics and Go does not. In this sense Haskell is more powerful than Go. However, Go has mutability and (mostly) Haskell does not. I
by dfgdghdf 6y ago
Haskell has fully-featured generics and Go does not. In this sense Haskell is more powerful than Go. However, Go has mutability and (mostly) Haskell does not. In this other sense, Go is more powerful than Haskell.
- Geminidog 6y agoKind of but if you think about it generics and parametric polymorphism in general is a restriction on the types that a function can take as parameters. It is a feature that allows you to restrict how a function is used. In a sense you are using generics to deliberately make a function less powerful. Golang doesn't have parametric polymorphism as a restrictive option . Instead you can use interface {} which removes all restrictions makes go as unrestrictive as python. Type checking and any feature related to it in general exists to make languages less "expressive"
- c-cube 6y agoTypes in Haskell are not just restriction, they're also used to generate code automatically for you using typeclasses. Something like [traversable](https://wiki.haskell.org/Foldable_and_Traversable https://wiki.haskell.org/Foldable_and_Traversable) provides behavior just based on types, and is far too powerful to be expressible in Go (or in most typed languages anyway).
- Geminidog 6y agoThis isn't code generation. This exists in other typed languages including Go. It's called interfaces or polymorphism. It's done via interfaces or inheritance in other languages. This is still a restriction. A function that operates only on a "traversable" type is still a function that is restricted to that type class.
- dfgdghdf 6y agoYes, you are given the power to restrict a function's usage