CSC/ECE 517 Fall 2010/ch2 S24 sk

From Expertiza_Wiki
Revision as of 02:18, 21 September 2010 by Skey (talk | contribs)
Jump to navigation Jump to search

What is Metaprogramming

Metaprogramming is in essence using programs to manipulate other programs. the concept is actually a classic UNIX principle on writing code and is far from new. In fact, its technical beginning probably starts with Konrad Zuse's insight almost 70 years ago that a computer could prepare its own instructions. Metaprogramming has been garnering the attention of developers and software engineers in recent years, first with dynamic languages such as Ruby and more recently with static languages such as Java and C++.

Metaprogramming is also called generative programming. The idea is that instead of modifying simple data elements, you modify symbols (or patterns) that represent complex operations. This is achieved through three key components. A metalanguage where we define a generalization or pattern. A generator which is an expression of that generalization and finally an instance which is the output from the evaluation of that generator. The goal is to generalize a set of concrete instances that can be evaluated and generated as a static representation of what we wish our code to accomplish. This takes polymorphism variation out of the code level and moves it up to the metalevel where it can be interpreted by Domain Specific Languages (DSLs) which describe how a system should be generated.

Metaprogramming in Practice

Dynamic Metaprogramming

Template Metaprogramming

Drawbacks of Metaprogramming

Addressing the Drawbacks

Conclusions

References