This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Alternatives to java swing ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Alternatives to java swing ?" Watch "Alternatives to java swing ?" New topic
Author

Alternatives to java swing ?

Arjun Singh Rampal
Greenhorn

Joined: May 24, 2012
Posts: 20
I have seen that many java programs are slower than others. I guess that swing tends to make execution slower. Are there any alternatives to swing which are much faster ?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11444
    
  16

Arjun Singh Rampal wrote:I guess that swing tends to make execution slower.

Guessing why something is slow is almost ALWAYS going to give you the wrong answer. Why do you think it is Swing that is slowing things down?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Arjun Singh Rampal
Greenhorn

Joined: May 24, 2012
Posts: 20
fred rosenberger wrote:
Arjun Singh Rampal wrote:I guess that swing tends to make execution slower.

Guessing why something is slow is almost ALWAYS going to give you the wrong answer. Why do you think it is Swing that is slowing things down?


I heard that it does not use the native graphic libraries of an OS. Instead, it calls the native functions indirectly. So, there is some overhead. Sounds believable, but i cant confirm its actual impact on performance.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8043
    
  22

Arjun Singh Rampal wrote:I heard that it does not use the native graphic libraries of an OS. Instead, it calls the native functions indirectly. So, there is some overhead. Sounds believable, but i cant confirm its actual impact on performance.

Then before you make any rash decisions, I suggest you do - and make sure your evidence is backed up by statistics, not just anecdotes.

Just as a general rule, a layer of indirection shouldn't add a huge overhead, but it depends entirely on how well it's designed. Not being a Swing expert I couldn't tell you how good Java's is.

It's also possible that what you've heard is an urban myth dating from the times of AWT: A few of those have surfaced over the years, probably the most pernicious being the one that "synchronization is expensive".
Like many myths there was a grain of truth to it, but it caused a lot of programs to be written to avoid synchronization; code which became basically redundant when the Java memory model was upgraded. Unfortunately, by then the damage had been done, and there are still programs around with arcane (and sometimes invalid) code to get around the "problem".

Another thing to think about before you make wholesale changes: There are a lot of Swing programmers out there; how many will there be for whatever superfast, bleeding-edge alternative you choose?

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

In my experience, it's *much* easier to create smooth responsive GUIs in Swing than in AWT for example. The indirection may refer to Swing's lightweight components, which are not notified of repaints by the OS, but by the container holding them. This actually often makes Swing faster, because they use some tricks to try to get the smallest area necessary to repaint.
 
Don't get me started about those stupid light bulbs.
 
subject: Alternatives to java swing ?