3 ms·
I think most programmers would agree that running a code-generation program at build time is something that should be approached with a little more caution (not
by lmm 5y ago
I think most programmers would agree that running a code-generation program at build time is something that should be approached with a little more caution (not saying that you blanket shouldn't do it, but you should check the reputation of the code generator, what the output looks like, how well your debugger/profiler can handle it...) than using a plain-code library. But a lot of people seem to somehow fail to realise that using a macro is the same thing.
Everything can be abused, which is why it's best to write everything in the most restrictive environment that still allows expressing what you need to. See Dhall or Noether for what that looks like for everyday code. At the language design level, there may be cases where users need to apply an arbitrary Turing-complete AST->AST function, but it shouldn't be the first thing they reach for; if there are features (such as do notation) or patterns (such as Python decorators) that allow expressing most macro use cases via a more constrained (and therefore less maintainability-impacting) feature, that's a big win.