The Artima Developer Community
Sponsored Link

Heron-Centric: Ruminations of a Language Designer
Programmers Shouldn't Touch the Source
by Christopher Diggins
October 21, 2005
Summary
More and more programmers and researchers have been suggesting heresies along the lines of "programmers should only work with a view of source code, not the source itself".

Advertisement

Greg Wilson recently inspired me to think deeply about the issue of programmers only working with an abstraction of source code with his article Extensible Programming Systems for the 21st Century

Traditionally programmers work with source code of a language directly within a text editor. In most language there are numerous automated tools to help with writing and viewing the source, but in the end the programmer still works directly on the source code.

An idea that I have heard more than once is that an IDE should only present a specific view of the source code, while the real source is hidden behind the scenes in a more general format, like XML. If a source file was really an XML file at its base, and rarely directly edited by a programmer, it could have many advantages.

One of many advantages is that history tracking could be embedded in the XML source, without being in the fact of programmers all the time. When I first look at source code, I like to see the history of revisions, who did what when or why. If this is embedded in the source code as comments, I often strip it so that the code is easier for me to work with, and I know I am not the only one. If the editor only presents me with a view of the source it could be a simple matter of checking a property option to turn history viewing on or off.

Given the following program:

program answer {
  _main() {
    // the question of life, the universe and everything
    x = 15 + 3 * 9;
    // the answer to life, the universe and everything
    write(x);
  }
}
Here is an example of how an XML source-code might look:
<program name="answer">
  <function name="_main">
    <history>
      <modified>
        <author>Christoper Diggins</author>
        <date>10/21/2005</date>
        <license>BSD</license>
      </modified>
      <original>
        <author>unknown</author>
        <licence>Public Domain</licence>
        <url>http://www.somewhere.there</url>
      </original>
    </history>
    <statement>
      <raw>x = 15 + 3 * 9</raw>
      <ast>
        <push>x</push>
        <push>15</push>
        <push>3</push>
        <push>9</push>
        <call>_star</call>
        <call>_plus</call>
        <call>_eq</call>
      </ast>
      <comment>
        the question of life, the universe and everything
      </comment>
    </statement>
    <statement>
      <raw>write(x)</raw>
      <ast>
        <push>x</push>
        <call>write</call>
      </ast>
      <comment>
        the answer to life, the universe and everything
      </comment>
    </statement>
  </function>
</program>
I think that by storing source as XML, it could give a rebirth to theroetically good ideas like literate programming, which tend to be ignored in practice.

There are a lot of possibilities with using XML source representation. What are your ideas on things you would like stored with the source code that you don't want to always have to look at?

Talk Back!

Have an opinion? Readers have already posted 83 comments about this weblog entry. Why not add yours?

RSS Feed

If you'd like to be notified whenever Christopher Diggins adds a new entry to his weblog, subscribe to his RSS feed.

About the Blogger

Christopher Diggins is a software developer and freelance writer. Christopher loves programming, but is eternally frustrated by the shortcomings of modern programming languages. As would any reasonable person in his shoes, he decided to quit his day job to write his own ( www.heron-language.com ). Christopher is the co-author of the C++ Cookbook from O'Reilly. Christopher can be reached through his home page at www.cdiggins.com.

This weblog entry is Copyright © 2005 Christopher Diggins. All rights reserved.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us