Monday, August 29, 2011

XML Overdose

While giving a talk at IT-Jam 2011 in Odessa I mentioned that XML is poisoning our lives (Russian "...портит нам жизнь" to be accurate). And apparently some people got the impression that I'm in favor of getting back to monochrome ASCII terminals or something...


Well, allow me to clarify my perspective on that topic. I'm using XML extensively in my day-to-day life. And I think it is a clever syntax to present data. Maybe a little bit overloaded with meta information, but clever anyway. It has it's own weaknesses, but in general it is a good data format to use. It is a standard, its backed by a lot of tools and it is ubiquitous throughout the computing world - supported by most of modern languages, frameworks and libraries.

My attitude toward XML was changing all the time I was using it. First it was confusion from that mystic way to organize data - it was hard to understand the concept of semantic mark-up since years of HTML formatting. But when the idea became dominant I started to appreciate the power of XML and tried to use it everywhere I can - transfer protocols, data formats, configurations... It soon became apparent that I'm actually writing real programming languages in XML. And a lot of people, including framework developers, doing that too. So we ended up in the world where we are doing more declarative coding in XML than coding in imperative programming languages... And some ideas are taking much more space to express in XML, so it does not make things concise.

Once I realized that, I switched from blind injection of XML into anything I could to a more pragmatic approach. I think we are overusing XML a lot these days. And it fits well for some purposes, but for others makes things more complex. By trying to fit XML where it doesn't belong we are loosing a sense of simple solutions and getting the XML overdose.

And that XML overdose playing tricks with our brains - just look at the Maven dependency declaration:

<dependencies>
    <dependency>
        <groupid>junit</groupid>
        <artifactid>junit</artifactid>
        <version>4.0</version>
        <type>jar</type>
        <optional>true</optional>
    </dependency>
</dependencies>

To set 5 values (ids, version, type and optional) we have to specify 7 strings. And in a real project we would have 10s if not 100s of dependencies each requesting 5-8 strings to define. That's what I call the XML overdose!

In this case Maven is blindly following best recommendations you can find at W3C Schools. They suggest to use elements instead of attributes, since elements are flexible, extendible, can have multiple values etc... When do they propose to use attributes? Well, when you have some identification values like NAME or ID.

So, you can look at it this way - groupid, artifactid and version are like identifiers for a dependency. So you can put them as attributes. Developers of Apache Ivy have done just that. And the same declaration in Ivy would take only one XML string:

<dependencies>
    <dependency org="junit" name="junit" rev="4.0" optional="true"/></dependencies>

We can get rid of XML at all. And Gradle by doing that makes the declaration even more concise:

dependencies {
    testCompile 'junit:junit:4.0'
}

Now that is a big needle to stick into anyone affected by the XML overdose!

Just ask yourself - why do I need bloated syntax to define my project dependencies? Only because it is a STANDARD and it is a way most developers doing it?

I'd better keep my own perspective on this matter since I'm tired of tag-bloat in my pom.xml files.

If you are designing an XML format humans are going to work with, try to keep it as simple as possible. That is the only ground rule here. Avoid unnecessary structures and nesting, try to minimize mandatory values by using defaults. And most of all - DO NOT use XML namespaces - they are making tags ugly and unreadable. If it is possible, consider using some alternative format instead of XML.

In summary, with some effort on our part, it is possible to make XML data confortable to work with. Just do not overdose it!

P.S. Don't get the impression I have something against monochrome terminals. I'm a fan of retro-computing. Maybe I missed the glory days of PDP-11 era, but I had my time programming ZX Spectrum in early 90s. And it was a great time with a really neat machine!

Thursday, August 25, 2011

IT Jam 2011 Report

Last weekend I attended the IT Jam 2011 conference in Odessa. The experience was so intense and vivid, that I'm still recovering from the trip and only recently have managed to sort out all correspondence gathered while I'm gone.

Odessa is a great place for such a conference and it attracted 1000+ IT professionals. Before the opening, I've managed to get my caffeine dope from a great café in the downtown.


Odessa is able to impress. It welcomed us with great sunny weather, distinctive architecture, impressive industrial skyline of a port, good restaurants and dynamic night life.



The conference itself was hosted in the marine passenger terminal - probably one of the few places in Odessa capable to hold an event of that magnitude.

 
The talks were divided in 6 streams - Main stage, Java, .Net, Web, Mobile and QA.



I was giving a talk in the Java stream called "Gradle - next generation of build tools". It was a lot of fun - listeners were very positive, easygoing and responsive. And according to tweets the talk was accepted quite well.


The only thing I regret is that I haven't positioned the talk properly. And some people got the impression that I'm trying to persuade them to migrate on Gradle right away (which I'm not). I just wanted to increase product awareness, so Java developers would mark on their radar another convenient build integration tool. And it makes a good sense, since according to my initial quiz nobody uses Gradle.

Along the way I've mentioned Polyglot Maven as a way to handle pom.xml complexity. Apache Ivy also came into view - I was really surprised, that nobody actually knows about it.

My presentation is available at SlideShare (in Russian). I actually made a really fun mistake in the code, which hasn't passed unnoticed. While making a "hello world" program for Gradle I first made it say "hello world!" but than decided to change it to "hello Gradle". However, I've forgotten to change the original source, only the output has been changed. So I ended up with println "hello world" seems like printing "hello Gradle". My appologies :)

The conference was very dynamic with a lot of people going back and forth between the talks. I've met a lot of interesting people and had the opportunity to chat with folks I haven't seen for a while.

There was some problems with food availability during the lunch. I, however, skip some talks to visit the summer lounge in a good Odessa restaurant.


So I was really surprised to see all the whining in twitter that all food is gone. No, it is not! Just get outside and find a good restaurant to eat - your are in Odessa after all!


But somebody expected on free conference to get free food to boot. So naive and immature on their part. As for the conference organizers, they probably should have cleared more time for lunch. I don't have any other complains with organization at all - the event was great and all small inconveniences was inevitable for such a scale. They were caused by the complexity of the event itself and not by the lack of organizational effort (people complained a lot about sound isolation in improvised stages - well, just try to find a better place to host 2000 people!).

IT Jam was closed by a spectacular rock show featuring several rock/punk/metal bands consisting mostly of IT-people. The sound was harsh and loud - exactly what we needed after the whole day of tech talks.


After last chords everybody could enjoy Odessa nightlife.


Italian tall ship "Amerigo Vespucci" was in Odessa harbour at the time. Truly sailing work of art attracting both locals and tourists.


You can find photo report from my trip here.

In summary, I want to thank Ciklum for the effort in organizing the conference. The jam was a fascinating event. It was worth the time and energy to visit. And I'm looking forward for the next year jam. Let it be bigger, brighter and louder!