Metaprogramming paradigm involves writing programs which manipulate other programs as their data. The language of the manipulating program is called metalanguage, and the language of the manipulated one is called object language.
The simplest example of metaprogramming tool is any compiler, since it converts code written in high-level language into low-level machine language or assembly language. It is clear that most languages which support string processing can be used for code generation for other languages. However, term “metaprogramming” usually implies that one language is used as both metalanguage and object language, and moreover, such usage is provided by language design.
Metaprogramming paradigm can be implemented in multiple ways:
- usage of macro systems;
- generic programming;
dynamic execution of string expressions which contain pieces of code and can be generated
at runtime (for example,
execute immediatestatement in PL/SQL);
- giving the programming code access to the interior of run-time engine.
- Lisp (dialects: Clojure, Common Lisp, Scheme)