When I was in my third year at college the programming language selected to be taught to us was Java. At the time, I was quite dissapointed, I had wanted to learn C and that was what it had been reported we might be learning.
I never took the class.
This is a shame, because one member of the IT faculty had actually written 3 books especially for us to learn from, and I heard from my friends who did take the course, that these mammoth books (each almost half a ream (sp?) of A4 paper) were great. I laughed and went about my more important business of working with PHP.
This week, I wanted to write a GUI application, and spent some hours deciding what to use. Here is my list of options:
- Visual Basic – I know it, its easy. Windows only.
- PHP + GTK – Again, I know it, its fairly easy, PHP 4 only, cross platform. Sort of.
- C + GTK – I don’t know it, but the PHP-GTK stuff should be fairly similar (naming/use wise). Cross Platform. Sort of.
- Java + SWT – I don’t know it. I hate Eclipse. I’ve read SWT sucks on some platforms
- Java + Swing – I don’t know it. Cross Platform.
- Delphi – I don’t know it, but there is Kylix, the Linux compatible version…
One of the major factors in this choice was that I was going to be distributing it with a PHP application,
therefore I wanted it to be as cross-platform as the PHP application.
Because of my dislike for AWT and the issues I’ve read about, I finally decided on Java + Swing. Let me remind you that I never took but 2 possibly 3 hours of my Java class. I certainly didn’t get past variable types.
I decided on using NetBeans IDE 4.0 to develop in, I didn’t like IntelliJ IDEA nor as I said, Eclipse.
Over the course of about 8hrs in the last two days, I’ve now managed to write part of my application. I have a main window which opens up maximized. It has two menus with sub-menus. I have an “About” popup dialog which dissappears when you click it. I have a toolbar with pretty PNG icons on it, and… thats it.
I only have two menu items, “File > Exit” (which has a Confirm popup) and “Help > About” working.
But, I have it using the OS look and feel on WinXP, OSX and SuSE Linux + KDE, and working on all three platforms with nothing special being done on any to make it work.
I am quite amazed at how much I’ve managed to accomplish considering my prior knowledge of Java was close to none. I’m also amazed at how fast the application is – not that it does much of anything yet.
I’m going to continue to develop on this over the next few weeks and see where I get with it. But one thing is clear, Java + Swing sure beats the hell out of PHP + GTK. I’m certainly not interested in moving to JSP though.
There is one thing that bugged me so far, its possible in Java to specify that something must be in a try...catch block and if its not… you get an exception. This is the case with the code that sets the option to use the OS look and feel. This threw me off for longer than any other problem so far, it seemed odd – I hope PHP never gets this functionality.