Interesting article about Java performance

mrchimp

Newbie
Joined
Jul 19, 2003
Messages
1,928
Reaction score
0
http://www.idiom.com/~zilla/Computer/javaCbenchmark.html

Very informing, speed is becomeing less of a problem for Java. Infact it hasn't been a problem for years :rolleyes: Unless your makeing something massively complicated.

Here's my faveriot bit:

Java is now nearly equal to (or faster than) C++ on low-level and numeric benchmarks. This should not be surprising: Java is a compiled language (albeit JIT compiled).

Nevertheless, the idea that "java is slow" is widely believed. Why this is so is perhaps the most interesting aspect of this article.

Let's look at several possible reasons:

* Java circa 1995 was slow. The first incarnations of java did not java a JIT compiler, and hence were bytecode interpreted (like Python for example). JIT compilers appeared in JVMs from Microsoft, Symantec, and in Sun's java1.2.

This explanation is implausible. Most "computer folk" are able to rattle off the exact speed in GHz of the latest processors, and they track this information as it changes each month (and have done so for years). Yet this explanation asks us to believe that they are not able to remember that a single and rather important language speed change occurred in 1996.
* Java can be slow still. For example, programs written with the thread-safe Vector class are necessarily slower (on a single processor at least) than those written with the equivalent thread-unsafe ArrayList class.

This explanation is equally unsatisfying, because C++ and other languages have similar "abstraction penalties". For example, The Kernighan and Pike book The Practice of Programming has a table with the following entries, describing the performance of several implementations of a text processing program:
Version 400 MHz PII
C 0.30 sec
C++/STL/deque 11.2 sec
C++/STL/list 1.5 sec

Another evidently well known problem in C++ is the overhead of returning an object from a function (several unnecessary object create/copy/destruct cycles are involved).
* Java program startup is slow. As a java program starts, it unzips the java libraries and compiles parts of itself, so an interactive program can be sluggish for the first couple seconds of use.

This approaches being a reasonable explanation for the speed myth. But while it might explain user's impressions, it does not explain why many programmers (who can easily understand the idea of an interpreted program being compiled) share the belief.

Two of the most interesting observations regarding this issue are that:

1. there is a similar "garbage collection is slow" myth that persists despite decades of evidence to the contrary, and
2. that in web flame wars, people are happy to discuss their speed impressions for many pages without ever referring to actual data.

Together these suggest that it is possible that no amount of data will alter peoples' beliefs, and that in actuality these "speed beliefs" probably have little to do with java, garbage collection, or the otherwise stated subject. Our answer probably lies somewhere in sociology or psychology. Programmers, despite their professed appreciation of logical thought, are not immune to a kind of mythology, though these particular "myths" are arbitrary and relatively harmless.

Now I'm going to sit back and wait for the completely irrelavant C++ is better than Java post. :naughty:
 
The only thing I have found Java to be slow in (in my limited experience in programming) is with applets. However since it is the only programming language to have something like applets (to my knowledge) I can't help but forgive them.
 
mrchimp said:
http://www.idiom.com/~zilla/Computer/javaCbenchmark.html

Very informing, speed is becomeing less of a problem for Java. Infact it hasn't been a problem for years :rolleyes: Unless your makeing something massively complicated.

Here's my faveriot bit:



Now I'm going to sit back and wait for the completely irrelavant C++ is better than Java post. :naughty:

And there are many articles using speed comparisons which the exact opposite is the case. They can't all be right and this article alone (including the benchmarks it listed) are not enough (some of the reference links are broken, the ones that work do not provide actual code used; so determining if the testing was indeed accurate is not possible). Even if the article is correct, it is not sufficient. Find more supporting articles with REPRODUCABLE comparisons (includes code) that stress CPU bound processes - otherwise there tests can be biased.

- Some tests have used inefficient C++ code against efficient Java code, providing the code used in the test allieviates this concern.


The Mullinator said:
The only thing I have found Java to be slow in (in my limited experience in programming) is with applets. However since it is the only programming language to have something like applets (to my knowledge) I can't help but forgive them.
From wikipedia - "An applet is a small program that runs in the context of a larger program on a client computer. This usually refers to Java applets, which run in a browser."

Using that deffinition ASP (previously just vb, now including C# via ASP.net) is also an applet.

So is macromedia flash for that matter.

---------------------------------------------------------------

Here are some more speed comparisons
http://www.cs.cornell.edu/vogels/weblog/2002/11/25.html (compares java, c#, j# -> benchmark ranges from 0 to 1, where 1 is better -> note 1 represents C's performance)

http://www.tommti-systems.de/go.htm...ain-Dateien/reviews/languages/benchmarks.html
(compares C++, C#, JAVA - C++ is fastest and uses the least amount of memory)

http://www.osnews.com/story.php?news_id=5602&page=3
(compares Visual C++, Visual C#, gcc C, Visual Basic, Visual J#, Java 1.3.1, Java 1.4.2, Python/Pysco, Python)

---------------------------------------------------------------

So is it clear now that there are articles supporting both sides? Maybe instead of trying to find the one 'best' language to be used in absolutely every ****ing case... you can focus on which specific langauges fit which specific problems.

You would never use C++ for a web-front end to a system.
You would never use Java for a micro-controller.
You would never use LISP for a financial accounting application.
You would never use Assembly for anything over 300 lines (unless your masochistic)
You would never use fortran to write a GUI-Application.
You would never use PERL for a engineering simulation.
You would never use ProLog for a media editing tool.
You would never use VB Script for an operating system.
....
....


Get the idea?
 
Well I read the first link you posted and it said Java's perf wasn't too bad either.

"Get the idea?" Yup years ago, didn't even need you to explain it. Infact that was rather patroniseing.
 
BTW in the first link you posted, if you took out trigonometry - which looks bugged to me - Java would only be slightly slower than C++ which is highly incourageing as it opens up many new doors that would otherwise be closed if Java was a "slow" language. As it is, it's fairly fast in relation to other languages, of course Java programs still take longer too load up than most native solutions and on average take up more memory, but thats never been a problem for me nor anyone I know.

For my purposes Java is better than C++ (and yes my purposes include more than just web developement) and I don't need an article to tell me so, my own experience has already shown me that it's both fast enough and technically capable. I just found the article interesting and informative. It is biased in Java's favour, but thats because it's an article defending Java and in particular it's performance.
 
MrChimp said:
BTW in the first link you posted, if you took out trigonometry - which looks bugged to me - Java would only be slightly slower than C++ which is highly incourageing as it opens up many new doors that would otherwise be closed if Java was a "slow" language. As it is, it's fairly fast in relation to other languages, of course Java programs still take longer too load up than most native solutions and on average take up more memory, but thats never been a problem for me nor anyone I know.
The first link I posted did not mention C++, it mentioned C#.

MrChimp said:
For my purposes Java is better than C++ (and yes my purposes include more than just web developement) and I don't need an article to tell me so, my own experience has already shown me that it's both fast enough and technically capable. I just found the article interesting and informative. It is biased in Java's favour, but thats because it's an article defending Java and in particular it's performance.
Likewise I have always found C++ to be more usefull for what I have been doing - not for the speed but for the functionality of the language. When ever I deal with problems that are speed important I switch to C / Assembly ( and even microprogramming when possible / necessary).
 
Whoops I was talking about the last link not the first.

Personally I like C++ and think that it is the better/more interesting langauge (although a little long winded), but VC++ isn't free and Netbeans is, also JavaDoc is indespensible as far as I'm concerned and so is the Java API. Thats why I use it instead of the alternatives. If I ever do find myself faced with a problem that can't be solved in Java alone, then I plan to use the JNI. Which should be fun.
 
Back
Top