2 ms·
What is it with Go's love of code generation? Everything from protocol implementations to database connections seems to generate a large wad of Go code. Is it j
by cybrexalpha 6y ago
What is it with Go's love of code generation? Everything from protocol implementations to database connections seems to generate a large wad of Go code. Is it just to workaround the lack of Generics?
- zippoxer 6y agoI think it doesn't hurt that most if not all of the packages needed for code generation are built into the language's standard library.
- bagol 6y agoI think it's. Usually, compiler generates each concrete implementation for generic. But in go, that's programmer's job. Maybe it's trade off for language's simplicity.
- erik_seaberg 6y agoThis is an opportunity to use a higher-level DRY language to drive the code generator, and treat Go like assembly.
- loopz 6y agoDunno, but would guess this is consultancy-driven. Nobody would generate code they need to maintain afterwards. In the example of DB schema though, could be a way to avoid ORM but still import schema into code. Code generation is not all barf. Generics are being planned for golang.