Ant pipes?

A while ago Duncan published a Blog entry quoting somebody saying that in Ant we’d forgotten some old Unix lessons such as the stringing together of simple filter operations in pipes. I can’t find the entry now since Duncan has rebuilt his blog on a new server. At the time I had a quick think about it and was not sure how we could provide the concept of a pipe in Ant. I didn’t get very far and let it go. Nevertheless, that thought has been jangling around in my head since then.

I recently saw a bug report in Ant about sorting the output of <echoproperties>. The normal approach would be to bung in a new attribute to control sorting of the output and just do that. But that does not make the functionality available to other Ant tasks. The idea of a pipe appealed

So, I wonder if a pipe could be created, something like this

<pipe>
  <echoproperties/>
  <sort/>
</pipe>

The pipe would route the log output of one task to an input method on the subsequent task for additional processing. Anyway, I’m at something of a low ebb right now and not in the mood to code so I thought I’d throw these thoughts out there for some feedback.

Atomic increment in Java

Matt and I were talking this week about whether ++ is an atomic operation in Java.. He’s written it up in his Blog so I thought I would add my 2c here. I hadn’t really thought about it before and my initial reaction was to think it would be implemented with an iinc bytecode instruction. As Matt points out that’s only true for local variables for which atomicity isn’t a big deal.

Nevertheless, I had to take exception with a statement in Bruce Eckel’s original article:

“… and if you’re coming from C++ or some other low-level background, you would expect the increment to be an atomic operation, because increment is usually implemented as a microprocessor instruction”

C/C++ don’t really address thread interactions and the above statement is certainly not true on a RISC processor. It is just as prone as the Java code to thread interactions. I guess Bruce was thinking in CISC. It certainly is a single instruction on a x86 CISC processor but even there that could fail on a multiprocessor system.

So, lock up your variables …

SJUG Javablogs

Brendan and I went along to the local Java user’s group, SJUG, to hear Mike’s presentation on Javablogs and its technology. I liked the presentation and it was good to catch up with a few people. I’m playing around with webwork2 right now so that it was quite relevant to me.

I sat behind Dion so I could heckle him about Maven – just kidding. It was good to chat. One of Mike’s slides was about Maven and it actually generated a fair bit of discussion. It was good and I took away some of the issues people are having with Ant so that was useful.

Considering that we had the developers and contributors of Checkstyle, Clover, Jira, Javablogs, the Ant and Maven PMC chairs, and who knows who else, there, you’d have to say that Aussie Java is pretty healthy.

I guess that Brett Porter must have been there although I do not know him. Cool.

Maybe we should do a Sydney JavaBloggers dinner.

Dropped from JavaBlogs?

Hmmm, I added this blog to Java blogs a while ago and now it seems to be gone. Was it a technical glitch or did I not produce enough Java releated stuff? I’ll try again …

ICFP2003

Matt and I both entered this year’s ICFP programming contest.. I have to say thanks to Matt since I used his GUI code with a few hacks to work on my solution. We also kicked around ideas and chatted on Yahoo in the wee hours of Saturday night.

It was tremendous fun to watch my little car repeatedly crashing into the wall and then trying again, getting a little better most times. I achieved some reasonable times in the end but nowhere near the top league of results that I have seen. I have uploaded my submission here. You are free to check it out. You’ll realize just how much I relied on Matt’s GUI. My main contribution is in the LapDriver class. Funny when you are trying to code quickly – fields quickly become public and there is lots of dead code from experiments that didn’t work out. My times were

track

1

2

3

4

5

6

7

8

9

time

10307

16346

18557

20957

6351

5399

3989

10884

Not attempted

It makes you realise just how incredible the human brain really is. Just looking at the track picture, anybody could find a reasonable path in seconds. Sure we can optimise that with a computer program and we can write that program with a little effort. But to write a program to find that initial path – that is hard. Not only that, it’s amazing how the brain can keep the rest of you going when you should have been asleep hours ago.

Speaking of programming contests, I recently heard that MacTech is stopping their programming challenge. That was a great series. I only entered it once to write a Java Virtual Machine in 1996, I think. I wrote that in C++. It wasn’t the fastest sicne I solved a more general problem than required and others used PowerPC assembler. Nevertheless I learnt a huge amount about the Java VM in a very quick time. Some of that code lives on in the Ant <depend> task, now rewritten in Java.