Allen Holub: Say No To XML (As Programming Language); I Agree

By Angsuman Chakraborty, Gaea News Network
Wednesday, September 27, 2006

Allen Holub (Author of Compiler Design in C and famous OO Guru) said: “XML is perhaps the worst programming language ever conceived. I’m not talking about XML as a data-description language, which was its original design. I’m talking about perverting XML for programming applications. It’s inappropriate to use XML as a scripting language (e.g., ANT), a test-description language (e.g., TestNG), an object-relational mapping language (e.g., Hibernate, JDO), a control-flow language (e.g., JSF), and so forth. These sorts of XML “programs” are unreadable, unmaintainable, an order of magnitude larger than necessary, and audaciously inefficient at runtime.” Link

He surmised that the tendency to use xml for these tasks is simply because people either don’t want to create a compiler or are inacapable of creating one. I agree with him. Most of the time people use XML because it is easy to parse XML, so who cares how long it takes for people to create these xml documents in the first place. Look at Hibernate for an example. It is XML hell. EJB 2 was another example. Jelly was probably the worst example and I don’t like JSTL that much either.

Then he goes on to define the basic qualifications of a programmer, he said something which is close to my heart:
“This list includes a deep understanding of data structures and key algorithms, a little math (set theory, logic, a little statistics), mastery of analysis-and-design techniques, both process (e.g., RUP or XP) and structure (e.g., design patterns), and database structure and use (e.g., SQL). You also need to know how the hardware works.”

Designing compilers is hard. Today it is rare to see people designing compilers for their software. They use XML or simple property files. Also, as he mentioned, it is hard to get books on compiler design. The best Java software to design compiler is JavaCC, which was by an ex-Sun employee, who later went on to found MetaMata in the dotcom boom era.

He misses one vital point. Somewhere down the road it has unfortunately become a marketing bullet point to mention that your software uses XML for configuration.

Discussion

Fidel Viegas
January 4, 2008: 4:25 am

I have often seen people creating programming languages using XML. I think that XML was not meant for that and does not suit that purpose. Prove of that is XUL, Flex MXML or even XForms, that end up using Actionscript or Javascript to do the business logic. They use the XML part to layout the components and Actionscript or Javascript to do the serious work. These make sense, because when we are creating the forms, we are marking (or laying) our UI components.

When I started playing with XML, I thought it was going to be a solution for writing quick languages. But, I came to the conclusion that XML is what it is: a markup language. And it can be used for document design and for data design as well. As for complex programming languages, I stick to writing compilers for them. The language becomes so much cleaner than XML.

Now, as for compiler writing being a hard, I just answer \\\”when people don\\\’t know how to use something, they always say it is difficult\\\”

It is not like in the old days whereby you would need loads of programmers to write a compiler. Today, a single programmer can put together a compiler, using current compiler frameworks, in a month.

Nowadays, you don\\\’t have to write parsers by hand. You can put together a parser for a configuration file in a day or two.

Compiler writing was, in the old days, very laborious. Not anymore, because you have many frameworks that do half of the work for you. For instance, with JavaCC you can generate the lexer, the parser, the Abstract Syntax Tree using JJTree. And then, you just have write the semantic analyser, intermediate code generator, code optimizer and the code generator. But, that is very simple to do. It is similar to traversing XML nodes. I usually see it that way. :D

Finally, I would like to mention that there is a compiler framework called SableCC, which is very easy to use. There is also an alternative based on SableCC, which allows us to write backend generators for other languages. I have written two backend generators: one for Python and one Actionscript. The Python one is in the public domain. The Actionscript one is still being used internally in my company. But will, eventually, be released to the public domain. We used the Actionscript backend to write a SPARQL parser for Adobe Flex, and to write a compiler for a programming language based on Daplex. Well, we call it a framework, because it does more than generating database code. It generates web applications that target PHP, Java, C# with either Ajax or Adobe Flex front ends.

Anyway, that is my two cents.

All the best,

Fidel.

March 7, 2007: 11:00 am

Yes, I do remember sendmail as well as the make files :)

I think xml for plain configuration is ok but not as a programming language. Ant is a case where xml is used as a programming language.

March 5, 2007: 8:39 am

I think, the author exaggerates a little.
It is good that there is a simple format of configuration files. XML is maybe verbose, but it is easy to learn. And if everyone created a new format for each application, we would have to learn much more and it would take much more time. Do you remember sendmail configuration files?

September 29, 2006: 12:32 am

I had read his book - “Compiler Design in C” and I think it is of very high quality. So even if he is plugging his book, I think it is a good plug.

Also everyone has their natural tendencies. A compiler designer sees everything as a compiler design problem, a OO designer sees the world as object oriented and so on. Beyond all that I still see lots of merit in his arguments against ubiquitous use of XML as programming language.

September 27, 2006: 10:29 pm

Yeah, maybe… Except a bad example (ok, problem with Ant, yeah, but it’s not like make is so easy to use, please, tabs, and spaces o my), and plugging his book with all the subtlety of a sledgehammer wasn’t too cool :)


Don Parish
September 27, 2006: 10:07 am

I got tired of doing “XML push-ups.” So I’m trying to focus my new development efforts on Ruby on Rails. XML? There is none. Just YAML for configuration of database. Very nice!

September 27, 2006: 7:14 am

Wouldn’t it be more profitable in the long run to make your application easier to use, unless you also offer paid professional support services?

Creating compilers is hard for us but creating xml files aren’t easy for end-users.

In my experience most of them are comfortable with Excel documents, complex xml is beyond them (obviously with exceptions).

The downside of compilers is that they are not only harder to create but also harder for others to consume, unless you provide them with a parser too. We do however need a better solution than xml, especially for simple formats.


Tony P
September 27, 2006: 6:25 am

Some geeks fantasize about being with hot and sexy girls, only to come home and meet the wife (if they have any) who is far from hot and sexy. That, my friend, is reality.

Allen Holub lives in a fantasy world. In reality, there’s always deadlines to meet, profit to achieve.

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :