Originally posted by Gregg Bolinger:
Swing being slow is a common misconception. Slowness in swing apps is due to bad programming.
I keep hearing that sentence and it leaves me frustrated everytime. Why is it that, if you run Swing source code written by authors of various books, they do not "optimize" the code to make it "look" fast? How can such popular authors who have years of experience in writing programs also produce such bad software? Why is JEdit, Netbeans and OpenOffice so poor? These are written by software companies as commercial software. But these are still slow - how can every vendor be writing "poor" code? To me, it seems that you must be an expert and an experienced Swing programmer to be able to "write good code" so it can run fast. Only then can you write compariable native applications. But I am yet to see a commercial application written in Swing which is fast - prehaps because even writers themselves realise that no matter how well the code is written, they cannot get it to "look" fast to the end-user. That is why developers keep churning out slow Swing applications and end-users continue to say "Swing is slow". I bet the developers are thinking: "Hey end-user, we tried really hard to make it run fast and our team of professional developers did everything, sorry it still looks slow though".
For me, Swing just doesn't cut it. First user preceptions of Swing is "its slow and ugly looking" and rightly so. You need to have a good argument to change their opinions - you cannot change first impressions can you? Why should you as a programmer need to write so much code to do the most basic of things to make it run faster? You can write a very good looking application in SWT with
very basic knowledge of the controls, and it runs as quickly as a native application. That is why SWT is much better than Swing because it does not require you do have a Ph.D in multithreading and GUI issues. End-users judge software on how its GUI looks and how well it runs, and Swing applications always leave me with a horrible feeling afterwards. You need to write more code in Swing than in SWT to do the same thing if you want to make Swing really fast (supposedly). Ask yourself why Eclipse is so popular - if it was written in Swing, I doubt many people would use it. Look at the forums on javalobby.org under the "Swing is slow" discussion, professional developers echo this opinion. Look at NetBeans, its slow and ugly. If the software company (with supposedly professional developers) who made NetBeans cannot write good code to make it run faster, what hope is there for the rest of us? How can you encourage new Java Developers to learn Swing when the biggest vendors producing Swing software cannot make it run any better?
IBM have really embarassed Sun with SWT. So what if it uses native libraries and needs a different .dll for each platform? (if thats a problem, write a good installer with all the libraries for the major platforms). Its a
very very very small price to pay compared to what you get back (how hard is it to copy half a megabyte dll to the Window dir?): a nice and fast GUI which is easy to code and understand, with the knowledge that the code is still cross-platform and that a popular IDE (Eclipse) has been successful because of it, having won Java fans from across the globe.
Good enough for me.
[ February 13, 2005: Message edited by: Kashif Riaz ]