Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
compare webbrowser
Freenet DSL
Who's Online
2 user(s) are online (2 user(s) are browsing encyclopedia)

Members: 0
Guests: 2

more...
browser tip
Unix Befehle
manual of unix befehle
recommendation!
Sponsored
partner

Metaprogramming

: This article is about the programming technique. For the management technique, see metaprogramming (management).

Metaprogramming is the writing of computer program that write or manipulate other programs (or themselves) as their data or that do part of the work that is otherwise done at Runtime during compile time. In many cases, this allows programmers to get more done in the same amount of time as they would take to write all the code manually.

A simple example of a metaprogram is this Bash script (computer programming), which is an example of generative programming:

#!/bin/bash # metaprogram echo #!/bin/bash >program for ((I=1; I>program done chmod +x program

This script (or program) generates a new 993 line program which prints out the numbers 1–992. This is only an illustration on how to use code to write more code, not the most efficient way to print out a list of numbers. Nonetheless, a good programmer can write and execute this metaprogram in just a couple of minutes, and will have generated exactly 1000 lines of code in that amount of time.

Not all metaprogramming involves generative programming. If programs are modifiable at runtime (Lisp programming language, Smalltalk, Ruby programming language, and other languages), then techniques can be used to accomplish metaprogramming without actually generating source code.

*The most common metaprogramming tool is a Compiler which allows a programmer to write a relatively short program in a high-level language and uses it to write an equivalent assembly language or machine language program. This generally saves a good deal of time compared to writing the machine language program directly.

*Another still fairly common example of metaprogramming might be found in the use of ), which are used to generate compilers and interpreters.

*A Quine is a special kind of metaprogram that has its own source as its output.

*One style of programming which focuses heavily on metaprogramming is called Language Oriented Programming.

Reflection (computer science) is a valuable language feature for facilitating metaprogramming. Having the programming language itself as a first class data type (as in Lisp programming language) is also very useful.

=See also=

*Template metaprogramming, a C++ compile-time example *OpenC Plus Plus *Recoder *Code generation *introspector (program) *XL Programming Language *Self-modifying code *Partial evaluation *Ruby on Rails, an Open source web application framework

=External links=

*[http://c2.com/cgi/wikiMetaProgramming c2.com Wiki: Metaprogramming article] *[http://fare.tunes.org/articles/ll99/index.en.html Metaprogramming and Free Availability of Sources] by François-René Rideau *[http://www.meta-language.net/ MetaL] - Metaprogramming language with source code in XML that is used to generate code in several target languages: Java, Perl, PHP, etc. *[http://dslengine.sourceforge.net/ DSLEngine] - Scheme macro metaprogramming example *[http://www.cse.ogi.edu/PacSoft/projects/metaml/ MetaML] - A version of ML with homogeneous (same-language) metaprogramming *[http://recoder.sourceforge.net/ RECODER] - Framework for source code metaprogramming in Java *[http://lambda-the-ultimate.org/taxonomy/node/or/15 Metaprogramming Weblog] - At Lambda the Ultimate *[http://mozart-dev.sf.net/moka.html Moka, a Java-to-Java extensible compiler] *[http://poignantguide.net/ruby/chapter-6.html whys (poignant) guide to ruby] - Metaprogramming in Ruby *[http://www-128.ibm.com/developerworks/linux/library/l-metaprog1.html The art of metaprogramming, Part 1] - Introduction to metaprogramming, with codes in several languages