Re:Half a million lines of Go
by takeda on Monday May 17, 2021 @03:09AM
(#27180784)
They use hack of "interface{}" which does type checking at runtime (slow). And you then cast it to a proper type.
If I remember correctly (haven't used it in a year) Go cheats a bit, and it has few functions in standard library that do have generics (like make), it just doesn't provide this functionality to the developer.
Re:Half a million lines of Go
by loopz on Monday May 17, 2021 @03:57AM
(#27181018)
If you can avoid interface{} you should, ie. by declaring interfaces to types and using them explicitly. You can then mix your own types, and still be protected by the type system.
If I remember correctly (haven't used it in a year) Go cheats a bit, and it has few functions in standard library that do have generics (like make), it just doesn't provide this functionality to the developer.