Live data from Hacker News

Why I hate XML for DSLs

theschemeway.blogspot.com

11–20 of 27 posts

Re: Why I hate XML for DSLs

#11
post #10
post #7

I have created a programming language that is written in XML. With a decent editor (I use oxygen xml) and a good schema (I use Relax NG) there is almost no way to make syntax errors and typing is a breeze (auto completion). With schematron you can even make clever (semantic) error checking before compile time. So it always depends on the case.

I don't doubt that you could write a DSL that someone would be productive with. But then you'd need to keep a psychiatrist on staff to make sure the people using it don't go crazy. If we're talking about a full on, general purpose language, then you might as well start them on Thorazine ahead of time. Otherwise, you risk a programmer going postal. In short, don't risk your or your coworkers' safety. Just say no to XM…

I know several people that are productive with that language without a psychiatrist.

Take for example XSLT. You are saying that all XSLT programmers are mad?

Re: Why I hate XML for DSLs

#12
post #10

Earlier quoted context omitted.

I don't doubt that you could write a DSL that someone would be productive with. But then you'd need to keep a psychiatrist on staff to make sure the people using it don't go crazy. If we're talking about a full on, general purpose language, then you might as well start them on Thorazine ahead of time. Otherwise, you risk a programmer going postal. In short, don't risk your or your coworkers' safety. Just say no to XM…

I know several people that are productive with that language without a psychiatrist. Take for example XSLT. You are saying that all XSLT programmers are mad?

Not at all. However, if they enjoy it, I'm not convinced they're sane either.

Re: Why I hate XML for DSLs

#13
post #9
post #3

There are two times when you'll be better of programming in XML. One is if the language you would otherwise be writing in is Java. (Or WCF in the MS stack) The other is transforming XML documents (XSL) although this is quickly becoming more of a PITA than doing it natively as the various XML APIs start offering declarative syntaxes.

> One is if the language you would otherwise be writing in is Java. (Or WCF in the MS stack) I admit that I've never done any serious Java development, but that's jumping from the kettle into the fire, is it not? As verbose as Java is, it seems to be less so than XML would be.

No, but Java is static, you have to recompile it every time you edit it. The draw of XML-based languages for the Java community is that you don't have to recompile them. Hell, it might even be possible to reload them on the fly.

Re: Why I hate XML for DSLs

#14
post #8
post #4

I have to say that I've never considered using an XML for a DSL. Most of the reasons I've written DSLs usually involve a desire to avoid writing more code. The closest I've come to writing an XML-like DSL are the many Lisp-lites that I've hacked up over the years. Most of the rest are either Forthish languages (if it's primarily for my use to avoid writing large quantities of Java, C*, Haskell, etc.) or rough "busine…

> I have to say that I've never considered using an XML for a DSL. Most of the reasons I've written DSLs usually involve a desire to avoid writing more code. I'd like to ask a favor as a fellow programmer: pretend you never saw this article. The fewer XML-based DSLs, the better.

Done! :-)

Re: Why I hate XML for DSLs

#15
post #9

Earlier quoted context omitted.

> One is if the language you would otherwise be writing in is Java. (Or WCF in the MS stack) I admit that I've never done any serious Java development, but that's jumping from the kettle into the fire, is it not? As verbose as Java is, it seems to be less so than XML would be.

No, but Java is static, you have to recompile it every time you edit it. The draw of XML-based languages for the Java community is that you don't have to recompile them. Hell, it might even be possible to reload them on the fly.

Languages are mainly for humans, not for machines. XML is intended for transporting data machine to machine, not to be read and comprehended by humans. Computer languages must foster the comnprehension by (fellow) developers, this is their main task.

Reloading is possible with Java as well. And even an XML-document has to be reparsed and most likely be brought into an internal representation, a task which is very similar to a compilation. So, no difference here or any jsutification that xml is suited better for this purpose than other languages.

Re: Why I hate XML for DSLs

#16
post #6
post #5

If you liked this blog post, you'll love mine on "Why I Hate Peanut Butter as a Cleaning Agent".

The difference here is that nobody is silly enough to use peanut butter as a cleaning agent.

http://cleaning.tips.net/Pages/T004197_Remove_Gum_from_Carpe...

Sorry, I just had to find an example...

Re: Why I hate XML for DSLs

#17
Most of my past experience with XML reminds of a certain saying. The one about how someone realized they had a problem and that it could be solved with XML. Then they had two problems.

Re: Why I hate XML for DSLs

#18
post #15

Earlier quoted context omitted.

No, but Java is static, you have to recompile it every time you edit it. The draw of XML-based languages for the Java community is that you don't have to recompile them. Hell, it might even be possible to reload them on the fly.

Languages are mainly for humans, not for machines. XML is intended for transporting data machine to machine, not to be read and comprehended by humans. Computer languages must foster the comnprehension by (fellow) developers, this is their main task. Reloading is possible with Java as well. And even an XML-document has to be reparsed and most likely be brought into an internal representation, a task which is very sim…

> Languages are mainly for humans, not for machines. XML is intended for transporting data machine to machine, not to be read and comprehended by humans.

You might want to avoid rewriting history, or at least avoid commenting on things you clearly know nothing about.

XML Working Group design goal 6 (out of 10):

> XML documents should be human-legible and reasonably clear.

Human readability was a primary goal of the WG, and one of the big advocacy claims against binary or custom plaintext formats.

> Reloading is possible with Java as well.

Sure, anything's possible, you can even parse, compile and load C source code in a Java program if you have time to waste. How many JVM implementations let you trivially reload executed source files on the fly, and how often does that feature explode in your face?

> And even an XML-document has to be reparsed and most likely be brought into an internal representation, a task which is very similar to a compilation.

The point is that it's performed on the fly, easily, and can be re-executed as often as needed without bringing down the whole machine.

Re: Why I hate XML for DSLs

#19
post #3

There are two times when you'll be better of programming in XML. One is if the language you would otherwise be writing in is Java. (Or WCF in the MS stack) The other is transforming XML documents (XSL) although this is quickly becoming more of a PITA than doing it natively as the various XML APIs start offering declarative syntaxes.

There are two times when you'll be better of programming in XML. One is if the language you would otherwise be writing in is Java.

You would rather implement business logic in XML than in Java? Seriously?! Personally, whenever I see logic implemented in a markup language, it makes me wanna scream. That's simply not what they were designed for.

As far as I'm concerned there's only one time when you're better of programming in XML and that's when doing GUIs. That's because XML lends itself naturally to GUI programming. Concepts of nodes, parents, children, siblings and trees are very much at place in XML (or XML-like language), and can be easily used to describe the structure of the UI, whereas in imperative programming there are really no such concepts, and you have to sort of 'invent' them.

I think that people are finally starting to realize this - that we shouldn't indiscriminately use XML for just about anything, and especially not for tasks that require some sort of decision, branching and logic. But we should use it for what it's good at, and that's describing structure (of documents, user interfaces, models, etc).

The good people at Adobe, for example, came to this conclusion a couple of years ago, that's why when developing Flex applications you usually write your UI in MXML and your business logic in ActionScript.

Re: Why I hate XML for DSLs

#20

Most of my past experience with XML reminds of a certain saying. The one about how someone realized they had a problem and that it could be solved with XML. Then they had two problems.

Oh, not the one about how XML's like violence - more of it solves any problem?
Post reply on HN