[YLUG] Parsable Rack Diagrams

Noah Slater nslater at gmail.com
Tue Aug 7 20:32:20 BST 2007


> Sounds like something for some handcrafted XML and a custom written
> perl/python/foo script to render it.

XML is not the answer. It is not even the question.

To quote Phillip J. Eby [1] who is paraphrasing  Jamie Zawinski [2] on
regular expressions:


"Some people, when confronted with a problem, think "I know, I'll use
XML." Now they have two problems."

To quote him some more:

-------------------------------------------------------------------------------------------------------

If you're not implementing an existing XML standard for
interoperability reasons, creating some kind of import/export format,
or creating some kind of XML editor or processing tool, then Just
Don't Do It. At all. Ever. Not even just this once. Don't even think
about it. Drop that schema and put your hands in the air, now! If your
application or platform will be used by Python developers, they will
only thank you for not adding the burden of using XML to their
workload.

(The only exception to this is if your target audience really really
needs XML for some strange reason. Like, they refuse to learn Python
and will only pay you if you use XML, or if you plan to give them a
nice GUI for editing the XML, and the GUI in question is something
that somebody else wrote for editing XML and you get to use it for
free. There are also other, very rare, architectural reasons to need
XML. Trust me, they don't apply to your app. If in doubt, explain your
use case for XML to an experienced Python developer. Or, if you have a
thick skin and don't mind being laughed at, try explaining to a Lisp
programmer why your application needs XML!)

-------------------------------------------------------------------------------------------------------

Robert recommends YAML but in many ways this is the same as using XML.

Unless your writing something that performs XSLT transformations on
very large documents the overhead of processing XML is completely in
your mind. Using YAML offers you no advantages in this area - it may
even compound the problem as it is less widely known and hence parsers
may not exists for all the languages or exotic environments where you
/can/ parse XML.

Phillip J. Eby [1] goes on to explain what you /should/ do to implement a DSL:

-------------------------------------------------------------------------------------------------------

In Python, XML is something you use for interoperability, not your
core functionality, because you simply don't need it for that. In
Java, XML can be your savior because it lets you implement
domain-specific languages and increase the flexibility of your
application "without coding". In Java, avoiding coding is an advantage
because coding means recompiling. But in Python, more often than not,
code is easier to write than XML.

-------------------------------------------------------------------------------------------------------

Noah

[1] http://dirtsimple.org/2004/12/python-is-not-java.html
[2] http://fishbowl.pastiche.org/2003/08/18/beware_regular_expressions

--
"Creativity can be a social contribution, but only in so
far as society is free to use the results." - R. Stallman



More information about the York mailing list