3 ms·
There is no doubt that Go needs generics. Pretty much every Go container and data structure library on github will benefit from generics. The empty interface is
by 13415 5y ago
There is no doubt that Go needs generics. Pretty much every Go container and data structure library on github will benefit from generics. The empty interface is used everywhere, leading to all kinds of panicking typecasts, hard to debug errors, and inefficient conversions. The vast majority of these uses can be made type-safe, more efficient, and clearer with generics. There is nothing subjective about the benefits of generics. Together with type-safe enumerations I miss generics the most from Ada.
To be honest, I'd use Ada if it had a significant infrastructure, but it feels pretty much dead. With Go I can at least get 3rd party libraries, as long as I check the source code to see if it's good enough.
- wvh 5y agoThere's some pain in writing generic data structure algorithms for sure. It would have been an interesting experiment though if the Go authors would have tried to improve the tooling around code generation and making it easier to use, as an alternative avenue to generics as code generation might satisfy some of the cases likely to trigger those complains. Anyway, interesting to see how far they will take the generics in the path to Go 2.
- pjmlp 5y agoIt isn't as if previous languages did not used code generators before generics were a thing on them.
- amw-zero 5y agoYea but, it has never been a particularly popular approach.
- pjmlp 5y agoIt surely was in C, C++ and Java. Borland BIDS 1.0 used such approach with pre-processor tricks, similar to many C projects do as well. Java, well EMF was a common tool to generate such boilerplate, Velocity was another one.
- pjmlp 5y agoMight be dead for FOSS, but still has 5 compiler vendors around and a new standard revision being done.