Site menu:

Sponsored by

Bitcube Ltd.  Expert Linux Consultancy

Categories

Meta

Site search

 

May 2009
M T W T F S S
« Apr   Jun »
 123
45678910
11121314151617
18192021222324
25262728293031

Archives

Links:

No comment

I often think that Java has the worst case of [http://en.wikipedia.org/wiki/Not_Invented_Here 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” [http://svn.apache.org/viewvc/activemq/trunk/assembly/src/release/bin/linux-x86-32/wrapper.conf?view=markup property file]:

 # Java Additional Parameters
 # note that n is the parameter number starting from 1.
wrapper.java.additional.1=-Dactivemq.home=%ACTIVEMQ_HOME%
wrapper.java.additional.2=-Dactivemq.base=%ACTIVEMQ_BASE%
wrapper.java.additional.3=-Djavax.net.ssl.keyStorePassword=password
wrapper.java.additional.4=-Djavax.net.ssl.trustStorePassword=password

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.