If you look at it long enough, the tags disappear
Saturday, 22 August 2009
I don’t know what it is about xml configuration files that simply turn me off learning a particular library or framework. For example, here is a Hibernate XML monstrosity.
I realize it all makes sense, but there is something terribly off-putting about xml. To me it’s a sign that the host language is not sufficiently dynamic or declarative, and here we are going back to a verbose format so that the framework can parse it using readily available libraries. It also makes one yearn for a lispy language, where configuration and implementation code looks entirely similar.
All this language snobbery may be well and good, but it doesn’t help to improve one’s familiarity with an important framework.
This brings me back to the original comment about how to read Lisp code. If you stare at it long enough, the braces simply disappears.
This is exactly what I had to do to learn new XML configuration file formats. Stare at XML long enough, and the tags simply disappear.
If you are willing to persist with the equivalent of staplers in your cereal bowl, here is what xml looks like to you after a couple of months:
<hibernate-configuration>
<session-factory>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<!-- Database connection settings -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:data/music</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="connection.shutdown">true</property>
<!-- JDBC connection pool (use the built-in one) -->
<property name="connection.pool_size">1</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- disable batching so HSQLDB will propagate errors correctly. -->
<property name="jdbc.batch_size">0</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- List all the mapping documents we're using -->
<mapping resource="com/oreilly/hh/data/Track.hbm.xml"/>
</session-factory>
</hibernate-configuration>
What’s your way to cope with xml? Any tips?
You should follow me on twitter here
No. 1 — August 23rd, 2009 at 1:19 am
> What’s your way to cope with xml?
Avoiding anything which uses XML as its configuration format.
No. 2 — August 23rd, 2009 at 3:52 am
All those pointy brackets hurt my eyes! ;-)
Oxygen (my favorite XML Editor) actually has a feature for this, allowing you to lighten either the tags or the content. That said, I don’t use that particular feature much.
No. 3 — August 23rd, 2009 at 5:14 am
I’ve started using YAML for config-files. It’s so much nicer to read than xml.
No. 4 — August 23rd, 2009 at 5:58 pm
I’m writing Zope 3 applications, which use ZCML (an XML format) for configuration. I deal with them is good formatting: consistent (2 lines) spacing between sections, separate related tags into sections, documenting stuff not with comments (which editors usually highlight in faded colors), but with plain text inside the tags, or outside the regular tags (you might want to try that with your Hibernate files, I bet you can do that. Also, in my case, it helps if I keep the files short, separate contents into different files (Z3 makes it possible to “include” on file into another). Plus, I have a good knowledge of the zcml tags. To tell the truth, I’m not bothered by the XML, in this case, at all :-)
No. 5 — August 24th, 2009 at 5:41 pm
XML is a machine language more than a human language. The crux of the problem is: why is there still no decent XML editor? (not counting proprietary cr*p with an ugly java UI)
No. 6 — August 24th, 2009 at 7:42 pm
XML is not a machine language in the sense that it has a lot of human-readable metadata, but it is a hell of an annoying format in configuration files, because the signal-to-noise ratio is too low. Most of the essence of a file is hidden in a sea of tags.