Site search

May 2009
« Apr   Jun »



No comment

I often think that Java has the worst case of [ NIH ] syndrome I’ve ever seen. At other times it’s due to the way it chooses to do things. However that’s little excuse in my opinion – “so don’t do that then” is one possible answer. “Think of the children” (or rather “think of your users”) being a more helpful reply.

This article is written from my point of view as a system administrator. Java programs (or rather their programmers) often seem to think that the way to configure a program isn’t via a readable configuration file, oh no. You have to edit sometimes dozens of “properties” files and XML files, these will no doubt be scattered throughout a whole WEB-INF tree.

Let’s start with ActiveMQ’s “wrapper” [ property file]:

 # Java Additional Parameters
 # note that n is the parameter number starting from 1.

To add extra parameters I have to actually add a line with an incremental number? Or worse to remove one I have to go and edit all the other lines? I’m ignoring the horrific sin of passing passwords on the command line exposed to any user who types “ps”. This is just diabolical – no one could possibly be proud of this design.

XML files are far, far worse though. They aren’t human readable to any sane definition of it. This is pretty silly – life should be made easy for people – it’s not as if parsing a configuration file requires high performance. It’s far more important that the chances of making a mistake are as low as possible and that they are easy to edit and understand. I even recall reading many articles that parsing XML files is slow and uses up huge amounts of memory too – (something Java programs seem to do in abundance – it doesn’t seem unusual for them to take many minutes and GB of memory to start).

Back to the ranting. XML files and comments. There is no universal comment syntax in computing, however let’s take a look at the common ones:
* # most comment comment sign in unix, most configuration files, most scripting languages
* // used in C++ and derivatives (including Java), most modern C implementations
* /* … */ used in C, C++ and derivatives, does not nest

Now let’s look at XML files. I do realise that this syntax is due to the format, however it’s another reason why it’s a horrific format for configuration files. The comment characters here are:
* <!–– … ––> – that’s almost twice as long as the previous worse case and seven times longer than the usual case. It doesn’t even nest.