

Why xml configuration files suck - Tichy

I just started a new project, in Java because I was in a hurry, so I copied the web.xml from another project and just replaced the references to the old project with the name of the new project. (web.xml configures some things, like the servlets in the project, servlet filters, resources - many of them are needed for all projects).<p>Or wait - that was really repetitive. What do I do if something like that happens in normal code? I write an abstraction for it, something like configureServlet("newProjectName") would do, for example. Except with xml files I can't, or it would be rather complicated.<p>I conclude that it's probably a good idea to keep configurations in the same programming language as the rest of the project.
======
bayareaguy
_I conclude that it's probably a good idea to keep configurations in the same
programming language as the rest of the project._

Of course, if you used lisp you wouldn't even notice :-)

XML is ok if nobody (other than the original developer or the person who takes
over later) has to look at them. Lots of OSX apps use XML in .plist files and
nobody cares because that's just a detail of the class library the devs use
and an OSX app without a nice configuration panel is unthinkable.

However, visible XML configurations are a symptom that your app is about to be
assimilated into the borg collective.

------
pcowans
How would that work in Java (or any other compiled language)? You recompile
every time you want to change the settings?

~~~
Tichy
For example, instead of saying "the configuration goes into web.xml", the
servlet specification could have said "the configuration goes into
ServletConfiguration.java" or something like that.

Actually I think it Spring it can be done, have to look into it.

------
twism
i dont know what you guys are talking about... I use spring and I just
discovered embedded javascript (ala rhino) for view controllers and I'm in
heaven right now... Can't wait to release to the public to test real world
performance

~~~
Tichy
Cool, I was planning to use that, too. Is it availably with the latest version
of spring? Last time I looked, they did not have javascript yet.

Also, I think in Spring you can create configurations in a programmatic way,
if you want to, you are not forced to use xml.

------
run4yourlives
>in Java because I was in a hurry

lol :-)

~~~
Tichy
Just because I already know it.

~~~
mrtron
I don't think you need to defend your choice of Java. It is hardly a poor
choice to write software in. I worked with Java on a huge financial server,
and it was really fantastic.

That being said, .xml config files are something I strongly dislike as well.

