Views
- State: published
Programming in XML the Good, the Bad and the Ugly
|
|
Now, there's an ongoing debate on whether XML should be used as a syntax for a programming language. I tend to agree with the opinion that programming constructs should not be expressed in XML form. I've had my share of war stories working with XSLT, Ant and TagLibs. However, I would qualify this by saying that it's perfectly acceptable to embed a general purpose language inside XML (i.e. see Quasi Literals).
Another acceptable use of XML is to provide views of code. For example, Eclipse uses XML to describe a plugin, this is analagous to defining the interface however in XML. Another possibility is an XML description of UML like activity diagrams. The rationale behind this is that process definition interchange may facilitate interoperability. However, all views should be declarative in nature rather than perscriptive.
My reasoning behind the above constraints is that it should be possible to leverage a host language to implement a little language. There are two different approaches to implementing a little languge. One approach is to design the little language from scratch, the second approach is to extend a general purpose language. Extending a general purpose language leverages the language's features like variables, conditionals, loops, functions and even typing rules.
There are two papers that describe the utility of this approach: "A Universal Scripting Language" and "Little Languages and their Programming Environments". The later paper, shows how the editing and debugging features of the host language can be used with the little language. Both papers describe why a "embedded" approach is easier and leads to a better quality implementation. If Ant had been built this way, it would be more consistent and we would have the luxury of a debugger.
In conclusion, its good to implement a little language using an exisitng language, its bad to implement a little language from scratch and its just plain ugly to express programming constructs in XML.
Last modified 2003-07-30 04:15 PM


You say:
"its just plain ugly to express programming constructs in XML."
but I think that confuses models with views. Using XML to store programs makes them easier for machines to manipulate. Displaying that XML to human beings makes as much sense (to me) as showing assembly code instead of Lisp. Every other major application on the planet (AutoCAD, Microsoft Word, MySQL) separates models from views; why don't programming languages?
See also http://www.third-bit.com/~gvwilson/xmlprog.html.
Replies to this comment