asn't it George Jetson who went to "work" each day and pushed a few buttons to generate all his deliverables without lifting a physical or mental finger? Ah, would that our computers would write all the code we don't feel like writing (and write it so there are no bugs to fix, either!), leaving us free to focus on the fun, challenging, or unique aspects of our applications.
The notion of software that writes software has been around for decades, but it is only recently that developers are taking this notion of code generation seriously. What changed? Code generation changedand much for the better.
Your Father's Code Generation
|Figure 1. Workhorse: Automatic code generation promises to build about 80 percent of your application for you.|
Some of you may remember when RPGII
was introduced back in the 1960s and 1970s. This was an initial attempt at streamlining the development process by providing a higher-level language that generated code for you. In fact, 4GLs and 5GLs attempted this again in the '80s. High-level languages are effective at generating code, but only when you give them a highly structured environment. 4GLs work best when nearly everyone in the development team uses the same language, for the same reason that a development shop would standardize on VB or C#. The downside to 4GLs is that they are proprietary in nature, so mastering one can limit one's career mobility and ability to work in different application areas. It is for this reason, I believe, that there is no longer any 5GL on the horizon for code generation.
In the late '80s and early '90s came Computer Aided Software Engineering (CASE), which also worked well for highly-structured applications. CASE, as Abe Lincoln was fond of saying, "appealed to the people to which these sorts of things appeal." It worked well for highly structured, organized thinkersthose who write all the architecture down before starting the development process. However, this does not lend itself to the iterative style of development used by most developers today.
CASE tools did not actually generate code, but they did certainly provide great documentation and layout files. That was, of course, CASE's downfall. The tools never generated anything terribly useful for actual application development. However, CASE does hold the distinction of being the first technology to hold out the promise of code generation and not deliver.
Another category of tools that promised great things is what I would call bleeding edge research tools.' These ranged from AI systems to genetic algorithms. While they certainly have a number of uses, they are not practical to the meat and potatoes application development that most corporate developers do day-in and day-out.
Figure 2. Employment and Education History: Everything in this HR application Web page was created generated using an automatic code generator.
Figure 3. Checking its work: This is the generated code for the page from Figure 2. The XML-based code generation tags (in blue) are inserted at each location where a databound control appears.
On a more contemporary front, there are tools that will insert SQL queries into your ASPX page, and a lot of template-based IDEs
where, by pushing various buttons, you automatically create various aspects of your application. These both can work well if you need a standard, non-custom component.
And finally, having stood the test of time and still in use today is what I refer to generically as compiler-compilers. You may know these as YACC, JavaCC, and so forth. These are code generators, not application generators, because they focus on creating one aspect or component that lends itself to being regenerated over and over again. For example, YACC is a tool that generates a parser for a specific language syntax.
Evolving from the compilers are single-tier code generators. Some of the best of these will give you the flexibility to generate custom code for your specific database schema. Others will generate a schema based on your object model. For these tasks, they can work well. But they are not for generating a complete, custom application.
|Editor's Note: The author, Alan Fisher, is the cofounder and chairman of Iron Speed, Inc., a vendor of code generation products. We have selected this article for publication because we believe it to have objective technical merit.