Friday, September 30, 2016

                                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 

_______________________________________________________________________________



No comments:

Post a Comment