<story><title>Automatic programming: write code that writes code</title><url>http://programmers.stackexchange.com/questions/103840/automatic-programming-write-code-that-writes-code</url><text></text></story><parent_chain></parent_chain><comment><author>colomon</author><text>I use straightforward techniques to automatically generate about a third of my C++ code (108,000 lines of code or so). When I&apos;m writing code, I keep an eye out for things that I&apos;m doing which are very repetitious.&lt;p&gt;For instance, I have nine libraries which do the same things for different file formats.  Ideally I&apos;d like the main API for each library to be as similar as possible.  So the files which implement the API are generated by a Perl template script.  Each library implements a couple of core functions; then the code generated from the template calls those functions in various ways.  So I implement LowLevelStepImport; the automatically generated code uses that to implement ArrayStepImport, ClassStepImport, CCallableStepImport, etc.  Then I implement LowLevelJTImport, and it implements ArrayJtImport, ClassJTImport, CCallableStepImport, etc.&lt;p&gt;There are lots of advantages to this.  It means I don&apos;t have to write a bunch of boring code which is essentially the same.  It makes it very easy to keep the APIs consistent across all the libraries.  If I need to change part of the API, I just change the template and all the libraries update automatically.  And if I add a new library, it is trivial to get it added to the collection.</text></comment>
<story><title>Automatic programming: write code that writes code</title><url>http://programmers.stackexchange.com/questions/103840/automatic-programming-write-code-that-writes-code</url><text></text></story><parent_chain></parent_chain><comment><author>espeed</author><text>See Philip Greenspun&apos;s problem set 4 from MIT course 6.916: Software Engineering of Innovative Web Services (&lt;a href=&quot;http://philip.greenspun.com/teaching/psets/ps4/ps4.adp&quot; rel=&quot;nofollow&quot;&gt;http://philip.greenspun.com/teaching/psets/ps4/ps4.adp&lt;/a&gt;).&lt;p&gt;Its objective says, &quot;Teach students the virtues of metadata. More specifically, they learn how to formally represent the requirements of a Web service and then build a computer program to generate the computer programs that implement that service.&quot;&lt;p&gt;This is one of the problem sets potential ArsDigita (&lt;a href=&quot;http://en.wikipedia.org/wiki/ArsDigita&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/ArsDigita&lt;/a&gt;) recruits were required to solve during the first bubble.&lt;p&gt;UPDATE: Philip explains automatic code generation here (&lt;a href=&quot;http://philip.greenspun.com/seia/metadata&quot; rel=&quot;nofollow&quot;&gt;http://philip.greenspun.com/seia/metadata&lt;/a&gt;), and the &quot;SQL for Web Nerds&quot; book he references in the pset has been moved to (&lt;a href=&quot;http://philip.greenspun.com/sql/&quot; rel=&quot;nofollow&quot;&gt;http://philip.greenspun.com/sql/&lt;/a&gt;).</text></comment>