XML as a Declarative Programming Language
XML is a generic format for data storage that has been widely used by the industry. That could be all that there is to XML, if were not for the importance of data in programming. One of the things you learn when using Lisp is that data can also be viewed as code — we just need some way to interpret it using a programming language. This is the secret that make s-expressions so powerful.
It turns out that using C++ or Java to interpret data in XML format is not terribly complicated. Many people have made a good life just doing this kind of thing, using one of the many libraries available.
It is possible to use data encoded as XML as code and use a standard XML parser to interpret that data.
There are several examples of how this strategy may work. Ant is a well know case, where XML has been used to encode not only data about the building process but also other programming-like actions.
XML and Domain Languages
Using a textual language to express commonly used actions has always been a powerful way of creating software. For example, whole systems have been implemented using a domain language.
Think for example of Emacs, which was implemented in a simplified version of Lisp. Or, in a more specific domain, troff was implemented using a special-purpose language.
The advantage of using XML, though, is that one doesn’t need to use yet-another-parser for a domain-specific language. At the end, using a generic format such as XML is almost as good as the s-expressions used by Lisp.
In a sense, XML unleashes the possibilities of domain-specific languages for everyone else who doesn’t know how to write good parsers. You still need to implement the semantics of the language in Java or C, but this is a great step towards improved support for domain specific languages.
Further Reading
To Understand how Lisp leverages the power of DSLs, the best reference is Paradigms of AI, where this and related techniques are discussed.
Similar Posts:
About the Author
Carlos Oliveira holds a PhD in Systems Engineering and Optimization from University of Florida. He works as a software engineer, with more than 10 years of experience in developing high performance, commercial and scientific applications in C++, Java, and Objective-C. His most Recent Book is Practical C++ Financial Programming.
TYVM you’ve solved all my porblmes
By Delonte on Apr 25, 2011