CSC/ECE 517 Fall 2009/wiki2 1 ma: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
Metaprogramming is the writing of a program that writes other programs. Metaprogramming is not limited to o-o languages, but it seems that about half of the languages that support metaprogramming are object oriented. Consider how metaprogramming is done in the various languages, and give an example of writing a particular metaprogram in at least two of these languages to illustrate the differences. Since the Wikipedia article on metaprogramming is not very detailed, if you do a good job, you could submit this article to Wikipedia.
Metaprogramming is the writing of a program that writes other programs. Metaprogramming is not limited to o-o languages, but it seems that about half of the languages that support metaprogramming are object oriented. Consider how metaprogramming is done in the various languages, and give an example of writing a particular metaprogram in at least two of these languages to illustrate the differences. Since the Wikipedia article on metaprogramming is not very detailed, if you do a good job, you could submit this article to Wikipedia.


= What is Metaprogramming? =
== What is Metaprogramming? ==
'''Meta-''' (from Greek: μετά = "after", "beyond", "with", "adjacent", "self"), is a prefix used in English to indicate a concept which is an abstraction from another concept, used to complete or add to the latter. Source: Wikipedia
'''Meta-''' (from Greek: μετά = "after", "beyond", "with", "adjacent", "self"), is a prefix used in English to indicate a concept which is an abstraction from another concept, used to complete or add to the latter. Source: Wikipedia


''Metaprogramming is the writing of computer programs that write or manipulate other programs (or themselves) as their data, or that do part of the work at compile time that would otherwise be done at runtime. 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, or it gives programs greater flexibility to efficiently handle new situations without recompilation."
''Metaprogramming is the writing of computer programs that write or manipulate other programs (or themselves) as their data, or that do part of the work at compile time that would otherwise be done at runtime. 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, or it gives programs greater flexibility to efficiently handle new situations without recompilation."


= Examples of Metaprogramming =


== Examples of Metaprogramming ==
Examples of Metaprograms
*the compiler or interpreter of your favourite language
*Lex and Yacc
*CORBA's IDL compiler
*a Quine (a program that, when executed, prints a copy of its own source code -- see QuineProgram for examples)
*Programs to generate EJB code and XML from database metadata
*Macros are nothing but special cases of metaprograms, as they generate the actual code during macro evalution.


= Metaprogramming style in various languages =


== A metaprogram in Ruby ==


== A metaprogram in JAVA ==
== Metaprogramming style in various languages ==


=== A metaprogram in Ruby ===


== Illustrating the differences ==
=== A metaprogram in JAVA ===
 
 
=== Illustrating the differences ===
 
 
== Conclusion ==
 
== Appendix ==
Metalanguage: The language in which the metaprogram is written
Object language: The language of the programs that are manipulated
reflection or reflexivity: The ability of a programming language to be its own metalanguage
 
== References ==

Revision as of 04:18, 8 October 2009

Metaprogramming is the writing of a program that writes other programs. Metaprogramming is not limited to o-o languages, but it seems that about half of the languages that support metaprogramming are object oriented. Consider how metaprogramming is done in the various languages, and give an example of writing a particular metaprogram in at least two of these languages to illustrate the differences. Since the Wikipedia article on metaprogramming is not very detailed, if you do a good job, you could submit this article to Wikipedia.

What is Metaprogramming?

Meta- (from Greek: μετά = "after", "beyond", "with", "adjacent", "self"), is a prefix used in English to indicate a concept which is an abstraction from another concept, used to complete or add to the latter. Source: Wikipedia

Metaprogramming is the writing of computer programs that write or manipulate other programs (or themselves) as their data, or that do part of the work at compile time that would otherwise be done at runtime. 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, or it gives programs greater flexibility to efficiently handle new situations without recompilation."


Examples of Metaprogramming

Examples of Metaprograms

  • the compiler or interpreter of your favourite language
  • Lex and Yacc
  • CORBA's IDL compiler
  • a Quine (a program that, when executed, prints a copy of its own source code -- see QuineProgram for examples)
  • Programs to generate EJB code and XML from database metadata
  • Macros are nothing but special cases of metaprograms, as they generate the actual code during macro evalution.


Metaprogramming style in various languages

A metaprogram in Ruby

A metaprogram in JAVA

Illustrating the differences

Conclusion

Appendix

Metalanguage: The language in which the metaprogram is written Object language: The language of the programs that are manipulated reflection or reflexivity: The ability of a programming language to be its own metalanguage

References