SwiXml Review

Externalizing the screen layout is a natural step for many applications. It can be because a customer might want a slightly different presentation, or just for the sake of clearly separating layout code, or for using a kind of screen generator. Back in 2003, I wrote a small utility to help with GridBagLayout, nothing fantastic, but there was the feature of saving a generated layout in XML (or Beanshell) and using it in an application.

SwiXml saves a bit more than a layout as it instantiates the components as well, allowing to represent a hierarchy of components in XML. But it does not more than that. The "no generation" approach is interesting, I bet the author thinks the XML should be kept concise enough to be used easily without using a kind of generator. the XML is almost a mirror of Java code, but fortunately makes layouts more compact and easier to read. I tried version 1.51, and while it is quite well done, its documentation is a bit lacking and to me an important functionality is missing:

There is no "component" tag by default. One needs to explicitely name the class of component we want to add. I think there could be a component tag that instantiate an 0 parameter constructor by default, using reflection for example. The class of component to instantiate would be found through the field name.

Fortunately SwiXml is quite well done and this is not that big of an issue since you can just interpret new tags with 1 line of code:
engine.getTaglib().registerTag("datecombobox", DateComboBox.class);

for a Jide DateComboBox.

I said documentation was lacking, because in my first non Hello World trial, I wanted to use the standard constant names for GridBagConstraints (RELATIVE,REMAINDER, FIRST_LINE, LAST_LINE, ...). Putting <gridbagconstraint anchor="FIRST_LINE">did not work. By reading the code, I found out you could achieve it but you have to do <gridbagconstraint anchor="GridBagConstraint.FIRST_LINE">.

In the end SwiXml left me with a good impression. It is non intrusive, and handle well enough what it is done for. One major drawback, you can only use either BorderLayout or GridBagLayout or FormLayout (from JGoodies).

Better Java Swing Development

It has been a while since I have looked at the different options for building GUIs in Java. I like the approach taken by Eclipse, they provide not only GUI components, but a complete GUI application framework. Several years ago, I have stolen ideas from it (how they manage plugins) and applied it for Swing applications. This worked out quite well. The Netbeans platform now offers a more interesting alternative if you have to do Swing. The major drawback when compared to Eclipse, is that since the beginning Eclipse was all about making a platform, while Netbeans copied that idea only relatively recently and is less active about making it so. IBM uses Eclipse foundations for many of their products successfully.

Unfortunately on many projects, a Swing application is already there and all you have to do is add more screens, more forms. What I am trying to see here, is what could help Swing development is those cases.

JGoodies


JGoodies is old now, but can be quite useful in creating nice looking forms quickly. It is basically all around a layout better tailored to forms that the can do everything GridBagLayout.
It can help but it does not make a significant difference vs good practices with the GridBagLayout.

Jide Software


Jidesoft provides much more than JGoodies, but is not free (except the Jide Common Layer). I have used it in the past and found their API quite clean and easy to use. They offer more elaborated Swing components that should be part of the JDK. They started to go to the platform area only recently with their Jide Desktop Application Framework, which is not free either. I am not sure I would base an application around an unfree framework.

SwiXAT


It is a recent BSD licensed project based on top of Swix. It is basically MVC for Swix, with command binding in XML. I need to look more into it, it seems to provide an "application framework" as well where you have to launch your app through a SwixAt class (which IMHO sucks). I hope it is not a requirement and that only parts of it can be used and integrated into an existing application. I will hopefully have time to try it more concretely and will blog about it. In any cases it looks interesting.

SwiXml

An Apache licensed project, it seems like a decently used way of laying out swing components in XML, inspired by XUL. It might just be enough. Or is it just too similar to  Java code translated to XML? I need to investigate this more.

JavaFX

JavaFX is probably the serious alternative to SwiXml. I like the idea of a better grammar to lay out and assemble components instead of using XML. Unfortunately it seems a bit invasive to start using for a part only of an application

I took a quick look at Swing Application Framework (JDNC2 redone once again). While it has interesting use of annotations, it seems very far from what Eclipse offers. And I don't feel like it will improve working with Swing a lot. I think except JavaFx, Sun seriously fucked around during many years with Swing. IBM has been much more focused and effective.



Fedora 8 vs. Ubuntu 8

I had the bad idea of trying (K)ubuntu 8.04 on my home computer. It worked for a few days, but as Ubuntu 8 is still in alpha, changes tend to break everything easily. At one point Wine stopped working, then the DVD, then the sound. I had crashes with USB plug/unplug. It was time to go back to a stable distro. I went back to Fedora 8.

I found out that I had missed some positive sides of Fedora 8 before. It compares quite well with the future Ubuntu 8. Both include pulseaudio. Pulseaudio in Fedora 8 is very well integrated, works well by default. I had to manually tweak things with Ubuntu, probably because it is an alpha.

Both have a relatively new kernel (2.6.23 for Fedora 8, 2.6.24 for Ubuntu 8).Packages I use everyday are as new in both Fedora 8 and Ubuntu 8.

Fedora 8 is also more stable than it used to be on my machine. Fedora people do their job very well at fixing various bugs after a release.

2 drawbacks of Fedora:

  • the package management. I know by experience that rpm+yum is more problematic with dependencies than apt.
  • Sun Java not installed by default (IcedTea instead). Being a Java developer, the reference is Sun JDK. Plus Sun JDK is open enough for me.

Other than that, Fedora 8 is excellent. I feel it has more features than Ubuntu: pulseaudio already well integrated, SELinux, Firewall by default.

Don’t make the same mistake, don’t install an alpha linux distro. It used to work without problems back in the days. I have used Gentoo, Slackware with custom kernel without troubles. Nowadays it seems quite risky to go without a distro that has not been well tested.

Windows Vista Is Crap!

It has been already 1 year since Windows Vista is out. In my new company, I had a new computer with Vista on it. I quickly installed Ubuntu in dual boot. I was happy with Ubuntu for my work, until I received many Excel files OpenOffice was not able to read properly. I decided to give a try to Vista. My first impression of it when I had the computer was quite negative. I was not able to find things that used to be easy to find. It seemed slow and not very interesting.

As I thought I had to use it, I managed to make it a bit more pleasant by adopting the old Windows 95 style instead of the default colors and effects everywhere. I dislike the standard effects because it seems that they are only there to distract you from what you want to do with the computer, and don’t help you to do things. I have used Windows a long time before, and installing Total Commander and Opera made Vista a bit more responsive for some tasks. Explorer is really slow and bloated.

Still on the big Java project we are working with, it took 14 minutes to (clean and) build the first time. I struggle to find out why it was so slow. Under Ubuntu, the same command took 5 minutes. As I thought it was swapping to disk, I decided to order more RAM so that I have 3GB (the build process takes around 1GB). If I build it many times in a row, because of the file cache, I can have the build in 4.30 min but it never happens in real life. In real cases it always takes at least 14 minutes, event with 3GB. And it still seems to swap !?! Now I am not even sure of anything, the fact is I did not manage to make it faster. I tried messing with various registry parameters for the cache/memory with no success. This article is completely wrong about Vista memory being much better managed. It is really awfully managed. That frustrated me how a new OS can be 3x slower, until I heard about gnumeric. Gnumeric is able to read all kinds of difficult Excel formulas, and all my Excel documents worked under Ubuntu.

So after 2 weeks of experiencing the slowness of Vista, and the first blue screen (BSODs are back with Vista), I switched back to Ubuntu. Other than being awfully slow, Vista does not have that many drawbacks, but it does not have anything compelling either when compared to XP (except a maybe better security system).

The 2008 Java Web Framework

One of my first web framework was a custom one, based on the book Web Development with Java Server Pages. That was in 1999, when Struts was not yet known. But it was web-MVC, very near from what Struts gave later, without the custom tag stuff (custom tags were not yet part of JSP specifications).

Until 2007, Struts was IMHO the most used web framework and the default choice, even though many contenders appeared, with more features, better code. 2007 saw the maturity of some of these framework. As similar framework to Struts, I particularly like Stripes, because the API is very lean. Some component frameworks got a lot of buzz as well, Tapestry some time ago, and today Wicket. I tried both, and while they are very interesting, and can be very productive for some tasks (web application more than web site), I am not convinced they are the tech of 2008. Web Applications are better done with Flex, or GWT.

The major news in the past few years has been Ruby On Rails. Everybody tried to replicate it in every language (with their own twist):  Django in Python, Lift in Scala, ErlyWeb in Erlang, Cake in PHP, Grails (along with now abandonned Sails, and less populair Trails) in Java. And some people fought for making the point they had the idea before Rails. But Rails is what made Rails-like development popular.
After trying Rails soon after it was out (way before 1.0) and more recently (just before 2.0), I was amazed by the progress of Rails. I was impressed in 2004 about Rails, because the approach was new and effective. I disliked a bit the choice of Ruby. In the end in the project we ended up rewriting the persistence layer because our application was very specific. And I ported the app very quickly to Java. In 2007, I was even more impressed, and did not need to dwelve into arcanes of Rails anymore, but merely using it was enough to do lots and lots of things.

In 2008 the Ruby On Rails mentality will continue to prevail. In the Java world, Grails is the most likely to benefit from it. But I would not be surprised if there was another new Rails-like contender in the game (Rails on JRuby?). It could also be something based around Spring as their current MVC solution is not very good and very old fashioned.

KDE4 Still Not Ready

I tried KDE4.0 last week, when it was everywhere in the news. I was very disappointed.

I have a long experience of trying beta software, not well known software. I have used Linux since 1998 (partly). I have even used windows beta at one point. And I have seen nothing as crappy as KDE4.0 release.

It is not usable at all.

Now I can understand what are KDE motivations to do such a bad release. It is to gain momentum in their project. KDE4.0 is in development at least since 2002 - 6 years! By creating a .0 release now even if it is an alpha, they have at least something officially out and hope to have developers starting to improve it. It is especially important for them because Gnome has, in the mean time, made regularly lots of improvements.

I admire the initiative, KDE 3.5 needed lots of improvements, and KDE4 goals are the right ones. But it just feel like the release was more political than everything else. Hell, even Linus seems to use Gnome nowadays.

Fedora 8 - The Comeback

My previous post about Ubuntu Gutsy vs Fedora 8 was weak. It is difficult to find a very good distro. Depending on the computer, I have had different experiences. On some computers, Ubuntu really shines and work with minimal tweaking. On some others, Ubuntu is unstable/does not handle wireless correctly and Fedora is much more stable.

The main issues I can see with Fedora 8 are:

  • LVM by default. I don’t think it is a good idea to go LVM by default since lots of basic tools are still not handling it properly. And if you want to read your disk by something else than a distro with LVM you are screwed. Ext3 straight is imho a much wiser choice. Plus it is rarely a problem to resize partitions as it is not something one does often.
  • Fewer programs in the repositories available. Under ubuntu, I was using gtkguitune to tune my guitar, it was in the default repositories. It does not exist for Fedora and I did not manage to compile it due to too old dependencies (GTK 1.2). I found accordeur on sourceforge which is a better program and is available as RPM, so in the end I found something. But while searching I saw the choice was not as wide as with Ubuntu.
  • Packages too small: it is not exactly clear what packages you need to start compiling programs with Fedora. If you look in the default categorization, way too many things are silly to enable by default. Also generally package management seems less stable/less easy to use than with Ubuntu.

What I like:

  • newer Linux kernel, with better scheduler. Fedora seems more responsive.
  • bluetooth relatively well handled by default. The standard method of editing /etc/bluetooth/default works well to plug keyboard.
  • wifi well handled by default. I had lots of problems with Ubuntu on my computer and the wifi card, I don’t have them with Fedora.

Next step:

  • maybe try Suse 10.3 as I just found out that Amarok is the best music player on earth today. As music playing is very important for my computer, a KDE based distro makes sense.

But that would be a silly typical Linux user reaction.

Haskell Fibonacci Revisited

Recently, there was an interesting post about Haskell performance and Haskell parallelization showing Haskell could outperform C on a simple Fibonacci example.

A friend of mine, Peter (that I seem to manage to constantly piss off) thought about it on another level, saying you could achieve a _MILLION_ times better using a direct formula in C or Java, the Binet formula.

I decided to try as the improvement scale seemed a bit surprising. I first compared a Java recursive fibonacci with a Haskell one. Here are the results for Haskell GHC 6.6.1 vs Java 1.6.0 on Linux for fib(44):


Then I decided to check out the time for fib(44) or any fib at all, I was unable to measure precisely enough since it always came out as 0ms, in Haskell, or in Java. Looping out 10 million times, Java gave out 7.3s and Haskell something similar (but my method to loop 10 million times in Haskell is probably very bad).


The original post actually points to a link that describes various algorithms for Fibonacci. They basically say that for large n, the rounding is not precise enough, they also propose algorithms in log(n). I tried and was really impressed by the performance of those algorithms. Again I could not measure the difference for a single calculation between it and the binet formula as elapsed time is always 0. The binet formula becomes inexact already at n=71 in Java with doubles.


Of course the original post is still quite interesting, it shows how easy it can be to parallelize calculations in Haskell. But the example is silly as another algorithm can lead to 10 millions times the performance. Still Haskell performs well with the shit or good algorithm when compared to Java.

Ubuntu 7.10 vs Fedora Core 8 - Gutsy vs Werewolf

I was pretty happy with Ubuntu 7.10, but when Fedora 8 came out I decided to give it a try. Last time I tried it it was Core 2 or something like that, and it was NOT good.

At first Fedora 8 looks quite good, has a good Live CD install, reminiscent of Ubuntu. The positive side is that it is based on the latest Kernel. It manages my Thinkpad T42 very well (suspend, hibernate work). But after a few days, one notice Fedora is not as stable as Ubuntu, for example:

  • I have had weird behavior with windows not being updated properly
  • I experienced big problems when playing with LVM,
  • It is also a general impression when interacting with the system.

One can wonder why Fedora 8 does not install OpenOffice by default.Ubuntu is IMHO still the king of distros.

Apache DbUtils Completely Useless

I am disappointed about the Jarkarta Commons DbUtils project. I give a link to it, because it’s a bad project (even if written in clean code). It is very simple, but it really does not do much for you.

I was looking for a very simple abstraction of JDBC. I thought bringing Spring in my project would be overkill. After trying DbUtils, I think again. It does not help. It does not handle frequent cases well, and it does not save many lines of code.

I am a bit angry about it as I noticed that by using it, my test program that was taking 2s with straight JDBC before is now using 1 minute!

The reason behind this huge performance penalty is that there is no way to just reuse a PreparedStatement with the existing classes. For each query with a same sql, it will create a new PreparedStatement object, even if you reuse the connection. I am surprised since this is probably why PreparedStatement is used in the first place. How can such a project be part of Jakarta repository?

Now I just wish Spring was more Guice like, maybe I should write a Spring JDBC like layer for Guice.

Previous

Next