Guajara in other languages: Spanish, Deutsch, French, Italian ...



Metaprogramming

Metaprogramming is the writing of programs 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. This allows programmers to produce a larger amount of code and 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:

  1. !/bin/bash
  2. metaprogram
echo "#!/bin/bash" > program for ((I=1;I<=992;I++)) do
       echo "echo $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, this is not the most efficient way to print out a list of numbers.

A good programmer can write and execute this metaprogram in 5-10 minutes, and will have generated exactly 1000 lines of code in that amount of time. This is a good reason why you should never pay programmers by the number of lines of code they write.

See also

External links


Metaprogramming is also the name of an management technique invented by Charles Simonyi for organizing the work of a team of programmers. In a 2002 news item [1], The Age noted:

Simonyi, 54, introduced the concept of metaprogramming at Microsoft, turning it into what people sometimes referred to as a software factory. This was something on which he had written a thesis. The metaprogramming concept did not work out in practice....

In his 1992 book Accidental Empires, Robert X. Cringely gave this description:

Simonyi's dissertation was an attempt to describe a more efficient method of organizing programmers to write software... the metaprogrammer was the designer, decision maker, and communication controller in a software development group.... individual progammers were allowed to make no design decisions about the project. All they did was write the code as described by the metaprogrammer.... A programmer with a problem or a question would take it to the metaprogrammer, who could come up with an answer or transfer the question to another programmer...




Wikipedia - All text is available under the terms of the GNU Free Documentation License.

Tagoror dot com  -  Legal Information  -  Contact us