Friday, March 30, 2007

Working with Java

Or should that be Working against Java...

I've more-or-less come to the end of a project refactoring a large Java GUI application for my company and I now feel I can justifiably have a practical opinion on Java. This was my first commercial work with Java and I'll compare it to C/Python/GTK+ which I have used both commercially and in open-source projects.

Java is far more complicated than it should be. Count the number of methods each class has when browsing the documentation. The complexity of the standard library exceeds the complexity of the problems you solve with it. Compare it to the Python or even C library. Instead of containing the basic tools and tools that you use frequently it's full of cruft. I think the programmer should either build up more complex functions themselves or use higher level functions from a different namespace (compare GL and GLU libraries in OpenGL).

AWT and Swing are just a complete mess. Sure this is for historical reasons but Java needs a serious replacement. Maybe SWT is it but if some leadership is not taken to make a "standard" GUI that works I cannot see vanilla Java surviving compared to something like .NET. Case in point, java.awt.Component has four variations on getting keyboard focus. And reading the documentation on each is just worring... You may not get focus, you should use the requestFocusInWindow() because it is more cross-platform. I used to work with a commercial Java developer and he described the cross-platform support as write once; test n times. I now understand.

Packing in AWT/Swing is just too difficult. The simple packing models are too simple for most cases and the complex ones create too much code. While the GTK+ model is more complex to start with I'm always surprised how my windows "just work" (try shrinking a Java window and see everything get messed up). Java needs a universally accepted equivalent of Glade or XAML.

Connecting signals takes too much code. Using Listeners requires you to write loads of empty methods to catch signals you want to and Adapters can't be inherited if you're already extending another class. I hate inline classes with a passion (so much code for so little behaviour!). Using SwingUtilities.invokeLater() (which is a really practical method that should be more central to Java) to create a runnable class every time you want to access one method later? Overkill. Why not just gobject.idle_add(method)?

Threading... All I can say is threading is an optimisation. I've seen too much excessively threaded code that is very hard to maintain. Java seems to implicitly encourage you to thread which I do not like. I don't like that a lot of the Graphics operations don't seem to have an easy way of doing them synchronously. Threading is an optimisation.

Really it's the library that lets Java down. The language is a huge improvement over C. It lacks a little in low level access (I have not really done this in Java but from a first glance it may be missing something like Pythons struct module). I dislike the lack of flexibility over Java but I do like the compile time checking for catching bugs. I must try a .NET project to see if .NET doesn't have the baggage Java does. I get the impression the dominant members of the Java community have the opinion "Don't change anything, we've got too much code" as opposed to "Keep version X stable as we have lots of code, but make version X+1 fix the big problems in X".

My opinion of Java? Not ready for the enterprise :)

Tuesday, March 20, 2007

Damn broken VMWare

Why are the Ubuntu VMWare packages so flaky? Every time I've upgraded the kernel (i.e. standard updates) VMWare player ceases to work. This has happened in both Dapper and Edgy and I'm surprised it hasn't been fixed as the way to reproduce is:
  1. Install Ubuntu from a CD
  2. Install VMWare player
  3. Use VMWare player. Works (fairly - see below) well
  4. Perform a security update
  5. Pretty much broken from now on...
I was trying to find some bugs in the mess of and there doesn't seem to be any bug collection (?). Googling seems to show others on the forums etc have the same sort of problems...

Some clues:
  • The kernel modules are not loaded on startup. If you try and use modprobe they're not found. If you use insmod they load OK.
  • Running /etc/init.d/vmware-player start says neither vmmon or . I think this is because it is trying to use modprobe
  • If you run the player after insmodding then it runs but networking doesn't seem to work. In general the networking seems very flaky.
And the last time I ran it it didn't want to quit and had to be killed. I wonder what state my image will be in next time I get it working (based on experience the first time I install Feisty!).

And why is the performance of the player so poor? Applications inside the player often pause inexplicably for a minute or more (I think it may be related to networking, for example try ifup with DHCP). Sure it's virtualised so I could understand if there was a resource problem but both CPU and IO are not active. So I just don't know what's going on.

So if anyone is wondering why there aren't any glChess packages from me for non-Ubuntu Dapper systems, now you know.

Saturday, March 17, 2007


Seems like got slashdotted:

Good to see the quality of the comments were absolutely rubbish. Why actually try/investigate something when you can rush and post about it! :)

Bonus points if anyone can actually confirm the dialog has bad grammar as some of the comments say.

Another sneak peak...

As usual no promises on getting this past the screenshot stage at any particular time...

Friday, March 16, 2007

Sick today...

...but every cloud has a silver lining! I have time for open-source. In an attempt to reduce the millions of Gnome Sudoku bug reports flowing into my inbox I've had a crack at some of the worst offenders. I think I've knocked about five on the head so things should be more stable now.

Unfortunately a lot of the bugs are due to a save file being corrupted. Once this has occurred Sudoku will always crash on startup. So we'll have to wait until a month or so until 2.18.1 is released to get some relief from bugbuddy...

Monday, March 05, 2007

Java + keyboard bindings

= Insanity.

I want to connect all input keys to a single widget. And I don't want to have to use 16 classes in the process. And I want all the Java library developers to get their come-uppance.


Python GtkGLExt now in Debian Unstable. This works for me (I get to be lazy and eventually stop providing anything for Ubuntu) and good for you (it's available in all the architectures that Debian builds for). Big thanks Thierry Randrianiriana for maintaining this.

Sunday, March 04, 2007

Boo's chess engine

I've just packaged Boo's Chess Engine (or BCE, or BACE, or ddlchess as it is known...) for Debian/Ubuntu adding another easily installed AI that works with glChess. I think I have some sort of addiction finding open source chess engines and packaging them :)

p.s. I found it quite funny posting the same article twice!

Saturday, March 03, 2007


The other day I happened to look at the ASCII table and was surprised that I had never read and understood the C0 control characters! For something I've used for so long I thought that was pretty funny :) Way, way back when I started programming with QBasic I remember looking at the table but all the non-printable stuff looked "too complicated" so I just ignored them. I suppose I should have looked again when they weren't too complicated any more.

In my previous job there were a number of ASCII/Binary protocols that used STX (02) and ETX (03) for framing transmission. This now makes a whole lot more sense...

Oh and software flow control seems quite simple now. I'd assumed there was some sort of escape sequences to do this but hey, there's the characters right there!