Java is slow compared with other languages |
| |
|
|
|
Code Guru Gender:  Posts: 1399 Topics: 85
|
|
|
November 26, 2008, 05:18:55 AM
|
|
There is this common belief that Java is considerably slower than other languages. There are a number of reasons cited for this - one such being that as it compiles to byte code and then needs the Java runtime this has a detrimental affect. However, with technologies such as the hotspot compiler and JIT compiling, this might not be as true as some people think. Other reasons are that, as Java is a safe language, runtime is "wasted" checking array bounds etc which C often does not.
I have my own thoughts on this, but generally, when comparing Java to languages such as C, C++ and Fortran do people think that there is a performance gap?
If Java is infact slower, does this matter - or do the benefits of Java outweight this issue?
Nick
|
|
| |
|
|
|
New Poster Posts: 7 Topics: 2
|
|
|
December 20, 2008, 09:17:19 PM
|
yes i agree with you, but java has many features than other languages, so we can ignore that slow issue.  For advanced programs java is the only option, because it always give many options.
|
|
| |
|
|
|
Code Guru
Location: India
Gender:  Posts: 1387 Topics: 105
|
|
|
December 20, 2008, 10:14:08 PM
|
|
Well I really don’t know with which other languages you are comparing JAVA with??
I don’t think one should compare or one can compare completely two languages for their speed performance. Because one language can be good in something but not good in something other. So it really depends upon for what factor the language is developed.
|
|
| |
|
|
|
Code Guru Gender:  Posts: 1399 Topics: 85
|
|
|
December 21, 2008, 03:42:31 PM
|
Yup, I absolutely agree when comparing the programmability of two languages. However, performance is a very objective thing - something is either faster or its not and some applications do require performance over anything else. I would be tempted to say compare performance of Java against the likes of C or C++. Of course, probably it isn't that easy - there may very well be things which Java has good performance with, and things which it don't. 
|
|
| |
|
|
|
Regular Coder Posts: 67 Topics: 33
|
|
|
January 03, 2009, 11:47:44 AM
|
|
hi friend, yes JAVA is slow compared to other languages because of JVM. Java uses multiple thread processing within it's own virtual machine, JVM. This virtual machine is designed to support platform independently. Because of this, Java uses direct machine code conversion through it's compiler and runtime environment.
|
|
| |
|
|
|
Code Guru Gender:  Posts: 1399 Topics: 85
|
|
|
January 03, 2009, 02:58:44 PM
|
|
Bear in mind Java uses technology such as JIT compiling and the hotspot compiler to combat exactly this - so its not as simple as just interpreting the byte code and executing it
|
|
| |
|
|
|
New Coder Posts: 25 Topics: 14
|
|
|
January 25, 2009, 05:11:04 AM
|
|
It is a bit slower. There is not a huge difference but that is no requirement of that either anything a bit slow is slow. I have never used techniques like Hotspot compiling and other stated above but while working with simple java compiler and JVM it is slower.
|
|
| |
|
|
|
Code Guru Gender:  Posts: 1399 Topics: 85
|
|
|
January 25, 2009, 01:22:44 PM
|
|
Hotspot and JIT should work automatically, depending on your version of Java
|
|
| |
|
|
|
New Coder Posts: 15 Topics: 1
|
|
|
July 23, 2009, 07:34:46 PM
|
|
At the risk of necroing a thread - I think there's definitely some valid points here.
Java is generally slower than a compiled language such as C/C++ - even the .NET platform as an interpreted language will likely show better performance since the libraries are pretty much part of windows, just wrapping the OS APIs.
Since Java is interpreted by the JVM which has to run as a bound process and interact with the OS' APIs, there's going to be some overhead and limits to the optimization that just can't be performed. Add to this the limits of the cross-platform requirements of the language, which requires special attention to be sure that you remain cross-platform and you find yourself somewhat limited.
Java has come a long way though, and while it used to be monstrously slow, it is no longer that noticeable. However if you find yourself trying to push the performance to such a degree where you need to implement another JVM in order to gain the performances, you might need to ask yourself if you wouldn't be better off performing that function in C/C++, if it's so performance critical.
Especially if it's a product that is going to be mass-marketed - you can't rely on your customers to have these special JVMs installed in order to run your application at the performance it was designed for.
For most cases though, you're not going to find much difference - and Java, being a memory managed language, is much easier to develop in than C/C++ - it all depends on the needs of your application.
|
|
| |
|
|
|
Code Guru Gender:  Posts: 1399 Topics: 85
|
|
|
July 24, 2009, 05:23:43 AM
|
|
Good post that Corazu. But as far as the JVM is concerned, if you assume the customer will be using the one from Sun (which of course they will need to download, which is annoying) then I suppose as a developer you can gauge some guess towards the performance.
I think your last point is very valid, speed is not everything and being memory managed then arguably it has more chance of being stable (I know this is a very sweeping statement, untrue in many cases but I think it is still holds generally), which is probably more important than that last ounce of speed.
There is another, different performance argument though. If you accept that Java (with its use of objects and the such) is higher level than C, then the compiler can perform more optimisations because it has more information provided to it - for instance the string object in Java rather than an array of chars in C..... not that I think this makes up for the slowness of needing a JVM etc... but in other languages it has more of an impact and is an important aspect when it comes to performance.
|
|
| |
|
|
|
New Coder Posts: 15 Topics: 1
|
|
|
July 25, 2009, 11:31:25 AM
|
|
Everything is interpreted in real time though, you're essentially compiling on the fly. I love Java, don't get me wrong, but if you're looking at pure speed, you're likely better off developing that in C/C++. Now, you can always use Java for the business logic/front end and then pass off that performance-critical component to a module developed in C/C++ by invoking it via JNI - best of both worlds, you just lose the cross-platform compatibility since you'll need to compile that C module for each different platform.
|
|
| |
|
|
|
Code Guru Gender:  Posts: 1399 Topics: 85
|
|
|
July 26, 2009, 06:10:38 AM
|
|
It is not that simple - yes the byte code is "interpreted" initially, but if it is being run multiple times (or even multiple iterations of loops) then technologies such as the hotspot compiler will make performance comparable.... I am not arguing it is faster (or slower) than the likes of C++ or C, but I don't think it is as simple as one might initially think. Out of interest, a google search for "java is faster than c++" came up with some interesting results
|
|
| |
|
|
|
Regular Coder Posts: 53 Topics: 2
|
|
|
August 03, 2009, 09:04:59 PM
|
|
Compare Java to C and it's a slug. Regardless of your technology, I don't think you'll be able to match it. I don't like Java, and I think that there are usually far better solutions in the world of today than creating a Java application.
|
|
| |
|
|
|
New Coder Real name: bhathiya
Location: Kandy
Gender: 
Age: 24
Posts: 17 Topics: 3
|
|
|
April 13, 2010, 11:32:48 AM
|
|
C is better than java that for sure
|
|
| |
|
CoderSquare.net Founder Activity
|
|
New Poster Posts: 6 Topics: 1
|
|
|
April 27, 2010, 12:30:16 PM
|
|
I think this comes from the old days when computers were just slow in general. Something that ran slow in 1997 runs very fast / smooth now.
Its a common misconception.
|
|
| |
|
|
|
Code Guru Gender:  Posts: 1399 Topics: 85
|
|
|
April 27, 2010, 01:51:27 PM
|
I think this comes from the old days when computers were just slow in general. Something that ran slow in 1997 runs very fast / smooth now.
Its a common misconception.
What exactly is a common misconception? I don't remember computers being slow in general 13 years ago, in fact I think they seemed to run at around the same rate (although the programs we used were somewhat simpler.) I can also think of many things that ran slow in 1997 that still run slow today, and some that ran well in 97 that don't run at all! At the end of the day, users will always want more speed because as technology progresses so does the boundaries of what it is used for (the load on the machine.) Which makes the issue of resource usage as topical today as it was 10, 20 or even 30 years ago
|
|
| |
|
|
|
Regular Coder Gender:  Posts: 85 Topics: 15
|
|
|
April 27, 2010, 02:15:20 PM
|
|
i dont think java is slower than other languages
|
|
| |
|
|
|
New Poster Gender:  Posts: 8 Topics: 1
|
|
|
February 10, 2011, 02:42:46 AM
|
|
No i don't agree that Java is slow than other Languages. very Language has its own Importance,And java i the language which i love to work with so,for me the answer is NO
|
|
| |
|
|
|
New Coder Posts: 25 Topics: 2
|
|
|
April 26, 2011, 01:01:05 PM
|
|
There is this common belief that Drinkable is substantially slower than otherwise languages. There are a enumerate of reasons cited for this - one specified state that as it compiles to byte cypher and then needs the Potable runtime this has a prejudicial touch.
|
|
| |
|
|
|
Skilled Coder Real name: Janne
Location: california
Gender: 
Age: 26
Posts: 108 Topics: 1
|
|
|
May 06, 2011, 03:36:58 AM
|
|
java is slow as java is too vast bto learn but it also depends on which language u r comparing with..........
|
|
| |
|
|
|
Skilled Coder Posts: 125 Topics: 0
|
|
|
May 20, 2011, 02:20:33 AM
|
|
Yes, I agree with you. Java is little bit slow programming language rather than other programming language. There are number of facilities are provided by java.
|
|
| |
|
|
|
New Coder Posts: 16 Topics: 2
|
|
|
May 31, 2011, 01:20:42 PM
|
|
I think so. But usually the Java is more sophisticated language that greatly used for creating game and software.
|
|
| |
|
A computer Science student Dream - To become a computer expert Activity
|
|
Skilled Coder Real name: Kevin
Location: India
Gender: 
Age: 18
Posts: 199 Topics: 51
|
|
|
June 26, 2011, 11:43:04 PM
|
Java is many times slower than C and C++. Yet, it is a powerful language and one of the most widely preferred languages by programmers...... 
Glad to help.
A TechnicalTalk member!
|
|
| |
|
|
|
New Poster Real name: Rodger Getz
Location: 2655 Camino del Rio N # 450, San Diego, CA 92108
Gender: 
Age: 32
Posts: 1 Topics: 0
|
|
|
July 05, 2011, 01:04:53 AM
|
|
yes it is true that java is slow than other languages. But i think it has so many features than other languages. that's why it is not that much important issue.
|
|
| |
|
|
|
Regular Coder Gender: 
Age: 24
Posts: 60 Topics: 10
|
|
|
July 15, 2011, 01:32:43 AM
|
|
Yes definitely java is slower because 1) java programs are compiled and then interpreted so obviously it gets slow 2) With the advent of templates, good C++ programmers have been able to avoid casts almost completely in high-level programs. Unfortunately, Java doesn't have templates, so Java code is typically full of casts. 3) Java programs use about double the memory of comparable C++ programs to store the data. There are three reasons for this:
a) Programs that utilize automatic garbage collection typically use about 50% more memory that programs that do manual memory management. b) Many of the objects that would be allocated on stack in C++ will be allocated on the heap in Java. c) Java objects will be larger, due to all objects having a virtual table plus support for synchronization primitives.
|
|
| |
|
|
|
Professional Coder Posts: 229 Topics: 7
|
|
|
July 16, 2011, 01:09:19 AM
|
|
Yes of course, because java uses compiler and interpreter both so obviously it takes some time. Java source code first have to compile to produce . class file and then . class file(due to this class file java is called platform independent language) is interpreted into machine code.
|
|
| |
|
|
|
New Coder Posts: 15 Topics: 0
|
|
|
July 16, 2011, 03:10:51 AM
|
|
Anybody that has ever used a non-trivial Java program or has programmed in Java knows that Java is slower than native programs written in C++. This is a fact of life, something that we accept when we use Java.
|
|
| |
|
|
|
New Poster Real name: aslam khan
Posts: 4 Topics: 1
|
|
|
August 09, 2011, 11:11:04 PM
|
|
People who claim that Java can be as fast as C++ or even faster often base their opinion on the idea that more disciplined languages give the compiler more room for optimization. So, unless you are going to hand-optimize the whole program, the compiler will do a better job overall.
|
|
| |