Archive for the ‘Uncategorized’ Category

Where the Cloud meets the Grid

Sunday, June 14th, 2009

The GridVoices blog on Gridipedia has just moved to a WordPress installation. Back in April, I wrote this article for them, which looks at the similarities and differences between Grid and Cloud computing.

Running JUnit from Vim

Monday, June 1st, 2009

Normally when I’m programming in Java I’ll use Eclipse. However, in some cases Eclipse can be a bit heavyweight and I’ll fallback on Vim. The last time I did this I started to miss the ability to quickly and easily run unit tests on a per class basis. For this reason, I added the following function to my .vimrc which runs the appropriate test class for the current Java class.

function RunTest()

    let cla = matchstr(expand("%:p"), '^.*[/\\]src[/\\]\(test\|java\)[/\\]\zs.*')
    "still need to replace /s with .s
    let class = "java org.junit.runner.JUnitCore " .  strpart(substitute(cla, "/", "\.", "g"), 0, strlen(cla) -5)

    if match(class, "Test") == -1
        let class = class . "Test"
    endif

    echo class
    echo system(class)
endfunction

map <F6> <Esc>:echo RunTest()<CR>

The code assumes that your test directory structure mimics your source directory structure and all the names of your test classes are the same as the source classes with “Test” appended e.g. if you are editing “src/mypackage/MyClass.java”, it will attempt to run “test/mypackage/MyClassTest”. (If you are currently editing a test class, it should run that class).

I also mapped F6 as a shortcut to the function.

I really don’t know Vim script at all, so I’m sure the code could be a lot cleaner. Still, it was a big help for me, and I now find it quicker to run the correct test in Vim than Eclipse.

Why use diffxml?

Tuesday, May 19th, 2009

I’m the author of the diffxml tool for comparing XML documents. In this post I’d like to explain why you might want to use diffxml to compare XML documents rather than traditional text tools such as the UNIX diff command.

There are two things that diffxml understands that diff doesn’t; the syntax of XML documents (e.g. <br/> is equivalent to <br></br>) and the hierarchical structure they represent. (more…)

Welcome

Saturday, May 2nd, 2009

Tergiversations. It’s a real word: tergiversate means ‘to change repeatedly one’s attitude or opinions with respect to a subject or cause.’

Richard Gabriel, “Patterns of Software”.

I nearly called this blog “Tergiversations”, after an essay by Richard Gabriel in his book “Patterns of Software“. It’s a very important book to me. I found the book in a bargain bin in the academic bookstore on my university campus at the end of my first year. At this time I was considering if Computer Science was the correct choice of course for me, or if I should do something completely different, perhaps in Arts & Humanities.

Gabriel’s book affirmed my course choice. In it, I saw someone who clearly loved his subject matter and was capable of deep insight into it. There was no doubt that Computer Science contained serious challenges and was worthy of anyone’s attention. More than this, I saw there was a very subjective side to the field, and that people’s imaginations – even their force of character – were of vital importance (of course, now I realise that this is probably true of most scientific subjects, but it was a revelation to me then).

The book itself is a series of essays, its title coming from an essay exploring how the ideas in Christopher Alexander’s books “The Timeless Way of Building” and “A Pattern Language” apply to software. It also contains essays on writing, programming languages and some more personal stuff. All are worth reading.

I wanted to call the blog “Tergiversations” to show that I was willing to listen to others and change my viewpoints accordingly. For me, one of the most striking differences between science and other disciplines is a willingness to concede, to accept that someone else’s theory is correct and yours isn’t. Of course, this largely occurs because many things in science can be objectively proven; you can’t argue about the existence of a black swan. At least in science, objective progress can be made, in artistic or political endeavour any progress tends to be subjective. I could argue all day against the BNP, but I couldn’t prove beyond doubt that their beliefs are misguided and immoral. However, I can easily prove that my Java code runs twice as fast as yours. (Interestingly, I recently read an article where these two worlds collided, and I’m just glad I don’t have to deal with Andy Schlafly)

In the end, I didn’t name the blog “Tergiversations”; it has the negative connotations of being evasive and desertion, whereas all I wanted to indicate was a willingness to change one’s mind and to try new methods (I’m sure Richard is well aware of this; I failed to remember the precise definition and the context he used it in until I re-read the essay).

To sum up; many thanks to Richard Gabriel for writing “Patterns of Software”, and welcome to “Feeding the Bit-Bucket”1.

  1. Yes, I know this captures none of the meaning I talked about. However, it does capture the likely end product of this blog, and some of the eternal aspect of writing. []