Skip to content.

Manageability

Sections
Personal tools
You are here: Home » blog » archive » Programming in XML the Good, the Bad and the Ugly

Programming in XML the Good, the Bad and the Ugly

20030423205419

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. 

Created by admin
Last modified 2003-07-30 04:15 PM
 

Powered by Plone

This site conforms to the following standards: