I agree that XML is harder to read than Java code, but I wanted to
share with you and your readers my believe that XML is ultimately the
most flexible (and coincidentally, desirable) file format for
representing source code.
Source code files are much more than a collection of structured
statements and variable declarations. They also contains textual
descriptions of algorithms, copyright and licensing information, a list
of authors names and contact information, as well as important
meta-information about each method, expected usage, and so forth.
Sun recognized the value of this meta-information from the
beginning, and show great foresight by providing a standardized way of
encoding it into source files (i.e. with Javadocs).
With the release of Java 5, they went even further by extending the
Java language to support “annotations”. A full discussion of
annotations and their merits is beyond the scope of my response, but
nevertheless I think its demonstrates the importance of
meta-information in source code.
So what does all of this have to do with XML?
XML is relevant because it’s emphasizes TRANSPARENT access over
everything else; size, speed and efficiency be damned. It can be
compared to democracy which is inherently inefficient but the lesser of
all evils.
Transparent access should be important to all programmers, because
source code is the fruit of our labor. I love the idea of being able to
transform it, analyze it, study it, or improve it, using tools that may
not even exist today, because access to my source, in a structured
manner, is so easy.
Anyone who has ever tried to write a C or C++ language parser, knows
exactly what I am talking about when it comes to transparent access to
source code. Try writing a “syntax highlighter” or a “source code
beautifier” for C code (see GNU indent). It’s a freaking nightmare.
If C code was represented in XML, you could write XSL stylesheets to
transform it into Java in a fairly straightforward manner. Of course,
you’ll need to map C library calls to equivalent Java methods, but even
that could be automated if the source code was in XML… again, because
access to the source code is transparent.
Ultimately, the best way to make XML more readable, is for us to develop better viewers for XML.
I agree that XML is harder to read than Java code, but I wanted to
share with you and your readers my believe that XML is ultimately the
most flexible (and coincidentally, desirable) file format for
representing source code.
Source code files are much more than a collection of structured
statements and variable declarations. They also contains textual
descriptions of algorithms, copyright and licensing information, a list
of authors names and contact information, as well as important
meta-information about each method, expected usage, and so forth.
Sun recognized the value of this meta-information from the
beginning, and show great foresight by providing a standardized way of
encoding it into source files (i.e. with Javadocs).
With the release of Java 5, they went even further by extending the
Java language to support “annotations”. A full discussion of
annotations and their merits is beyond the scope of my response, but
nevertheless I think its demonstrates the importance of
meta-information in source code.
So what does all of this have to do with XML?
XML is relevant because it’s emphasizes TRANSPARENT access over
everything else; size, speed and efficiency be damned. It can be
compared to democracy which is inherently inefficient but the lesser of
all evils.
Transparent access should be important to all programmers, because
source code is the fruit of our labor. I love the idea of being able to
transform it, analyze it, study it, or improve it, using tools that may
not even exist today, because access to my source, in a structured
manner, is so easy.
Anyone who has ever tried to write a C or C++ language parser, knows
exactly what I am talking about when it comes to transparent access to
source code. Try writing a “syntax highlighter” or a “source code
beautifier” for C code (see GNU indent). It’s a freaking nightmare.
If C code was represented in XML, you could write XSL stylesheets to
transform it into Java in a fairly straightforward manner. Of course,
you’ll need to map C library calls to equivalent Java methods, but even
that could be automated if the source code was in XML… again, because
access to the source code is transparent.
Ultimately, the best way to make XML more readable, is for us to develop better viewers for XML.