• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java's Performance  RSS feed

 
Nitin Dubey
Ranch Hand
Posts: 126
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I was a C++ programmer before coming into Java. I have found that Java programs run much slower than that of C++.
Is it the BYTECODE playing the role? or there is some other reason.
bye
nitin
 
Josh Garrett
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible you're noticing the first few extra moments that it takes to fully load the JVM? A running (not loading) java program should be very comparable in speed. Beyond that, all I can say is that java and CPU's are getting faster.
 
Vummidi Satya
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
Java Byte code will be interpreted. ie, Every piece of byte code needs to be converted into machine understandable form(M/c dependent) by vitraul machine for every execution of the program.
In case of other c or c++ languages a directly executable M/c dependent code will be generated, so there is no time wasted for conversion.
Advantages and disadvantages you only can decide.
 
shailesh sonavadekar
Ranch Hand
Posts: 1874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In Java , since the portability across the platform was the issue ( not efficiency as in case of c++ ) , thus sun has developed vm ,which in talks to your native platform. So you get the feeling that you are independent of the platform. ( Whether it is windows , it is linux or mac os )
Sun has done very great job in designing the VM. Your highlevel language code gets coverted to bytecode , which doesn't talk directly to native code , but it gets converted to p-code ( Psuedocode ). Uptill this phase , the comiled form is there. This pseudocode then talks to native , machine identifiable code . This is interpreted. Thus , Sun has used best of both the worlds. Because of this , Java is slower than C++ , which is platform dependent.
But , it must be noted that the purpose of designing of each language is different.
one more request VVSATYA. As naming policy of this site , the user must reister him with proper first & last name . I request you to please register with proper name & help the other javaranchers.
[This message has been edited by shailesh sonavadekar (edited November 08, 2000).]
 
Ihor Strutynskyj
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also try experimental gcc_java
compiler which will compile your java source into executables the same way as C or C++. I think there are some other java compilers out there. The new JDK 1.3 has very smart hotspot engine which will compile some parts of the byte codes 'on the fly' to improve performance.
 
talashme
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java Virtual Machine befor jdk 1.2.* is really slow for many real time tasks I found this while working on a Stock Exchange project some months ago, but sun is working hardly in resolving this performance issue. I appreciate Java HotSpot 2.0 that comes with jdk 1.3 really improves performance by 50 % in many cases thats fine but still it need to be better. or we can use the Java native code compiler like (Jove, BulletTrain, JET, etc.)
But I found that mannual optimization can really helps in improving the Java code performance.
My Question: Is there any one who know a good java bencmark
utility ?
 
shailesh sonavadekar
Ranch Hand
Posts: 1874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
talashme , thank your posting your reply. I don't want to rain the parade here.
As official naming policy of this site , the user has to register him / her with proper first name & last name.For example : - "shailesh sonavadekar" So , i request you to register with proper first & last name & help others with your
valuable contributions.
YOUR FREINDLY BARTENDER
SHAILESH
 
Nitin Dubey
Ranch Hand
Posts: 126
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanx all for reply,
What I can make out is native code compiler converts java code into OS understandable code that can execute faster.
Is it so? If not let me know. Links to native code compiler will be welcome ...
Well talashme I would like to know more about HOTSPOT 2.0 that comes with jdk1.3.
bye
nitin
 
SRINI VASAN
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,
given a prograqm how much is the performance difference between c++ and JAVA..

any idea about a performance profiler in java..
Reagrds
srini
 
Grant Crofton
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Srini, I read somewhere (wish I could remember where) that java is currently about 10x slower than an equivalent C++ prog. It depends on the platform - Microsoft's JVM is supposed to be the fastest, so on windows there would be less of a difference.
Of course, it depends what the program does - i think graphics are slow in java.
If anyone has any acual figures that would be useful.
Grant.
 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Current" java is on par with C++, and sometimes even faster. It really depends on both the type of application (e.g. graphics, math), as well as the JVM implementation and OS. Generally, the newer JVMs using JITs are pretty comparible with C++. The HotSpot JVMs are pretty good. (I believe HotSpot is faster than Microsoft's JVM--are they even making JVMs these days?)
--Mark
hershey@vaultus.com
 
Akin Kaldiroglu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe questions like "Which one is faster, C++ or Java?" does only make sense if we mention some more information about the situation. Specific platforms, implementations, algorithms, and skills of the person who writes the code will definetely determine the execution efficiency of the code, whether it is in Java or C++. But apparently , as in every aspect of the reality, there are tradeoffs in language design issues, too. What kind of problems or issues you like to address will determine your choice for languages too. Problems that are waiting in front of software engineers are getting more and more complex. Most of the time handling the complexity correctly and efficiently precedes performance. I mean, you will definetely to implement all of the requirements in an efficient and correct way and sacrifice from your performance in a reasonable range. If the performance is your only concern, then you will most like look for good machine code writers.
I believe Java has been created to handle the complexity better. In fact this is the promise of OO theory. Encapsualtions, inheritance, polymorphism, reusability and all other buzzwords are here to reflect the relationships between the entities in the real world on software area. Anybody who has a little experience in procedural and oo languages would confess that writing code with an oo language would require more line of code such as creating a class and instantiating its objects etc. So there are some intrinsic drawbacks of oo theory and languages implemented in that way. And when you add some other concerns and decisions such as beign platform independent, more secure etc. you will definetely give up some of other aspects such as performance. Java is more secure, using exceptions are mandatory and excellent way for project efficiency and user interaction in the software. This list goes on.
I have just read an article, I don't remember exactly where, but it was about Microsoft's new language, C#. The writer was talking about the fact that Microsoft realized the fact that C++ is capable but too complex and hard to use to develop giagantic and/or web based applications. He claimed that as a result of its experince from VisulaBasic and C++, Microsoft is now trying to incorporate best aspects of VisualBasic and C++ and creating its own "Java". I am not knowledgeable about C# but what I understood from the article is that Microstf is trying to address the complexity problem I mentioned above in its way.
Akin Kaldiroglu
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!