So hello guys, i hear quite often those three words: Java is slow? So can someone explain me what does it means. Like it will never be fast like C/C++ etc. I don't understand that.
Thanks in advance!!!
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
So hello guys, i hear quite often those three words: Java is slow? So can someone explain me what does it means. Like it will never be fast like C/C++ etc. I don't understand that.
Thanks in advance!!!
It is an old myth that is no longer true. It was true back in 2000, but isn't true anymore. Modern Java runs as fast as any other language. The "slow" myth was largely a criticism of the old pre-2000 virtual machine vs natively ran code.
NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:
When asking for help, please follow these guidelines to receive better and more prompt help:
1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
2. Give full details of errors and provide us with as much information about the situation as possible.
3. Give us an example of what the output should look like when done correctly.
Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/
GregBrannon (August 18th, 2014), HypeIsReal (August 18th, 2014)
aussiemcgr is right.
Back in the days java was rather slow because its byte code needed to be interpreted to be run. Today, black voodoo magic (the JIT) happens in the background to compile the java byte code to native code on the run. This can be exactly as fast as C or C++ code can be if we assume that the JIT does good work.
However, the JIT needs some time to heat up. So in the beginning java programs tend to be a little bit slow if you start them the first time. But once everything is cached and compiled things will go as fast as possible.
GregBrannon (August 18th, 2014), HypeIsReal (August 18th, 2014)
First of all, saying "Java is slow" is a bit too vague to mean anything. Slow when? On what system? Which part of it is slow?
That being said, saying "Java is slow" is simply not true. It got a bad reputation in the 1990s due to requiring the JVM and thanks to novice programmers who didn't understand how to use the EDT, resulting in unresponsive GUI programs- but that was the fault of the programmers, not Java.
Since then, Java has made several advancements, including the just-in-time compiler, that put many benchmarks on par (or even better than) other languages. Java has also expanded to include JavaEE (which powers many of the websites that you use every day), as well as Android.
The one place Java can't go (and this is by design) is native code. So if you're writing code for a particular piece of hardware, then you'll have to use a lower-level language. But you can use JNI to call that native code from Java.
That being said, one of the most important benchmarks is *programmer time*. Instead of thinking about how fast your code will go (which, like I said above, is probably fine), think about how long it will take you to accomplish a particular task. How fast can you get a window with some buttons up and running in C++? In Java, that would take about a minute. How fast can you set a server up? An Android app? In that way, Java is one of the fastest languages around. Also, what if you have to maintain some code written by somebody else? Would you rather that code be in C++, or in Java?
Recommended reading:
http://en.wikipedia.org/wiki/Compari...va_and_C%2B%2B
http://stackoverflow.com/questions/1...ance-vs-java-c
http://en.wikipedia.org/wiki/Java_performance
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
GregBrannon (August 18th, 2014), HypeIsReal (August 18th, 2014)
Guys, thanks for responses. That all makes sense. Thanks to all of you!!!
Cheers!