Lambda the Ultimate

inactiveTopic java vs. C# speed comparisons?
started 1/16/2003; 11:37:47 PM - last post 1/19/2003; 11:08:39 PM
Michael Vanier - java vs. C# speed comparisons?  blueArrow
1/16/2003; 11:37:47 PM (reads: 1670, responses: 10)
Does anyone know of any java vs. C# speed comparisons? I'm curious how the JIT technologies of these two languages compare in terms of raw speed.

Isaac Gouy - Re: java vs. C# speed comparisons?  blueArrow
1/17/2003; 7:15:04 AM (reads: 1464, responses: 0)
Win32 Computer Language Shootout ;-)

And then the fun starts!
If the C# time is worse than the listed Java time take a look at the source code - like String Concatenation where the Java code uses a StringBuffer but the C# code doesn't use a StringBuilder...
The exception is Producer/Consumer Threads - the current release of .Net really is that much slower (seems to be fixed in the beta for the next release).

And then the fun starts!
Java? Which JVM? Which JDK version? Which OS platform?
Aldo used a Sun JVM.
Java Grande Benchmarks and SciMark give some idea of the range of JVM performance.
Maybe some things (floating-point calculations) got slower with JDK 1.4?

And then the fun starts!
C#? Which C#? There's always the Mono C# compiler and runtime.

And then the fun starts!
compare in terms of raw speed doing what exactly?
Doing decimal arithmetic?

The SciMark benchmark has been ported to CLI vms.
The C#, C, and J# source code is available.

Michael Vanier - Re: java vs. C# speed comparisons?  blueArrow
1/17/2003; 1:15:38 PM (reads: 1433, responses: 0)
As you say, there are a lot of variables. What I had in mind was to compare the Microsoft .NET implementation of C# (which I assume to be the most optimized) with Sun's JVM/JIT combination.

As for the shootout, it's a little difficult for me to take a shootout seriously when it lists python as being faster than C# or java. I assume that this is more a reflection of the python libraries that are written directly in C than anything else, but I admit I haven't looked at the code in detail.

If I had to pick a subject area, I would probably pick number crunching e.g. in scientific applications.

My real interest in this is that .NET partisans often talk about how .NET IL (intermediate language) is optimized for JIT-compilation, whereas in the case of java, JIT-compilation was an afterthought. The implication is that therefore JIT-compiling .NET IL must result in much more efficient code than JIT-compiling java bytecodes. What I want to know is if there is any evidence to support or refute this claim. My impression is that java and C# are actually pretty close in speed.

Isaac Gouy - Re: java vs. C# speed comparisons?  blueArrow
1/18/2003; 9:14:18 AM (reads: 1420, responses: 0)
number crunching
C# and IBM JDK 1.3 and C SciMarks

IL optimised for JIT?
Not having seen the source of this claim, I could read it to mean - the performance of JIT compilation is better (instead of - the performance of the compiled-code is better).

java and C# are actually pretty close in speed
For number crunching there aren't 10x differences - is 30% pretty close?

difficult for me to take a shootout seriously when
Are you're talking about the Scorecard, which uses the "Completely Random and Arbitrary Point System!, CRAPS!", and is "just for fun"?
Each test page lists unweighted times - which all things being equal... Unfortunately, some of the implementations just don't do the same thing - even when the language allows it. (Due diligence is required.)

Michael Vanier - Re: java vs. C# speed comparisons?  blueArrow
1/18/2003; 3:52:53 PM (reads: 1412, responses: 0)
That's an interesting link -- thanks! If you see more of these, let us know. I don't consider 30% earth-shaking, but it makes you want to look at the code to see whether the difference was due to some particular programming idiom or other. For instance, C# supports "structs" (stack-allocated objects) whereas java doesn't. Did the C# code use structs? I don't know, since the C# code doesn't appear to be posted. I'm also curious how gcj (native-code java compiler) would do. Also, I've heard that java 1.4 is significantly slower than 1.3 (up to 2x) for many tasks :-(

I'll play around with the benchmark and maybe post my results.

Michael Vanier - Re: java vs. C# speed comparisons?  blueArrow
1/18/2003; 8:50:51 PM (reads: 1394, responses: 0)
OK, for java vs. C, at least, here was what I got:

c: Composite Score: 228.02 java: Composite Score: 110.90724420076754

This is with the Sun JDK 1.4. These are pretty decent numbers considering that java was not designed as a number-crunching language. I tried using gcj (native code java compiler) but couldn't get the benchmark to compile, I think because there are libraries missing from gcj.

Isaac Gouy - Re: java vs. C# speed comparisons?  blueArrow
1/19/2003; 12:24:51 AM (reads: 1383, responses: 0)
the C# code doesn't appear to be posted
As I mentioned, the C#, C, and J# source code is available.

a number-crunching language
Fortran is still popular for that.

Michael Vanier - Re: java vs. C# speed comparisons?  blueArrow
1/19/2003; 3:59:48 AM (reads: 1388, responses: 0)
OK, I compiled the C# code using mono 0.17. I get a score of 74.19 MFlops. Of course, mono is probably slower than M$ C#.

Isaac Gouy - Re: java vs. C# speed comparisons?  blueArrow
1/19/2003; 11:08:33 AM (reads: 1406, responses: 0)
If you see more of these
Google for c# benchmark - it was on the second page.

You'll probably be interested in this eval of the C# preview.

The discussion about particular C# language features is probably of more general interest.

"What I had in mind was to compare the Microsoft .NET implementation of C#"
So why use Mono?

What I want to know is...
Has SciMark shown anything relevant to your original question?

Michael Vanier - Re: java vs. C# speed comparisons?  blueArrow
1/19/2003; 2:33:57 PM (reads: 1438, responses: 0)
I used Mono because I don't use Windows unless I absolutely have to ;-)

Scimark is a nice set of benchmarks. My original opinion, that C# and java are roughly comparable in speed, has not been changed by anything I've seen so far.

Isaac Gouy - Re: java vs. C# speed comparisons?  blueArrow
1/19/2003; 11:08:39 PM (reads: 1518, responses: 0)
I used Mono because I don't use Windows unless I absolutely have to ;-)
"What I had in mind was to compare the Microsoft .NET implementation of C#"
Seems like you absolutely would have to use Windows... ;-)

Scimark is a nice set of benchmarks.
Has SciMark shown anything relevant to your original question - .NET IL and JIT compilation?