- Blog -

(A cheesy homepage for Justin Collins)
UI in Java and Ruby

For my research, I need to implement a shared whiteboard, which is a fairly common example of collaborative software. I’m doing it with three different projects handling the communication side of it. Since two of these can be directly tied in with Java, it made since to start with a Java UI. The third, for some inexplicable reason, chose to implement IPC through a C interface. So, for that one, I’ll be writing the UI using Ruby.

I have completed a basic prototype for both, which just implements the ‘drawing’ part of the whiteboard. They have exactly the same amount of functionality (draw lines, save the history) and do it basically the same way (start line on mouse click, save points and draw as the mouse moves). I didn’t try to make these as short as possible, just as equivalent as possible.

The Java version, using AWT, is 95 lines long. The Ruby version, using Tk, is 50 lines long. Not too big of a difference, considering how short they are.

However…each line in Java seems quite a bit longer than the Ruby version. What if we compare based on the number of characters, rather than the number of lines? Hmmmm…the Java version comes out with 2831 characters, while the Ruby version only has 978! That is a lot less typing! (A third, basically).

Oh, well. Sigh…

Edit: Oops, I forgot I also wrote a convenience class for the Java version that stored the history. But it wasn’t really necessary and I did not do so in the Ruby version, so the comparison above is still accurate, I think.