Java (Lack Of) Documentation

Today, I have wasted an astonishingly large amount of time trying to get this to work:

% java -classpath mylib.jar -jar myapp.jar

Suffice to say, it doesn’t work. It’s not going to. Looking inside the java.c:

    /* Override class path if -jar flag was specified */
    if (jarfile != 0) {

It would be really nice if somebody, somewhere had documented that -jar and -classpath are exclusive. I’d be a lot less upset then.

Of course, this would be less of an issue if Java had any tools for helping you to debug classpath issues. Something like Perl’s message Can't locate in @INC (@INC contains: ...) would be astonishingly useful. But apparently there’s nothing like this that I can find.

One interesting thing I did pick up from looking in the source: You can set an environment variable _JAVA_LAUNCHER_DEBUG which spits out a lot of debug info when the JVM starts up.


Google Musings

Aristotle is thinking laterally. This reminded me of a talk I saw last night by Jack Cohen. He presented a brilliant slide (which I appear to be utterly unable to locate) of a sign in some public place, with the same idea in two languages:

  • Lost Property
  • Objets Trouvée

Two completely different ways of thinking about exactly the same thing. Trying to think like this is a good habit to get into.


Perl Improvements

I’m very pleased to see that Nicholas Clark has been given a grant for improving things in Perl. The stuff is useful and should bring big benefits to all Perl users.

The one thing that really catches my eye is “making Perl relocatable”. This is a large annoyance for us at work, where we have multiple Perl installations that are ever-rooted in the same directory. Because they live in directories that are versioned after their projects, it requires that when we perform a new release of our software, we have to rebuild Perl, and all its dependencies. This is irritating, although thanks to Moore’s Law, not too bad these days. But a relocatable Perl will make this a lot simpler.


MySQL vs PostgreSQL

At work, we’ve just started converting one of our projects to use MySQL instead of the present PostgreSQL. Due to client orders, you understand. Unfortunately, after using PostgreSQL, coming up against MySQL reveals how bizarre, baroque and arbitrary it is.

  • CREATE TABLE automatically creates a transaction. So much for that schema loading script undoing its changes if it fails.
  • TEXT columns aren’t like PostgreSQL’s infinite length VARCHAR. They’re more like a 64k long blob. Heaven help us if we go over that by accident (which is not improbable).
  • Oh, and TEXT columns also can’t be primary keys. You have to switch to varchar for that. This is a minor (but seemingly gratuitous) incompatibility.
  • I defy anybody to make sense of MySQLs handling of date & time data types.
    • Firstly, you have to choose between datetime or timestamp, which appear to be different variations of the same thing. Except that there’s no choice because you can’t appear to set a default value on a datetime column. So you have to pick timestamp.
    • And then you have to understand TIMESTAMP Properties as of MySQL 4.1. This is incredibly obtuse, but manages to just about make clear the utterly arbitrary limitation that only one column can have a default value. That’s just wrong. No, really.
  • DROP USER doesn’t drop a user unless they have no privileges. What’s the point in that? Thankfully, this seems to have been fixed in later versions.
  • One minor, but exceedingly annoying faux pas: ^W in the mysql command line doesn’t delete the previous word. It deletes the entire line. Strictly contrary to every other user of readline.

I’m using MySQL 5.0.16, which I thought had grown up beyond all this sort of thing. Oh well. None of this stuff is an impenetrable problem, but it’s also certainly not endearing me to us MySQL for future projects.

Update: Just for amusement, witness TeeJay having even more pain going in the opposite direction.


Timely Advice

Andy Lester gives out some excellent advice in Help save the endangered time servers. If you haven’t configured your computer to use, it’s well worth doing so. It will mean that your computer has a much better notion of what the time is.

On a related note, I was immensely pleased to see that Windows XP finally came with an NTP client when I got given a new PC at work last year. So now windows users can trust their clock as well.


zsh globbing

I love using zsh—it’s full of completely insane features that you wouldn’t even think of using. Until you come across a situation and think: That’s exactly what I need!

Today’s example is recursive globbing. How to pick out all the non-image files in the current directory? I needed to run docs2unix over them. You could come up with some evil find command, but in zsh it looks like this:

  % dos2unix **/*~*.(gif|png|jpg)(.)
  1. **/* picks out all files and directories, recursively.
  2. ~*.(gif|png|jpg) excludes images from that list.
  3. (.) ensures that only files and not directories are chosen.

Easy, peasy. :-)

Update: Even better, case insensitive globbing!

  % dos2unix (#i)**/*~*.(gif|png|jpg)(.)


I’ve spent some time this evening playing with SwitchTower. It’s a tool for deploying Rails applications. It’s just perfect for sending what’s on my test environment (Mac) up to my server (FreeBSD). Not only that, it’s relatively simple to get going, compared to many other deployment tools I’ve used (and written) in the past.

But it’s also very flexible. For example, just when I thought I’d gotten everything set up and running, I discovered that my database.yml file was wrong. It’s fine for development, but not the live server. Yet switchtower has a really handy feature where it can render a template into a file. So now I get my database.yml generated on install, pointing at the right place.

task :after_update_code do
  buffer = render("config/database.yml.rhtml", :shared_path => shared_path)
  put buffer, "#{release_path}/config/database.yml", :mode => 0644

Anyway, if you’re doing Rails at all, invest some time in learning SwitchTower. It doesn’t take long, and you’ll be much better off for it.



If you’ve more than one computer at your desk, and one of them is a Mac, you need osx2x. It lets you use all the other computers via VNC or X-Windows connections, using only the one mouse and keyboard. Shiny.

Sadly, the download link on the main site is broken. This is a bit of a pain as it doesn’t appear to be mirrored anywhere.

Luckily, I found one chap who had created a fresh distribution from the (still available) source: osx2x Mac OS 10.4 (Tiger) Universal Binary. I’ve installed that version and it’s working great. My sincere thanks to jamesotron.

Update: Annoyingly, I can’t figure out how to right click when talking to the windows box. That’s a bit annoying.



Finally, after much nail-biting I gave my skillswap presentation this evening: An Introduction to Version Control. Thankfully, I had a delightful audience, who asked lots of very sensible questions. A few people said that they’d go away and try subversion, so that’s a win. Version Control is such a safety blanket to me, I don’t understand how people can do without it…

Anyway, it seemed to go well and I didn’t manage put anybody to sleep. :-)

Huge thanks to Andy Budd of course, for organising the whole SkillSwap thing. It’s a great idea, and I’ll certainly be enjoying more of them in the future (and contributing where possible).

Update: One question that came up that I didn’t have an answer for was the question of dreamweaver integration with subversion. There appears to be some commercial support from SVN for Dreamweaver. Costs $59 (£33.90 according to Might be useful.

One other option might be to set up the WebDAV autoversioning support in subversion. This means that you can just use Windows’ “Web Folders” to copy files in, and store them in the repository. It’s not as slick, however, and does involve extra server side setup.

Update#2: Damien Tanner kindly posted a photo of last night’s events:

SVN Skillswap


Rails Deficiences

There’s been quite a lot of criticism of Rails recently:

But the fact of the matter is that Rails gets so much right, that it’s still worth using. And I intend to.

Not only that, but I have every confidence that these issues will be addressed. In my case, I can see from the tickets that the whole area of database defaults is being revamped for Rails 1.1, so I’ll probably end up upgrading shortly after it comes out.

I’m reminded of the furore about the Google Web Accelerator last year. In that case, Rails was clearly in the wrong, and I said as much back then (although not fingering rails, apparently). In the end, a moderately sensible comprimise was reached: You can supply a :post parameter to the link_to command, in order to try and ensure that something gets submitted via post. It’s not perfect, as it relies on JavaScript to work, but it goes a good way to making it easier for people who don’t care to do the right thing.

In summary, Rails ain’t perfect, but it’s getting better all the time. And the way to speed it up? Patches Welcome.