20 Jan 2002 mstarch   » (Journeyer)

Code generators using XSLT ?

I have been experimenting with XSLT lately, and combined with an article I read in the C++ journal about code generation using XSLT, I have wondered if writing some code generators for some of the most normal tasks might be a good idea.

One example of a potentially time-saving application of code generators is database infrastructure. An SQL table is created, which must be accesible from a C++ program, which again must be accessible from an ASP script as a COM object. If this is hand-coded, a lot of time is spent doing simple and redundant typing. When a column is added to the table, multiple sections of code must be updated to reflect this change. The work invested in the specific SQL solution cannot be leveraged for later projects that have similarities.

Auto-generating this kind of code seems like a good idea, but the risk that the constructed templates aren't versatile enough to ensure their use for a sufficient number of cases to make them worthwhile exists.

Solving a specific problem by writing a code generator that generates code to solve the problem is a possibility, if a substantial part of the problem has traits that makes it likely to reccur at a later time, and if the code generator doesn't take substantially longer to write than what would be necessary to solve the problem directly. Writing modular code generators that are combinable becomes a worthwhile challenge.

To what extent should code generators be built and used ?

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!