3 ms·
he difficulty comes when you suddenly find yourself having to debug generated code and you find that it has become impenetrable and unreadable So don't do that
by DanielBMarkham 17y ago
he difficulty comes when you suddenly find yourself having to debug generated code and you find that it has become impenetrable and unreadable
So don't do that. When you find yourself doing that, you know you've gone too far.
I think maybe you've misunderestimated me: F# is a functional language. It'd be easy enough to abstract my way into all kinds of scary stuff.
Code generation is a form of meta-programming and abstraction. I find it useful in certain circumstances, like when I'd like to have types to inspect that are going to match up perfectly with my persistence framework. Language-level abstraction takes away the touchy-feely inspection I like, and there's no point re-inventing the wheel. Simply kick out a template and don't worry about it.
But you're absolutely right that in general, copy-and-pasting and code generation are signs that you are doing bad things. Just not always :)