Dave Thomas on Code Generation

Pragmatic Programmer Dave Thomas talks about code generation.

He says that he does not believe in 'application generators'. I do believe in them. The power of a generator depends on the kind of metadata you provide to it, and of course you can provide a generator enough metadata to generate anything.

Taking my argument to the extreme, the C# compiler is a code generator and the metadata for that code generator is the C# source code, so this 'generator' lets you generate a full application.

If you find a way to specify all the metadata you need to create your complete application, then you will be able to generate your full application.

The most powerful way to specify metadata is doing it declaratively. If there are things that you don't know how to specify declaratively you can write procedural code in a domain-specific language. Then and only then, you need to write code in a general purpose language as C#. The first two scenarios could involve code generation and I think you can generate complete applications by only using them.

The funny thing is that Dave talked about putting abstractions in code and details in metadata, so it seems that he does not believe that you can specify an application with just metadata, and let the code generator (or a runtime engine) to build the abstractions needed to run it.

1 Comment

  • Did you even read the article? What Dave talks about in the whole rest of the article is the same argument as you are giving. What he means by "application genators", I take to be what he and Andrew Hunt calls "Evil Wizards" in the Pragmatic Programmer; that is programs that spews out reels upon reels of unmaintainable code (think MFC...)

Comments have been disabled for this content.