Re:Go generics may use square brackets [] not parenthesis ()
by jfkebwjsbx on Wednesday July 15, 2020 @09:27AM
(#23844881)
There is nothing wrong with code generation, what do you mean by "or worse"?
Re:Go generics may use square brackets [] not parenthesis ()
by centril on Friday July 17, 2020 @06:26PM
(#23876701)
Off the top of my head: Poor error messages, any type checking is run on the generated code so harder to enforce properties, and if code generation is not in-language, then the base logic can diverge for different types, which is bad when you find bugs.
2) Without generics, you are probably reinventing the same code, or using reflection which is not even type safe, or worse, using code generation. For instance D has generics AND good compile times. I guess Nim compiles fairly well too. Or you can choose partially type erasure based generics with a different tradeoff. There is no point in not having useful generic functions on generic data structures in a language that came in 2000s.
Once write Python or ruby or something and come back to Go. People without knowledge of other languages with generics tend to think you are writing for loop in while loop in if - else break monstrosity because native compilation and performance come with a cost in expressiveness, while it need not be.