Oh god please don't do this indiscriminately. If you're typing out boilerplate, document it and add a generator for it. I've been bitten probably hundreds of times by bad abstractions created to save some keystrokes that turned 50 lines of boring easily readable code into an ungrokable dense mess.
"Okay, so you pass the function a lambda. And the input parameter to that lambda is another function that itself consumes a list of lambdas. And this is so that you don't have to init and fill in a few dictionaries OR because you might need to otherwise use an if-statement."
I like abstractions as much as the next person, but oftentimes you can just make due with the exact thing.
What do you mean "add a generator for it"? Do you mean something like a templating for source code, like the C pre-processor?
I think there is a pro and a con to that approach.
The pro is that there is a meaningful and familiar intermediate representation --- the output of the C pre-processor is still C code. Another example is https://doc.qt.io/qt-5/metaobjects.html
The con is that, well, it introduces a meta layer, and these meta layers are more often than not ad-hoc and ultimately became quite unwieldy. It's a design pattern that suggests that there is a feature missing from the language.
No absolutely not, I think that's the worst of both worlds. I mean something like `rails generate` where it's a parameterized block of generated code that you insert inline and then edit to your needs.
The disadvantage is that making sweeping changes is more work. The advantage is that making sweeping changes can be done incrementally. But the big win with code generators is that all you need to understand what's happening is right in front of you instead of having to mentally unwind a clunky abstraction.
Don't get me wrong if you have a good abstraction that reduces the use of mental registers do it! But you would and should do that regardless of boilerplate.
It's a design pattern that suggests that there is a feature missing from the language.
This is the part where I’ve been entertaining the idea of solving things at a language level (transpiler). It’s a dangerous idea because if we get better tools to extend the language and everyone does it, we’re all going to be fucked.
But I can’t shake the idea that some of our frameworks, if incorporated at a language level, could entirely eliminate the boilerplate.