3 ms·
I'm finding it difficult to accept the premise that generics and immutability are needed in Go. In my case, var foo map[<type>]interface{} solves 99% of is
by ShabbosGoy 9y ago
I'm finding it difficult to accept the premise that generics and immutability are needed in Go.
In my case,
var foo map[<type>]interface{}
solves 99% of issues where I would normally need generics.
The author also doesn't really specify what kind of generics, there's a huge difference between parametric polymorphism (i.e. Haskell type classes) and Java/C++/C# generics.
The sheer rapid pace of development and simplicity has made Go our primary stack.
- codygman 9y ago> var foo map[<type>]interface{} > solves 99% of issues where I would normally need generics. But it also opens you to to runtime conversion errors, spurious if checks for type information compilers with generics have, or slow reflection to find the type. > The author also doesn't really specify what kind of generics, there's a huge difference between parametric polymorphism (i.e. Haskell type classes) and Java/C++/C# generics. Java/C++/C#/Haskell generics all provide parametric polymorphism though. Haskell type classes provide ad hoc polymorphism, though I guess maybe they provide parametric polymorphism as well. Per Wikipedia: > In programming languages and type theory, parametric polymorphism is a way to make a language more expressive, while still maintaining full static type-safety. Using parametric polymorphism, a function or a data type can be written generically so that it can handle values identically without depending on their type.
- solidsnack9000 9y ago> I'm finding it difficult to accept the premise that generics and immutability are needed in Go. They aren't strictly needed; but that is not much of an argument. Having Maybe and Either available is a huge help. Those are examples of generic types I've really benefited from in Haskell, Scala, Rust, Kotlin, Swift... But of course I can code without them if I have to.
- GenericsMotors 9y agoLINQ gives a huge productivity boost...I wonder what a LINQ implementation in Go would look like. interface{} and run-time type assertions everywhere, probably.