wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes SWT is faster, no Swing is faster.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "SWT is faster, no Swing is faster.." Watch "SWT is faster, no Swing is faster.." New topic
Author

SWT is faster, no Swing is faster..

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I'm sick of this debate. I think it's a non-issue because I don't believe one API is more responsive than the other. However, some people seem to think so. So the challenge is, prove it. If you think SWT is faster, prove it. If you think Swing is faster, prove it. Give me something tangable here other than "The swing apps I create are slow". Please?


GenRocket - Experts at Building Test Data
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Greg I absolutely agree with your point. About (hatefull) X vs Y: it's human nature: every comparison of this type will finally end like no args comments - check TSS threads.
I am neither a Swing nor a SWT guru. The last 2 applications I have developed were based on SWT and Swing, respectively. We have chosen for the 1st SWT as our tests prooved SWT was better for that solution (requirements: old Linux machines, under 1s data refresh, tabular read-only presentation). For the 2nd our tests prooved Swing will fit better. This is all. It was our tests, that was our conclusion. Should I dismiss it directly? Nope. Both projects were huge successes. Should I praise it everywhere? Nope. It were just 2 special cases.
It is quite impossible to proove that overall one of them is better. The comparison is way to complex. There are many points to compare (learning curve, documentation, support, extensibility, customization, ease of dev, ease of maintainance, and so on).

cheers
--
./pope
[the_mindstorm]


blog - InfoQ.com
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Gregg Bolinger:
I'm sick of this debate.

Me too... It's similar to the debate of JSF vs. Struts... Isn't it?

Never-ending story...

So till we got official benchmarks on SWT and Swing, we cannot conclude that SWT responsiveness is better than Swing, as you said, Gregg... You are right that we must provide a proof to say which is better...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Don Kiddick
Ranch Hand

Joined: Dec 12, 2002
Posts: 580
Totally agree with you Gregg
D.
Lionel Badiou
Ranch Hand

Joined: Jan 06, 2005
Posts: 140
Hi all,

To my point of view one should consider using SWT when :

- Display performances are really critical
- You can afford the "DLL overhead" for your application (one DLL for each platform with SWT)
- You can easily manage the SWT's garbage strategy in your Java application(as far as I know, SWT doesn't use tradtional java gc. To me, that's error prone to use two different garbage strategies in a same application)

That's just an opinion to this never-ending debate ;-)

Best regards,


Lionel Badiou
CodeFutures Software
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
The gc mechanism is the same. The problem is that SWT widgets have a hook to a native widget. This is why it is recommended/good practice/mandatory to call dispose on your widgets.

--
./pope
[the_mindstorm]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

- You can afford the "DLL overhead" for your application (one DLL for each platform with SWT)
- You can easily manage the SWT's garbage strategy in your Java application(as far as I know, SWT doesn't use tradtional java gc. To me, that's error prone to use two different garbage strategies in a same application)


And to me, these are reasons to not use SWT.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Lionel Badiou:
- Display performances are really critical


Did you not even read my first post? If you say this, you have to prove it. Prove to me display performances are better with SWT. I dare you. I double dog dare you.
[ January 20, 2005: Message edited by: Gregg Bolinger ]
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by Gregg Bolinger:
And to me, these are reasons to not use SWT.


I don't want to divagate, but I don't see what would be the problem with a new dll. Regarding the dispose() programming mode, you are already doing this for your resources, so it is not a so big addition. Moreover JFace components are already offering default dispose implementation so in many cases you don't need it.

--
./pope
[the_mindstorm]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Ali Pope:


I don't want to divagate, but I don't see what would be the problem with a new dll. Regarding the dispose() programming mode, you are already doing this for your resources, so it is not a so big addition. Moreover JFace components are already offering default dispose implementation so in many cases you don't need it.

--
./pope
[the_mindstorm]


Another DLL isn't really a big deal in the grand scheme of things. However, there would have to be something SWT offered that Swing doesn't to warrent it for me. Hence, my other thread about requirements.
Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

Well, I couldn't resist the temptation. I had to see for myself, so I came up with a little test case to see which one could draw 200 buttons on a window the fastest. To my surprise Swing was 5X faster than SWT at drawing the controls. That's right! Even visually I could see the difference. I'm not saying this proves anything because it's only 1 test, but I do think it's at least INTERESTING.

Test environment:
OS: Linux
Java: 5.0
Processor: AMD 2600
RAM: 1GB

Test results:
Average time for Swing: .136 secs
Average time for SWT: .63 secs

Here is the Swing code I used:


And here is the SWT code I used:


I would be interested to see what the results would be on Windows. I will try that myself tomorrow.
Feel free to add to the test.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Windows XP
P4 3.4
1 GIG Ram

Swing
------
Time to init controls: 0.062

SWT
------
Time to init controls: 0.062

Doesn't surprise me. Seems I recall some discussion about SWT running better on Windows than linux. Thanks for the test code.
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Pentium 4
Windows 2000 Professional
RAM 768

Swing
----------
First time running : Time to init controls: 0.125
Second time running : Time to init controls: 0.062

SWT
----------
First time running : Time to init controls: 0.062
Second time running : Time to init controls: 0.062

It's really surprising... Does it depend on the memory consumption of my computer at the time of running?
Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

Windows 2000
P3 700MHz
328KB RAM
Java 5

Swing
----------------
.17


SWT
----------------
.2


These were average times after 3 tries.


Another observation:
The buttons in SWT and Swing look approximately the same size, but on Linux the SWT buttons are very thin and not even tall enough to display the full text.

It seems to me there has not been as much work done on the Linux side in SWT.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

If you didn't use a null layout and absolute button sizes and let the layout manager handle the size, SWT would render them corretly for linux. The problem is 110x20 is not really the same in Linux as it is in Windows. It's not even the same in GNOME as it is in KDE. :roll:
Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

Oh I see... that makes sense. Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SWT is faster, no Swing is faster..