3 ms·
Some years ago at a former employer I used to for generating some Java 5 code. I needed (as I hazily recall) an interface of accessors, immutable implementation
by mauvehaus 7y ago
Some years ago at a former employer I used to for generating some Java 5 code. I needed (as I hazily recall) an interface of accessors, immutable implementation, and a factory for the same couple dozen members. It was a lot of boilerplate and the list was changing a fair amount over the course of development. It worked great, and I got it plugged into the ant build without too much difficulty.
I'm told the person who took over that codebase was equal parts perplexed and horrified by it. They ripped out the m4 code generation and just put the generated files directly in the source tree. As the codebase had stabilized, the purpose that m4 served was basically gone.
So, not still in use, but if I found myself in the same situation today, I'd explore other options and consider doing the same thing. Interface default methods might cover some of the need at this point, but it's so far back, I'm hazy on the details.
The nice thing about doing this sort of code generation with m4 rather than the C preprocessor is that m4 preserves formatting (like line breaks) a lot better. Even if you're not using any of the other functionality of m4 (and there's a lot), that alone makes figuring out where things went wrong easier.