Monday, November 29, 2010

c++ is the future? the present?

I was away for a long time, not because I don't have anything to say, just because I was working on my own product, I created d-jon (check it out in

But why am I telling you this? because I want to discuss what is the best language for multi-platform desktop applications.

I've been working in c++ for the last few months, and I'm in love with that language, but... as most of the love experiences it started with hate... sometime ago I'd to work in c because most of our Universities had it as the main language and you should do all the homeworks on it... as usual you felt on some typical mistakes like memory leaks, unwanted behaviours, etc. But lately I started to wonder how difficult is to create applications for desktop in java... (hey... wait, don't kick your reading, let me explain why), I'm one of the java swing lovers, I think it's a great part of java and it has a very good architecture, it's flexible and etc.

But one of the problem of java desktop applications it's the java itself, imagine the following scenario. You created a desktop application and you want to distribute it, you're going to face one problem... you can redistribute the jre with your application or you could let the user use their current version (if they've any) or download the lastest jre version available on internet. Both scenarios have their own challenges, like: where am I going to put the java in order to avoid the JAVA_HOME and/or CLASSPATH environment settings problem?, what if they already have another java version required by some other applications? I know, you can install as much as java versions as you need, but that's true if you know what you're doing and face the settings in a batch file... not if you want to put your software and get 100 downloads every day and expect that each user has this knowledge. Other problems that comes to my mind, is how are you going to handle some native tasks relying on the operating system? let's use d-jon as an example of this, if I need to get the "idle time" you cannot install a hook or something using java... maybe you will jump and say: "hey!!! you can use the native calls to create this" that's true... but you'll need to create all the stuff that comes to this approach, it's not easy after all, and what if you are creating an application that will be deployed in several platforms? like linux, windows and mac? each platform has its unique APIs to do the same thing, in C you could use conditional compilation and create a different executable for each platform and that's it, if you address this in your architecture you will be able to do what ever you want. Other issues that comes to my mind, now that I wrote apple, is how to you create a native look and feel in java? it's not possible, you could use look'd feel and put your buttons with the same look as mac... but you will not be able to put the menu in the mac's main menu, like the native applications does. And what about system tray icon? I know that java implemented that in java 6... but mac does not have java 6, their last version is 5.

Last, but not least, what about the swing performance? d-jon should be deployed in new computers as well as old pcs, and I need to address a very big gantt diagrams, swing is not really that good.

My conclusion is... if you want to do a good shopping cart web application use java... it's the killer, if you want to use an application that will be on internet, and you don't have the money or infrastructure to create your own public server, use PHP and if you want to create a very good desktop application that will be portable across all kind of OS and architectures use C++ with Qt, GTK or any other multi-platform framework, my advice... use the right tool for the right job.

No comments: