Guest Opinion

Code Generation Drives the Future

The benefits of code generation are so strong that debates swirling around use are essentially moot. Its increasing use is inevitable, and developers will adapt.

Code generation is a hot-button topic for many developers.

Debates rage on about how code generation is either the salvation for building complex software systems, or the end of programming as we've known it over the past several decades. But both sides of this argument miss the real point. Code generation, based on an abstract definition or high-level model of application design and behavior, is all about delivering a high-quality application despite increasing constraints of cost and schedule. If generating some or all of an application automatically results in a higher quality application that can also be built more quickly, then code generation should become the standard for application development.

It's been a long time coming, but we are almost to the point where predefined code is largely replacing handwritten code in the vast majority of applications. In fact, developer-written code in most .NET applications today constitutes no more than 20 percent of total application code.

Ah, that's different, you might argue. The .NET Framework is a set of libraries, not generated code based on a higher level of abstraction. But most code-generation systems are sets of libraries whose methods build an application or component based on the specifications defined in a model or other representation of the software. It's a matter of degree rather than approach.

We have become dependent upon code libraries and frameworks because they provide us with reliable code that does tasks that don't contribute directly to unique application features. Generated code is reused code, and its quality gets proven in many different applications and uses. But code-generation technologies provide more than high-quality code. The productivity gains derived when working from a model or other high-level representation can overcome many inefficiencies in execution, especially with the ever-faster performance of processors.

Code libraries have a long history of enabling developers to improve productivity and application quality. A compiler is a code generator in a broad sense; few of us would prefer to work exclusively in machine language. Even if you look only at the PC era of computing, we've worked at successively higher levels of abstraction, requiring ever more sophisticated libraries simply to build an application.

Application quality has improved dramatically in that time. With managed code, we abstract common housekeeping chores such as memory management. The result is that developers can focus more on the implementation, rather than the mundane and error-prone details.

Performance has always been a point of contention when using code generation. While performance remains one of the cornerstones of application development, execution technology has become so good that managed execution environments have become the norm. Ironically, libraries and frameworks have become so pervasive that it's almost impossible for a developer to improve overall application performance more than a few percent.

Today, UML and Model-Driven Architecture (MDA) are emerging as modeling techniques that take application development to still higher levels of abstraction. Rather than model the application with a high-level programming language, we do so with diagrams that let us build formal and unambiguous pictures of the application. Code generation takes the behaviors defined in those diagrams and produces source code or even executable code. Programmers solve business problems rather than write code.

One knock against modeling and code generation is that the actual application design's high level of abstraction means code generation doesn't give you the opportunity to see how your design decisions gobble memory or create a massive working set. You have great productivity, but less of the insight needed to resolve problems. This is true, but there have always been developers who have had a deeper knowledge of technology than others, as well as developers who better understood the business problem. Each skill has its use in application development. Much generated code will be custom code, written by the technical heavyweights as pattern implementations used by less-technical programmers in specifying and assembling applications.

Code generation doesn't mean fewer "real" programming jobs. It does mean that the art and skill of programming will change, just as it always has. Programming—and the collateral discipline of software engineering—will consist more of diagramming the application, "debugging" the diagram, and integrating the generated application into the existing computing infrastructure. Programmers, who typically know several languages, frameworks, and even IDEs, thrive on such change.

About the Author

Peter Varhol is the executive editor, reviews of Redmond magazine and has more than 20 years of experience as a software developer, software product manager and technology writer. He has graduate degrees in computer science and mathematics, and has taught both subjects at the university level.

comments powered by Disqus

Featured

Subscribe on YouTube