Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Originally posted by Barry Gaunt:
One problem is the JVM startup time, class loading and initialization time. Once all the >infrastucture< is up and running and "raw" bytecode runs, then the race should be about even.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Originally posted by Norm Radder:
I dont' know what Java application is faster than C. EVERY java app I have is slower than every C app I have. By seconds!!
Originally posted by Norm Radder:
No I don't have 2 versions. I've only written one it both C and Java.
Its a very empirical thing, all C programs I use seem to start and be faster than any Java program. Most of it is in the startup.
I've written something of an application server that will execute other java programs and with it the other programs do load much faster.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
...Java has really made great gains in overall performance that can in fact put it on par with C++, if not a little quicker! There are various benchmarks that have reported Java algorithms running quicker than C++ equivalents... You will of course find many benchmarks finding the converse. What this shows is that they're at least comparable which is enough for me to imply that Java is fast, and I'll leave it to the benchmark zealots to fight over their nanoseconds.
I think Java is somehow still seen as an interpreted language; in fact, it does get compiled to native code using Just In Time (JIT) compilation. It is also a myth to think that JIT code is slower than pre-compiled code...
... The next myth is that Java is slow. Obviously, since it is an interpreted platform, it can't be anywhere as fast as native code. For some reason, these folks have never heard of Just In Time (JIT) compilers. I can understand that. This is an industry that prides itself on instruction counting, so relying on a JIT compiler may seem like voodoo. The fact is that JIT compilers now produce code that is just as fast as native compilers. And, in some cases the code is faster. JIT compilers can analyze runtime patterns and adjust compilations. Native compilers can't do that.
We can skip over the myth that Java execution is slow because it is interpreted. It's simply not true. JIT (just in time) and AOT (ahead of time) compilers are the norm for embedded Java.
Five composite benchmarks listed below show that modern Java has acceptable performance, being nearly equal to (and in many cases faster than) C/C++ across a number of benchmarks...
Myth #1: Java has to be slow. Myth #2: Java is interpreted. ... Previously, a Java Virtual Machine was primarily an emulator. Soon, however, some JVMs began compiling the Java code to native code as a part of the startup process. However, modern virtual machines do something which C/C++ usually does not: dynamic compilation and optimization. HotSpot, Sun's current JVM, does some pre-compilation, but also profiles your code at runtime. This allows it to figure out the most important areas to optimize, and then to make the optimizations as your program runs. In addition, HotSpot includes a new garbage collector without the annoying tendency of its ancestors to bring your application to a halt.
The myth of Java's poor performance originates from these three misconceptions:
that Java is interpreted and therefore slow, that Java's safety features in the area of typing and memory management introduce large amounts of overhead, and that system performance is primarily a function of CPU opcode selection. ...not only are none of them true, an understanding of modern hardware architecture and a survey of typical systems shows that Java is arguably a superior choice for high-performance applications; for instance, in a 24x7 n-tier application, Java's defragmented and compacted heap is likely to be both more robust and higher performance than a memory management scheme cooked up by the average C++ programmer.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Some folks have a hard time accepting that a Java program is actually a C program.
Screaming fools! It's nothing more than a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|