Metaprogramming
Metaprogramming is the art of writing a computer program with the ability to treat programs as their data.It means that a program could be design to read, generate, analyze or transform other programs, and even modify itself while running. Metaprogramming is what is done with C++ templates or CommonLisp macros. The code in question usually consists of a template and some instructions and how to fill it. The instructions in Metaprogramming are rather complicated. CommonLisp Macros can transform or generate the code in arbitrarily sophisticated ways.The programs that can be modified at runtime or have incremental compilation available can be actually used to perform Metaprogramming without generating a source code. The java languages can be used for metaprogramming are C#, Forth, Frink, Groovy, JavaScript, Lisp, Lua, Perl, PHP, Python, REBOL, Ruby, Smalltalk, and Tcl.
Why is Metaprogramming done ?
- To get around limitations in the primary development languages. Usually, this sort of thing is done when there is a management edict to use a particular language. The use of a different language is not allowed but doing MetaProgramming with the development language as the target is politically acceptable.
- To encapsulate domain-specific knowledge. These languages are generally more domain-dependent.
- To allow users to configure and program a system even though it is assumed that the user will not be capable of modifying the program source directly, or might not even have access to that source.
Is metaprogramming a good idea ?
The answer to the problem of whether Metaprogramming is a good idea or not depends on how domain-specific the meta-language is and on how complicated it is. The domain-specific meta-languages are more justifiable and simpler, and simpler is better.
_______________________________________________________________________________
References
- http://c2.com/cgi/wiki?MetaProgramming
- https://en.wikipedia.org/wiki/Metaprogramming
- https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&ved=0ahUKEwj43tuJ7LfPAhWJZiYKHYOLCAMQjRwIBw&url=https%3A%2F%2Fmetaprogram.bandcamp.com%2Falbum%2Fmeta-programming&psig=AFQjCNG3G2iwikLjcD1BMy_NBybNsxrUoA&ust=1475350229034271(Image)
- https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&ved=0ahUKEwjEztra7bfPAhUF4SYKHQdxCxgQjRwIBw&url=https%3A%2F%2Fwww.crondose.com%2F2016%2F08%2Fexamples-metaprogramming-guide-beginners%2F&psig=AFQjCNG3G2iwikLjcD1BMy_NBybNsxrUoA&ust=1475350229034271(Image)
_______________________________________________________________________________