Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 01-26-2011, 08:32 PM   #1
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Java is fast.

http://labs.oracle.com/techrep/2002/...r-2002-114.pdf

It's from a while back now but still shows a rather important point and debunks a rather widespread myth at the same time... Well written Java is generally no slower than C. In fact, it's often faster because of how clever the JIT compiler is these days

Admittedly these were guys that know the innards of Java better than anyone, but bear in mind this was written almost a decade ago and both the compiler and hotspot VM are a heck of a lot cleverer these days.

How? Well, C code might be platform dependant and native, but it still needs to be written to run on a number of different architectures. The Java VM knows exactly what hardware it's on when it's running your code, and because of this it can do things entirely differently depending on the underlying processor, memory available, the lot. So it can be incredibly specific in its optimisations, and especially using the server VM (which takes a while to start up but is stupidly fast when it does) it does an amazing job at it.

So if you ever hear the rumour / myth flying around that Java is as slow as slugs on depressants, ignore it. The last time it held much truth was in the 90's. When used properly Java is a blisteringly fast language, and continuous improvements mean it's only set to get better!
__________________

__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Old 02-03-2011, 06:34 PM   #2
Baseband Member
 
Join Date: Jul 2005
Posts: 55
Default Re: Java is fast.

What about graphics? I can usually tell when a UI has been programmed in Java because of its sluggish nature with a tendency not to respond while the JVM is doing other things. Maybe it's just Swing, I'm not sure, but does Java's inability to access native graphics components limit its speed in terms of UI's and graphics-heavy games?
__________________

Argon is offline   Reply With Quote
Old 02-03-2011, 07:38 PM   #3
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: Java is fast.

Quote:
What about graphics? I can usually tell when a UI has been programmed in Java because of its sluggish nature with a tendency not to respond while the JVM is doing other things. Maybe it's just Swing, I'm not sure, but does Java's inability to access native graphics components limit its speed in terms of UI's and graphics-heavy games?
If swing doesn't respond while the application is doing other things that's because of bad programming rather than Java itself being bad. In simple terms, there's a thread called the EDT (event dispatch thread) which should be just used for handling user input, dragging windows around, clicking buttons and so on. Any tasks that take a long time to execute on this thread will block it, stopping any interaction with the interface in question. The correct way to do things is to use a SwingWorker to fire off another thread and notify the UI when it's completed. However, this takes time and extra effort so many people just lazily misuse the EDT, causing the interface to lock up (perhaps indefinitely if the task never finishes.)

In terms of graphics heavy games, Java does actually use native graphics components for these. Libraries such as JOGL are provided with native dll's or so's that are unique to each platform, but a version is provided for each platform. So you still code the same (JOGL handles all the native stuff) and have the application running on Windows, Linux and Mac, but the actual implementation on that machine whilst running will be directly accessing the native graphics components.

Have a look around for JMonkey and some of the games that have been developed using that - Java can certainly be used for this type of work too!
__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 06:39 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0