<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mlwiles</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mlwiles"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Mlwiles"/>
	<updated>2026-08-21T00:50:42Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39092</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39092"/>
		<updated>2010-10-21T01:54:58Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Putting it all together */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
*Interpreted Languages&lt;br /&gt;
Most dynamic languages are interpreted, not compiled. The basic idea here is for the code to be interpreted at run-time, allows generic objects to dynamically interact with each other.  This interaction in itself is potentially manipulating the behavior of the program as it is executing.  Generic objects are not the only uniqueness of an interpreted language, the 'eval' statement is something else to consider.  The ability to evaluate an expression via the 'eval' statement allows for the program to redefine functions at run-time.  These two capabilities for dynamic languages have become immensely valuable to programmers.&lt;br /&gt;
 &lt;br /&gt;
*Dynamic methods&lt;br /&gt;
These types of methods are very flexible.  The program have have an object created from a class, then you can add additional methods to the instance of that class.  Therefore manipulating the program at run time by allowing for only this instance of the object to have additional methods.  Not to be confused with extending classes or adding additional methods to classes.&lt;br /&gt;
&lt;br /&gt;
*Singletons classes&lt;br /&gt;
Singleton classes should not be mistake for the Singleton design pattern.  These types of classes available in some dynamic languages allow for [http://en.wikipedia.org/wiki/Dynamic_dispatch dynamic dispatching].  An common technique often used on singleton classes is to add dynamic methods to the instance.&lt;br /&gt;
&lt;br /&gt;
*&amp;quot;Everything is an object&amp;quot;&lt;br /&gt;
Many languages a 'weak-typed' which means that potentially anything can be anything else.  The most obvious way to have this behavior is by making everything an object.  What historically are considered primitive data types now are all considered objects (e.g. string, integers, etc).  In some of these languages even functions and procedures are considered objects.  In some languages such as Ruby, even classes are Objects since they (as well as everything else) inherits from Object.  Since classes can be used to define, extend, or redefine other classes (often referred to as a [http://en.wikipedia.org/wiki/Metaclass metaclass]) this is also potentially changing the behavior of the original program.&lt;br /&gt;
&lt;br /&gt;
Some other traits of some common dynamic languages worth mentioning are: the use of method_missing, [http://en.wikipedia.org/wiki/Introspection introspection], [http://en.wikipedia.org/wiki/Lazy_loading lazy loading], [http://en.wikipedia.org/wiki/Declarative_programming declarative code], extensible type system, and method aliasing.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Websites:&lt;br /&gt;
*Wikipedia.org: Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
*c2.com Wiki: Metaprogramming article, http://c2.com/cgi/wiki?MetaProgramming&lt;br /&gt;
*Code generation Vs Metaprogramming, http://www.qcodo.com/wiki/article/background/metaprogramming&lt;br /&gt;
*Solenoid, The first metaprogramming framework for [http://exist-db.org eXist-db], http://solenoid.schematronic.org&lt;br /&gt;
*The Art of Enterprise Metaprogramming, http://www.ibm.com/developerworks/linux/library/l-metaprog3/?ca=dgr-wikiaMetaprogP3&lt;br /&gt;
*Wikipedia.org: Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
*Eclipse.org, Dynamic Languages Toolkit, http://www.eclipse.org/dltk/ &lt;br /&gt;
*Wikipedia.org: Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
&lt;br /&gt;
Books/Articles:&lt;br /&gt;
*Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
*Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39090</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39090"/>
		<updated>2010-10-21T01:53:38Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Putting it all together */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
*Interpreted Languages&lt;br /&gt;
Most dynamic languages are interpreted, not compiled. The basic idea here is for the code to be interpreted at run-time, allows generic objects to dynamically interact with each other.  This interaction in itself is potentially manipulating the behavior of the program as it is executing.  Generic objects are not the only uniqueness of an interpreted language, the 'eval' statement is something else to consider.  The ability to evaluate an expression via the 'eval' statement allows for the program to redefine functions at run-time.  These two capabilities for dynamic languages have become immensely valuable to programmers.&lt;br /&gt;
 &lt;br /&gt;
*Dynamic methods&lt;br /&gt;
These types of methods are very flexible.  The program have have an object created from a class, then you can add additional methods to the instance of that class.  Therefore manipulating the program at run time by allowing for only this instance of the object to have additional methods.  Not to be confused with extending classes or adding additional methods to classes.&lt;br /&gt;
&lt;br /&gt;
*Singletons classes&lt;br /&gt;
Singleton classes should not be mistake for the Singleton design pattern.  These types of classes available in some dynamic languages allow for [http://en.wikipedia.org/wiki/Dynamic_dispatch dynamic dispatching].  An common technique often used on singleton classes is to add dynamic methods to the instance.&lt;br /&gt;
&lt;br /&gt;
*&amp;quot;Everything is an object&amp;quot;&lt;br /&gt;
Many languages a 'weak-typed' which means that potentially anything can be anything else.  The most obvious way to have this behavior is by making everything an object.  What historically are considered primitive data types now are all considered objects (e.g. string, integers, etc).  In some of these languages even functions and procedures are considered objects.  In some languages such as Ruby, even classes are Objects since they (as well as everything else) inherits from Object.  Since classes can be used to define, extend, or redefine other classes (often referred to as a [http://en.wikipedia.org/wiki/Metaclass Metaclass]) this is also potentially changing the behavior of the original program.&lt;br /&gt;
&lt;br /&gt;
Some other traits of some common dynamic languages worth mentioning are: the use of method_missing, [http://en.wikipedia.org/wiki/Introspection introspection], [http://en.wikipedia.org/wiki/Lazy_loading lazy loading], declarative code, extensible type system, and method aliasing&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Websites:&lt;br /&gt;
*Wikipedia.org: Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
*c2.com Wiki: Metaprogramming article, http://c2.com/cgi/wiki?MetaProgramming&lt;br /&gt;
*Code generation Vs Metaprogramming, http://www.qcodo.com/wiki/article/background/metaprogramming&lt;br /&gt;
*Solenoid, The first metaprogramming framework for [http://exist-db.org eXist-db], http://solenoid.schematronic.org&lt;br /&gt;
*The Art of Enterprise Metaprogramming, http://www.ibm.com/developerworks/linux/library/l-metaprog3/?ca=dgr-wikiaMetaprogP3&lt;br /&gt;
*Wikipedia.org: Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
*Eclipse.org, Dynamic Languages Toolkit, http://www.eclipse.org/dltk/ &lt;br /&gt;
*Wikipedia.org: Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
&lt;br /&gt;
Books/Articles:&lt;br /&gt;
*Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
*Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39089</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39089"/>
		<updated>2010-10-21T01:50:35Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Putting it all together */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
*Interpreted Languages&lt;br /&gt;
Most dynamic languages are interpreted, not compiled. The basic idea here is for the code to be interpreted at run-time, allows generic objects to dynamically interact with each other.  This interaction in itself is potentially manipulating the behavior of the program as it is executing.  Generic objects are not the only uniqueness of an interpreted language, the 'eval' statement is something else to consider.  The ability to evaluate an expression via the 'eval' statement allows for the program to redefine functions at run-time.  These two capabilities for dynamic languages have become immensely valuable to programmers.&lt;br /&gt;
 &lt;br /&gt;
*Dynamic methods&lt;br /&gt;
These types of methods are very flexible.  The program have have an object created from a class, then you can add additional methods to the instance of that class.  Therefore manipulating the program at run time by allowing for only this instance of the object to have additional methods.  Not to be confused with extending classes or adding additional methods to classes.&lt;br /&gt;
&lt;br /&gt;
*Singletons classes&lt;br /&gt;
Singleton classes should not be mistake for the Singleton design pattern.  These types of classes available in some dynamic languages allow for [http://en.wikipedia.org/wiki/Dynamic_dispatch dynamic dispatching].  An common technique often used on singleton classes is to add dynamic methods to the instance.&lt;br /&gt;
&lt;br /&gt;
*Method_missing&lt;br /&gt;
&lt;br /&gt;
*Introspection&lt;br /&gt;
&lt;br /&gt;
*Lazy loading&lt;br /&gt;
&lt;br /&gt;
*Declarative code&lt;br /&gt;
&lt;br /&gt;
*Extensible type system&lt;br /&gt;
&lt;br /&gt;
*Method aliasing&lt;br /&gt;
&lt;br /&gt;
*Evaluation techniques (evaluation code at runtime, in instance and scope classes)&lt;br /&gt;
&lt;br /&gt;
*&amp;quot;Everything is an object&amp;quot;&lt;br /&gt;
Many languages a 'weak-typed' which means that potentially anything can be anything else.  The most obvious way to have this behavior is by making everything an object.  What historically are considered primitive data types now are all considered objects (e.g. string, integers, etc).  In some of these languages even functions and procedures are considered objects.  In some languages such as Ruby, even classes are Objects since they (as well as everything else) inherits from Object.  Since classes can be used to define, extend, or redefine other classes (often referred to as a [http://en.wikipedia.org/wiki/Metaclass Metaclass]) this is also potentially changing the behavior of the original program.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Websites:&lt;br /&gt;
*Wikipedia.org: Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
*c2.com Wiki: Metaprogramming article, http://c2.com/cgi/wiki?MetaProgramming&lt;br /&gt;
*Code generation Vs Metaprogramming, http://www.qcodo.com/wiki/article/background/metaprogramming&lt;br /&gt;
*Solenoid, The first metaprogramming framework for [http://exist-db.org eXist-db], http://solenoid.schematronic.org&lt;br /&gt;
*The Art of Enterprise Metaprogramming, http://www.ibm.com/developerworks/linux/library/l-metaprog3/?ca=dgr-wikiaMetaprogP3&lt;br /&gt;
*Wikipedia.org: Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
*Eclipse.org, Dynamic Languages Toolkit, http://www.eclipse.org/dltk/ &lt;br /&gt;
*Wikipedia.org: Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
&lt;br /&gt;
Books/Articles:&lt;br /&gt;
*Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
*Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39072</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39072"/>
		<updated>2010-10-21T01:29:34Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
*Interpreted Languages&lt;br /&gt;
Most dynamic languages are interpreted, not compiled. The basic idea here is for the code to be interpreted at run-time, allows generic objects to dynamically interact with each other.  This interaction in itself is potentially manipulating the behavior of the program as it is executing.  Generic objects are not the only uniqueness of an interpreted language, the 'eval' statement is something else to consider.  The ability to evaluate an expression via the 'eval' statement allows for the program to redefine functions at run-time.  These two capabilities for dynamic languages have become immensely valuable to programmers.&lt;br /&gt;
 &lt;br /&gt;
*Dynamic methods&lt;br /&gt;
&lt;br /&gt;
*Singletons and Open classes&lt;br /&gt;
&lt;br /&gt;
*Method_missing&lt;br /&gt;
&lt;br /&gt;
*Introspection&lt;br /&gt;
&lt;br /&gt;
*Lazy loading&lt;br /&gt;
&lt;br /&gt;
*Declarative code&lt;br /&gt;
&lt;br /&gt;
*Extensible type system&lt;br /&gt;
&lt;br /&gt;
*Method aliasing&lt;br /&gt;
&lt;br /&gt;
*Evaluation techniques (evaluation code at runtime, in instance and scope classes)&lt;br /&gt;
&lt;br /&gt;
*&amp;quot;Everything is an object&amp;quot;&lt;br /&gt;
Many languages a 'weak-typed' which means that potentially anything can be anything else.  The most obvious way to have this behavior is by making everything an object.  What historically are considered primitive data types now are all considered objects (e.g. string, integers, etc).  In some of these languages even functions and procedures are considered objects.  In some languages such as Ruby, even classes are Objects since they (as well as everything else) inherits from Object.  Since classes can be used to define, extend, or redefine other classes (often referred to as a [http://en.wikipedia.org/wiki/Metaclass Metaclass]) this is also potentially changing the behavior of the original program.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Websites:&lt;br /&gt;
*Wikipedia.org: Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
*c2.com Wiki: Metaprogramming article, http://c2.com/cgi/wiki?MetaProgramming&lt;br /&gt;
*Code generation Vs Metaprogramming, http://www.qcodo.com/wiki/article/background/metaprogramming&lt;br /&gt;
*Solenoid, The first metaprogramming framework for [http://exist-db.org eXist-db], http://solenoid.schematronic.org&lt;br /&gt;
*The Art of Enterprise Metaprogramming, http://www.ibm.com/developerworks/linux/library/l-metaprog3/?ca=dgr-wikiaMetaprogP3&lt;br /&gt;
*Wikipedia.org: Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
*Eclipse.org, Dynamic Languages Toolkit, http://www.eclipse.org/dltk/ &lt;br /&gt;
*Wikipedia.org: Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
&lt;br /&gt;
Books/Articles:&lt;br /&gt;
*Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
*Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39071</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39071"/>
		<updated>2010-10-21T01:29:03Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
*Interpreted Languages&lt;br /&gt;
Most dynamic languages are interpreted, not compiled. The basic idea here is for the code to be interpreted at run-time, allows generic objects to dynamically interact with each other.  This interaction in itself is potentially manipulating the behavior of the program as it is executing.  Generic objects are not the only uniqueness of an interpreted language, the 'eval' statement is something else to consider.  The ability to evaluate an expression via the 'eval' statement allows for the program to redefine functions at run-time.  These two capabilities for dynamic languages have become immensely valuable to programmers.&lt;br /&gt;
 &lt;br /&gt;
*Dynamic methods&lt;br /&gt;
&lt;br /&gt;
*Singletons and Open classes&lt;br /&gt;
&lt;br /&gt;
*Method_missing&lt;br /&gt;
&lt;br /&gt;
*Introspection&lt;br /&gt;
&lt;br /&gt;
*Lazy loading&lt;br /&gt;
&lt;br /&gt;
*Declarative code&lt;br /&gt;
&lt;br /&gt;
*Extensible type system&lt;br /&gt;
&lt;br /&gt;
*Method aliasing&lt;br /&gt;
&lt;br /&gt;
*Evaluation techniques (evaluation code at runtime, in instance and scope classes)&lt;br /&gt;
&lt;br /&gt;
*&amp;quot;Everything is an object&amp;quot;&lt;br /&gt;
Many languages a 'weak-typed' which means that potentially anything can be anything else.  The most obvious way to have this behavior is by making everything an object.  What historically are considered primitive data types now are all considered objects (e.g. string, integers, etc).  In some of these languages even functions and procedures are considered objects.  In some languages such as Ruby, even classes are Objects since they (as well as everything else) inherits from Object.  Since classes can be used to define, extend, or redefine other classes (often referred to as a [http://en.wikipedia.org/wiki/Metaclass Metaclass]) this is also potentially changing the behavior of the original program.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*Wikipedia.org: Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
*c2.com Wiki: Metaprogramming article, http://c2.com/cgi/wiki?MetaProgramming&lt;br /&gt;
*Code generation Vs Metaprogramming, http://www.qcodo.com/wiki/article/background/metaprogramming&lt;br /&gt;
*Solenoid, The first metaprogramming framework for [http://exist-db.org eXist-db], http://solenoid.schematronic.org&lt;br /&gt;
*The Art of Enterprise Metaprogramming, http://www.ibm.com/developerworks/linux/library/l-metaprog3/?ca=dgr-wikiaMetaprogP3&lt;br /&gt;
*Wikipedia.org: Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
*Eclipse.org, Dynamic Languages Toolkit, http://www.eclipse.org/dltk/ &lt;br /&gt;
*Wikipedia.org: Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
*Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
*Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39063</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39063"/>
		<updated>2010-10-21T01:23:49Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Putting it all together */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
*Interpreted Languages&lt;br /&gt;
Most dynamic languages are interpreted, not compiled. The basic idea here is for the code to be interpreted at run-time, allows generic objects to dynamically interact with each other.  This interaction in itself is potentially manipulating the behavior of the program as it is executing.  Generic objects are not the only uniqueness of an interpreted language, the 'eval' statement is something else to consider.  The ability to evaluate an expression via the 'eval' statement allows for the program to redefine functions at run-time.  These two capabilities for dynamic languages have become immensely valuable to programmers.&lt;br /&gt;
 &lt;br /&gt;
*Dynamic methods&lt;br /&gt;
&lt;br /&gt;
*Singletons and Open classes&lt;br /&gt;
&lt;br /&gt;
*Method_missing&lt;br /&gt;
&lt;br /&gt;
*Introspection&lt;br /&gt;
&lt;br /&gt;
*Lazy loading&lt;br /&gt;
&lt;br /&gt;
*Declarative code&lt;br /&gt;
&lt;br /&gt;
*Extensible type system&lt;br /&gt;
&lt;br /&gt;
*Method aliasing&lt;br /&gt;
&lt;br /&gt;
*Evaluation techniques (evaluation code at runtime, in instance and scope classes)&lt;br /&gt;
&lt;br /&gt;
*&amp;quot;Everything is an object&amp;quot;&lt;br /&gt;
Many languages a 'weak-typed' which means that potentially anything can be anything else.  The most obvious way to have this behavior is by making everything an object.  What historically are considered primitive data types now are all considered objects (e.g. string, integers, etc).  In some of these languages even functions and procedures are considered objects.  In some languages such as Ruby, even classes are Objects since they (as well as everything else) inherits from Object.  Since classes can be used to define, extend, or redefine other classes (often referred to as a [http://en.wikipedia.org/wiki/Metaclass Metaclass]) this is also potentially changing the behavior of the original program.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
#Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39056</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39056"/>
		<updated>2010-10-21T01:20:43Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Putting it all together */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
#Interpreted Languages&lt;br /&gt;
Most dynamic languages are interpreted, not compiled. The basic idea here is for the code to be interpreted at run-time, allows generic objects to dynamically interact with each other.  This interaction in itself is potentially manipulating the behavior of the program as it is executing.  Generic objects are not the only uniqueness of an interpreted language, the 'eval' statement is something else to consider.  The ability to evaluate an expression via the 'eval' statement allows for the program to redefine functions at run-time.  These two capabilities for dynamic languages have become immensely valuable to programmers.&lt;br /&gt;
 &lt;br /&gt;
#&amp;quot;Everything is an object&amp;quot;&lt;br /&gt;
Many languages a 'weak-typed' which means that potentially anything can be anything else.  The most obvious way to have this behavior is by making everything an object.  What historically are considered primitive data types now are all considered objects (e.g. string, integers, etc).  In some of these languages even functions and procedures are considered objects.  In some languages such as Ruby, even classes are Objects since they (as well as everything else) inherits from Object.  Since classes can be used to define, extend, or redefine other classes (often referred to as a [http://en.wikipedia.org/wiki/Metaclass Metaclass]) this is also potentially changing the behavior of the original program.&lt;br /&gt;
&lt;br /&gt;
#extensible type system&lt;br /&gt;
#dynamic methods&lt;br /&gt;
#Singletons and Open classes&lt;br /&gt;
#method_missing&lt;br /&gt;
#introspection&lt;br /&gt;
#lazy loading&lt;br /&gt;
#declarative code&lt;br /&gt;
#method aliasing&lt;br /&gt;
#evaluation techniques (evaluation code at runtime, in instance and scope classes)&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
#Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39040</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=39040"/>
		<updated>2010-10-21T01:08:13Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Putting it all together */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
#Interpreted Languages&lt;br /&gt;
Most dynamic languages are interpreted, not compiled. The basic idea here is for the code to be interpreted at run-time, allows generic objects to dynamically interact with each other.  This interaction in itself is potentially manipulating the behavior of the program as it is executing.  Generic objects are not the only uniqueness of an interpreted language, the eval statement is something else to consider.  The ability to evaluate an expression via the eval statement allows for the program to redefine functions at runtime.  These two capabilities for dynamic languages have become immensely valuable to programmers.&lt;br /&gt;
 &lt;br /&gt;
#everything is an object&lt;br /&gt;
#extensible type system&lt;br /&gt;
#dynamic methods&lt;br /&gt;
#singletons and open classes&lt;br /&gt;
#method_missing&lt;br /&gt;
#introspection&lt;br /&gt;
#lazy loading&lt;br /&gt;
#declarative code&lt;br /&gt;
#method aliasing&lt;br /&gt;
#evaluation techniques (evaluation code at runtime, in instance and scope classes)&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
#Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38848</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38848"/>
		<updated>2010-10-20T05:02:00Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Putting it all together */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
#interpreted, not compiled - Compilation of dynamic languages is very difficult. There is mostly the eval statement to consider, which is used extensively in Javascript and Ruby.  we still need a run-time interpreter to handle evals. &lt;br /&gt;
#everything is an object&lt;br /&gt;
#extensible type system&lt;br /&gt;
#dynamic methods&lt;br /&gt;
#singletons and open classes&lt;br /&gt;
#method_missing&lt;br /&gt;
#introspection&lt;br /&gt;
#lazy loading&lt;br /&gt;
#declarative code&lt;br /&gt;
#method aliasing&lt;br /&gt;
#evaluation techniques (evaluation code at runtime, in instance and scope classes)&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
#Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38846</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38846"/>
		<updated>2010-10-20T04:52:41Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Putting it all together */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
Natural fit:&lt;br /&gt;
#interpreted, not compiled - Compilation of dynamic languages is very difficult. There is mostly the eval statement to consider, which is used extensively in Javascript and Ruby.  we still need a run-time interpreter to handle evals. &lt;br /&gt;
#everything is an object&lt;br /&gt;
#extensible type system&lt;br /&gt;
#dynamic methods&lt;br /&gt;
#singletons and open classes&lt;br /&gt;
#method_missing&lt;br /&gt;
#introspection&lt;br /&gt;
#lazy loading&lt;br /&gt;
#declarative code&lt;br /&gt;
#method aliasing&lt;br /&gt;
#evaluation techniques (evaluation code at runtime, in instance and scope classes)&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
#Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38844</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38844"/>
		<updated>2010-10-20T04:39:07Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Putting it all together */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
Natural fit:&lt;br /&gt;
#interpreted, not compiled&lt;br /&gt;
#everything is an object&lt;br /&gt;
#extensible type system&lt;br /&gt;
#dynamic methods&lt;br /&gt;
#singletons and open classes&lt;br /&gt;
#method_missing&lt;br /&gt;
#introspection&lt;br /&gt;
#lazy loading&lt;br /&gt;
#declarative code&lt;br /&gt;
#method aliasing&lt;br /&gt;
#evaluation techniques (evaluation code at runtime, in instance and scope classes)&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
#Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38843</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38843"/>
		<updated>2010-10-20T04:36:28Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Putting it all together */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
Natural fit:&lt;br /&gt;
interpreted, not compiled&lt;br /&gt;
everything is an object&lt;br /&gt;
extensible type system&lt;br /&gt;
dynamic methods&lt;br /&gt;
singletons and open classes&lt;br /&gt;
method_missing&lt;br /&gt;
introspection&lt;br /&gt;
lazy loading&lt;br /&gt;
declarative code&lt;br /&gt;
method aliasing&lt;br /&gt;
evaluation techniques (evaluation code at runtime, in instance and scope classes)&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
#Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38607</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38607"/>
		<updated>2010-10-18T19:30:38Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
#Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38604</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38604"/>
		<updated>2010-10-18T17:05:03Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Metaprogramming in some Dynamic Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.  Each of the following will take a class (SomeClassThatAlreadyExists) that was already defined and add an new method (some_method) to it.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
#Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38603</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38603"/>
		<updated>2010-10-18T17:03:54Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Metaprogramming in some Dynamic Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle one of the other characteristics of metaprogramming:  Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
#Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38602</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38602"/>
		<updated>2010-10-18T17:02:50Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Dynamic Typed Programming Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first usage.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
#Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38601</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38601"/>
		<updated>2010-10-18T16:40:13Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;br /&gt;
#Madsen, O.L.; Nogaard, C.; , &amp;quot;An object-oriented metaprogramming system,&amp;quot; System Sciences, 1988. Vol.II. Software Track, Proceedings of the Twenty-First Annual Hawaii International Conference on , vol.2, no., pp.406-415, 5-8 Jan 1988, http://ieeexplore.ieee.org.www.lib.ncsu.edu:2048/stamp/stamp.jsp?tp=&amp;amp;arnumber=11831&amp;amp;isnumber=538&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38600</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38600"/>
		<updated>2010-10-18T16:38:55Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. DOI= http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38599</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38599"/>
		<updated>2010-10-18T16:38:41Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#Wikipedia.org, Metaprogramming, http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming&lt;br /&gt;
#Wikipedia.org, Dynamic Programming Languages, http://en.wikipedia.org/wiki/Dynamic_programming_language&lt;br /&gt;
#Wikipedia.org, Command Pattern, http://en.wikipedia.org/wiki/Command_pattern &lt;br /&gt;
#Wikipedia.org, Application Programming Interfaces (API's), http://en.wikipedia.org/wiki/Application_programming_interface&lt;br /&gt;
#Wikipedia.org, Static-Analysis, http://en.wikipedia.org/wiki/Static_analysis&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. DOI= http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38598</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38598"/>
		<updated>2010-10-18T16:36:50Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Application_programming_interface Application Programming Interfaces (API's)]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Static_analysis Static-Analysis]&lt;br /&gt;
#Tratt, L. 2005. Compile-time meta-programming in a dynamically typed OO language. In Proceedings of the 2005 Symposium on Dynamic Languages  (San Diego, California, October 18 - 18, 2005). DLS '05. ACM, New York, NY, 49-63. DOI= http://doi.acm.org.www.lib.ncsu.edu:2048/10.1145/1146841.1146846&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38597</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38597"/>
		<updated>2010-10-18T16:27:35Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are increasingly recognized for playing a major role in software development, specifically for quick prototyping because of the forgiveness of the languages letting requirements evolve.  These languages are historically looked at as scripting languages that are inexpensive and not scalable.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Application_programming_interface Application Programming Interfaces (API's)]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Static_analysis Static-Analysis]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38596</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38596"/>
		<updated>2010-10-18T16:20:54Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* What is Metaprogramming? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations and plan for growth.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.  Ideally metaprogramming has one main objective, to allow for new features.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are best known for quick prototyping because of the forgiveness of the languages.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Application_programming_interface Application Programming Interfaces (API's)]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Static_analysis Static-Analysis]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38595</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38595"/>
		<updated>2010-10-18T15:35:28Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are best known for quick prototyping because of the forgiveness of the languages.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Application_programming_interface Application Programming Interfaces (API's)]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Static_analysis Static-Analysis]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38594</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38594"/>
		<updated>2010-10-18T15:32:22Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Metaprogramming in some Dynamic Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are best known for quick prototyping because of the forgiveness of the languages.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38593</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38593"/>
		<updated>2010-10-18T15:32:10Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* What’s Next? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are best known for quick prototyping because of the forgiveness of the languages.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at [http://en.wikipedia.org/wiki/Static_analysis static-analysis] tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38592</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38592"/>
		<updated>2010-10-18T15:25:28Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Dynamic languages are best known for quick prototyping because of the forgiveness of the languages.  Allowing for these types of behavior comes at a price.  The price is the potential for poor performance since the code is runtime optimized.  Another downfall is that rapid development is great but the flexibility allowed between type conversions means that there is a higher probability for runtime errors.  While understanding these limitation and accepting the risks, these languages can be very powerful specifically in the area of Metaprogramming.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38585</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38585"/>
		<updated>2010-10-18T15:16:25Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Example of Metaprogramming */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   f = open('outputfile.py', 'w')       // Open the file for writing&lt;br /&gt;
   f.write('#!/usr/bin/python \n')&lt;br /&gt;
   for i in range(1, 100):&lt;br /&gt;
      f.write('print' + i + '\n')       // Write the string to a file&lt;br /&gt;
   f.closed                             // Close the file &lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   f = fopen('outputfile.js', 3);       // Open the file for writing&lt;br /&gt;
   if(f!=-1) {                          // If the file has been successfully opened&lt;br /&gt;
      for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
         str = 'document.write' + i;&lt;br /&gt;
         fwrite(f, str);                // Write the string to a file&lt;br /&gt;
      }&lt;br /&gt;
      fclose(f);                        // Close the file &lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
===Ruby===&lt;br /&gt;
   f = File.open(outputfile.rb, 'w')    // Open the file for writing&lt;br /&gt;
   1.upto 100 do |i|&lt;br /&gt;
      f.write(&amp;quot;puts #{i}&amp;quot;)              // Write the string to a file&lt;br /&gt;
   end&lt;br /&gt;
   f.close                              // Close the file&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38583</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38583"/>
		<updated>2010-10-18T15:07:14Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* JavaScript */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
  f = open('outputfile.py', 'w')&lt;br /&gt;
  f.write('#!/usr/bin/python \n')&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     f.write('print' + i + '\n')&lt;br /&gt;
  f.closed&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   fh = fopen('c:\\outputfile.js', 3);&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38582</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38582"/>
		<updated>2010-10-18T15:05:54Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Python */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
  f = open('outputfile.py', 'w')&lt;br /&gt;
  f.write('#!/usr/bin/python \n')&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     f.write('print' + i + '\n')&lt;br /&gt;
  f.closed&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38576</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38576"/>
		<updated>2010-10-18T03:37:24Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Metaprogramming in some Dynamic Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
We have already seen how some languages can be used for programs to write programs, now lets examine how they handle some of the other characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38575</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38575"/>
		<updated>2010-10-18T03:24:51Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Metaprogramming in some Dynamic Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
All of the following languages contains these features:&lt;br /&gt;
#Variables are not required to declared &lt;br /&gt;
#Assignments bind names to objects (of any type)&lt;br /&gt;
#Variables can be assigned to a different object type later in code&lt;br /&gt;
&lt;br /&gt;
Lets examine how the following languages handle the characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method(params)&lt;br /&gt;
         print &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
      document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
   class SomeClassThatAlreadyExists&lt;br /&gt;
      def some_method&lt;br /&gt;
         puts &amp;quot;some code&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38574</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38574"/>
		<updated>2010-10-18T03:24:11Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Metaprogramming in some Dynamic Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
All of the following languages contains these features:&lt;br /&gt;
#Variables are not required to declared &lt;br /&gt;
#Assignments bind names to objects (of any type)&lt;br /&gt;
#Variables can be assigned to a different object type later in code&lt;br /&gt;
&lt;br /&gt;
Lets examine how the following languages handle the characteristics of metaprogramming:&lt;br /&gt;
&lt;br /&gt;
Manipulate itself at runtime.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
class SomeClassThatAlreadyExists&lt;br /&gt;
    def some_method(params)&lt;br /&gt;
        print &amp;quot;some code&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
SomeClassThatAlreadyExists.prototype.some_method = function () {&lt;br /&gt;
  document.write(&amp;quot;some_code&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
class SomeClassThatAlreadyExists&lt;br /&gt;
  def some_method&lt;br /&gt;
    puts &amp;quot;some code&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38573</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38573"/>
		<updated>2010-10-18T03:18:00Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Metaprogramming in some Dynamic Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
All of the following languages contains these features:&lt;br /&gt;
#Variables are not required to declared &lt;br /&gt;
#Assignments bind names to objects (of any type)&lt;br /&gt;
#Variables can be assigned to a different object type later in code&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example explained earlier in the article, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38572</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38572"/>
		<updated>2010-10-18T02:57:06Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Example of Metaprogramming */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
All of the following languages contains these features:&lt;br /&gt;
#Variables are not required to declared &lt;br /&gt;
#Assignments bind names to objects (of any type)&lt;br /&gt;
#Variables can be assigned to a different object type later in code&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example explained earlier in the article, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38571</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38571"/>
		<updated>2010-10-18T02:14:51Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Metaprogramming in some Dynamic Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
All of the following languages contains these features:&lt;br /&gt;
#Variables are not required to declared &lt;br /&gt;
#Assignments bind names to objects (of any type)&lt;br /&gt;
#Variables can be assigned to a different object type later in code&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example explained earlier in the article, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38570</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38570"/>
		<updated>2010-10-18T02:10:16Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Python */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example explained earlier in the article, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
#Variables are not required to declared &lt;br /&gt;
#Assignments bind names to objects (of any type)&lt;br /&gt;
#Variables can be assigned to a different object type later in code&lt;br /&gt;
&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38569</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38569"/>
		<updated>2010-10-18T02:08:13Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Python */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example explained earlier in the article, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
#Variables are not required to declared &lt;br /&gt;
#Assignments bind names to objects (of any type)&lt;br /&gt;
#Variables can be assigned to a different object type later in code&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38568</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38568"/>
		<updated>2010-10-18T01:58:54Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Dynamic Typed Programming Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.  These characteristics are allowed because it is not the compiler that checks for proper variable declaration, these type errors will only occur at runtime and potentially the program will suddenly stop due to a crash.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example explained earlier in the article, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38567</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38567"/>
		<updated>2010-10-18T01:54:58Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Dynamic Typed Programming Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time instead each variable is bound to an object.  Another unique characteristic of dynamic languages is that while variables need to be defined before they can be used, you don’t need to define them at the beginning of the program, just define it before its first use it.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example explained earlier in the article, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38555</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38555"/>
		<updated>2010-10-18T00:57:32Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Metaprogramming in some languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some Dynamic Languages==&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example explained earlier in the article, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38554</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38554"/>
		<updated>2010-10-18T00:22:05Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Metaprogramming in some languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some languages==&lt;br /&gt;
&lt;br /&gt;
Taking the same pseudo code example explained earlier in the article, we can see how each of the following languages would incorporate this.&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38553</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38553"/>
		<updated>2010-10-18T00:21:08Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* JavaScript */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some languages==&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
   for (i=0;i&amp;lt;=100;i++) { &lt;br /&gt;
      document.write('document.write' + i);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38552</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38552"/>
		<updated>2010-10-18T00:17:41Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some languages==&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38551</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38551"/>
		<updated>2010-10-18T00:17:29Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Python */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some languages==&lt;br /&gt;
===Python===&lt;br /&gt;
  for i in range(1, 100):&lt;br /&gt;
     print 'print' + i&lt;br /&gt;
&lt;br /&gt;
===JavaScript===&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
which outputs&lt;br /&gt;
  puts 1&lt;br /&gt;
  puts 2&lt;br /&gt;
  ...&lt;br /&gt;
  puts 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38550</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38550"/>
		<updated>2010-10-18T00:15:52Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some languages==&lt;br /&gt;
===Python===&lt;br /&gt;
===JavaScript===&lt;br /&gt;
===Ruby===&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
which outputs&lt;br /&gt;
  puts 1&lt;br /&gt;
  puts 2&lt;br /&gt;
  ...&lt;br /&gt;
  puts 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38549</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38549"/>
		<updated>2010-10-18T00:15:34Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Example of Metaprogramming */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following (in pseudo code):&lt;br /&gt;
  for i = 1 to 100 &lt;br /&gt;
    print i&lt;br /&gt;
&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  for i = 1 to 100&lt;br /&gt;
    print &amp;quot;print i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
which outputs&lt;br /&gt;
  print 1&lt;br /&gt;
  print 2&lt;br /&gt;
  ...&lt;br /&gt;
  print 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some languages==&lt;br /&gt;
===Python===&lt;br /&gt;
===JavaScript===&lt;br /&gt;
===Ruby===&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38548</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38548"/>
		<updated>2010-10-18T00:13:12Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following:&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;#{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
which outputs&lt;br /&gt;
  puts 1&lt;br /&gt;
  puts 2&lt;br /&gt;
  ...&lt;br /&gt;
  puts 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Metaprogramming in some languages==&lt;br /&gt;
===Python===&lt;br /&gt;
===JavaScript===&lt;br /&gt;
===Ruby===&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38547</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38547"/>
		<updated>2010-10-18T00:02:46Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Dynamic Programming Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following:&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;#{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
which outputs&lt;br /&gt;
  puts 1&lt;br /&gt;
  puts 2&lt;br /&gt;
  ...&lt;br /&gt;
  puts 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Typed Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time.&lt;br /&gt;
&lt;br /&gt;
==Putting it all together==&lt;br /&gt;
How does metaprogamming work with dynamic typed languages?&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38546</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38546"/>
		<updated>2010-10-18T00:01:55Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* Dynamic Programming Languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following:&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;#{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
which outputs&lt;br /&gt;
  puts 1&lt;br /&gt;
  puts 2&lt;br /&gt;
  ...&lt;br /&gt;
  puts 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Programming Languages==&lt;br /&gt;
How does metaprogamming work with dynamic languages?  Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38545</id>
		<title>CSC/ECE 517 Fall 2010/ch4 4g km</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch4_4g_km&amp;diff=38545"/>
		<updated>2010-10-17T23:56:56Z</updated>

		<summary type="html">&lt;p&gt;Mlwiles: /* What is Metaprogramming? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Metaprogramming in dynamically typed languages'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 &lt;br /&gt;
==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4f previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Command_pattern command patterns] in static and dynamic languages provide separation of objects that request actions from the objects that ultimately perform actions.  This is done by encapsulating the request for an action on a specific object.  These command patterns are executed at runtime and simply hide the fact that another program is being called.  Another technique of encapsulating behavior is for the program to have changes initiated at compile time.  This type of design requires that the program not only can call another piece of code at runtime but it can build these calls at compile time via [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming].  In this article we take a closer look at metaprogramming in [http://en.wikipedia.org/wiki/Dynamic_programming_language dynamically typed languages].&lt;br /&gt;
&lt;br /&gt;
==What is Metaprogramming?==&lt;br /&gt;
Metaprogramming is the ability for a computer program to manipulate itself or other programs at the time of compilation as opposed to performing this manipulations at runtime.  This tends to allow for greater flexibility for a program to handle new situations.  Metaprogramming is ideal for several scenarios to include the use of [http://en.wikipedia.org/wiki/Application_programming_interface application programming interfaces (API's)], programs writing programs, and working with other programs outside of itself.  API's allow the run-time engine to be exposed externally where it normally would not be.  When a program writes another program that just means the running program dynamically outputs strings that can later be ran as en executed program.  And finally, working with other programs outside itself refers to the running program's ability to accept language descriptions that it can execute transformations of the outside language.&lt;br /&gt;
&lt;br /&gt;
==Example of Metaprogramming==&lt;br /&gt;
There is a classic example of use for metaprogramming that involves some form of writing a program that outputs some set of numbers in order but the trick is that it cannot be done in a loop.  For this example we will ask for a program that outputs the numbers from 1 to 100 without using any looping.  Ideally one would like to write the following:&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;#{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
which outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
however since a loop is not allowed, you could use the loop to write code that will write the code:&lt;br /&gt;
  1.upto 100 do |i|&lt;br /&gt;
    puts &amp;quot;puts #{i}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
which outputs&lt;br /&gt;
  puts 1&lt;br /&gt;
  puts 2&lt;br /&gt;
  ...&lt;br /&gt;
  puts 100&lt;br /&gt;
which then outputs &lt;br /&gt;
  1&lt;br /&gt;
  2 &lt;br /&gt;
  ...&lt;br /&gt;
  100&lt;br /&gt;
the elegance of this technique is that it is very easy to repeat or manipulate.&lt;br /&gt;
&lt;br /&gt;
==Dynamic Programming Languages==&lt;br /&gt;
Dynamic typed programming languages are often referred to as 'weak typed' languages since it is not required for the variables to bound to a particular type at compile time.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch4_4h next article for which the link does not exist yet], we will look at static-analysis tools for Ruby.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Metaprogramming Metaprogramming]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Dynamic_programming_language Dynamic Programming Languages]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Command_pattern Command Pattern]&lt;/div&gt;</summary>
		<author><name>Mlwiles</name></author>
	</entry>
</feed>