3 ms·
It's real shame it's kinda bad language for it. Looking at what people did with Rust macros it's shame that Go code generation story is either "just run some ra
by ilyt 4y ago
It's real shame it's kinda bad language for it. Looking at what people did with Rust macros it's shame that Go code generation story is either "just run some random binaries to compile stuff" or "put code instructing the compiler to do stuf in fucking comments"
And I say it without being sarcastic but Go makes me miss C preprocessor and nothing should make anyone miss C preprocessor.
- rad_gruchalski 4y ago> put code instructing the compiler to do stuf in fucking comments Funny considering how Rust does stuff. Both approaches have pros and cons. One either digs through a shitload of macros, or commits explicit auto generated code.
- ilyt 4y agoYeah the annotations in Rust suffer from bit of that but macros don't. I yearn for ability to make error handling macros...
- teeray 4y agoIt’s like metaprogramming in Ruby again, except with the idea that it’s somehow more straightforward because you can inspect the generated code. Except nobody will ever inspect auto-generated code because a) it’s usually awful code b) ignoring that code was kind of the whole point.
- philosopher1234 4y ago>Looking at what people did with Rust macros it's shame that Go code generation story is either "just run some random binaries to compile stuff" or "put code instructing the compiler to do stuf in fucking comments" Why is it a shame? Rely on macros and this is what you get: 1. Slow compile times 2. Unsearchable (grep, sourcegraph...) code 3. Magic codebases. Longer learning curve To me, working in a large organization, those are big downsides.
- ilyt 4y agoThe article is about code generation that is more magic than macros.
- philosopher1234 4y agobut you can inspect the generated code, jump to def, search it... how the actual generation works may be magic, but the code is reviewable, searchable, debuggable... Its clearly better than macros for my use cases