Computer Science Canada

C# vs. Java

Author:  Martin [ Sun Nov 14, 2004 1:21 pm ]
Post subject:  C# vs. Java

I've been reading a lot about C# lately, and I definately like what I see.

The speed boost alone is enough to ditch Java. When I get some free time, I think I'm going to start to learn it.

http://www.25hoursaday.com/CsharpVsJava.html

Author:  wtd [ Sun Nov 14, 2004 2:54 pm ]
Post subject: 

C# has some syntactic conveniences not found in Java (properties come to mind), it's designed for a different virtual machine, which has some advantages, and it has a different set of libraries.

If you want to do Windows-specific programming with games and desktop apps, C# is the way to go. However, Java has significant advantages and shouldn't be casually dismissed. It's mature, more portable than C# between different platforms, and it kicks a lot more butt in the enterprise server environment.

Speed, by thew way, is not a reason to get rid of Java. You may not like Swing GUIs, and think they're slow, but that's Swing, not Java. Java is bloody fast everywhere else and even sometimes outperforms natively compiled C++ code.

Author:  bugzpodder [ Sun Nov 14, 2004 3:32 pm ]
Post subject: 

in a contest environment, Java is given on average 5 to 10 times more run-time than a C/C++ program. And there is no Swing involved, just pure data IO and processing.

Author:  wtd [ Sun Nov 14, 2004 3:42 pm ]
Post subject: 

Contest programs are probably not intended to run for long periods of time.

There's no denying the Java runtime has significant load overhead. However, in the long-run it makes up for that initial cost many times.

They key is that information makes it possible to optimize. C and C++ optimize at compile time, if at all, and in doing so discard information about the program and what's going on in the larger sense. Java doesn't, and thus it can perform optimization as the code runs.

Author:  bugzpodder [ Sun Nov 14, 2004 5:48 pm ]
Post subject: 

We are talking about pure computation in contest problems. basically its just numerical calculations. I think C++ is faster in this respect.

Author:  Mazer [ Sun Nov 14, 2004 9:49 pm ]
Post subject: 

I was at a seminar recently about C# and Managed DirectX. Seems quite interesting (the language, not the graphics API). I know the specifications for the language are available but are there currently any free compilers for C# yet? I've got a free copy of Visual Studio 2004 .NET on it's way but legally I won't be allowed to distribute anything compiled with it.

Author:  bugzpodder [ Sun Nov 14, 2004 9:53 pm ]
Post subject: 

2004?? there is 97, 6.0, 2002, 2003 and 2005... never heard of VS .net 2004
microsoft gives you free compilers... but not the IDE
and you can make a full fledge game in one hour using managed Direct X, or so i heard

Author:  wtd [ Sun Nov 14, 2004 11:35 pm ]
Post subject: 

Coutsos wrote:
I was at a seminar recently about C# and Managed DirectX. Seems quite interesting (the language, not the graphics API). I know the specifications for the language are available but are there currently any free compilers for C# yet? I've got a free copy of Visual Studio 2004 .NET on it's way but legally I won't be allowed to distribute anything compiled with it.


There's Mono, Portable.NET, and DotGNU for free compilers/environments.

And I believe you can distribute code compiled with the free versions... just not commercially.

Author:  Mazer [ Mon Nov 15, 2004 8:32 am ]
Post subject: 

Sorry, meant 2003. "Typo"

Thanks wtd, I'll look into those. Yes, I know I can distribute non-commercially but should the need arise it would be nicer to not be limited by that.

Author:  md [ Mon Nov 15, 2004 12:53 pm ]
Post subject: 

While C# does indeed look good, it's still an interpreted language, as is java. Interpreted languages are garnunteed to have AT LEAST the same execution time as native code (assuming the same code is used).

There is NO WAY you're going to run an emulator, which is basically what the JVM is, and better speeds than native code.

Quote:
Java is bloody fast everywhere else and even sometimes outperforms natively compiled C++ code.

Somewhere (i forget where unfortunatly) I read a comparison of different languages. The premis was to see how long it look each language to perfom some number of operations. The one in which Java came closest to C/C++ was doing addition, when it was still 2 times slower.

*** correction ***
It would seem that Java is improving : http://osnews.com/story.php?news_id=5602&page=3

However it is still only as fast as C, and only when doing integer arithmatic

Author:  bugzpodder [ Mon Nov 15, 2004 3:51 pm ]
Post subject: 

i dont see how this source is reliable

Author:  Hikaru79 [ Tue Nov 16, 2004 12:39 am ]
Post subject: 

Cornflake wrote:
While C# does indeed look good, it's still an interpreted language, as is java. Interpreted languages are garnunteed to have AT LEAST the same execution time as native code (assuming the same code is used).

There is NO WAY you're going to run an emulator, which is basically what the JVM is, and better speeds than native code.

Quote:
Java is bloody fast everywhere else and even sometimes outperforms natively compiled C++ code.

Somewhere (i forget where unfortunatly) I read a comparison of different languages. The premis was to see how long it look each language to perfom some number of operations. The one in which Java came closest to C/C++ was doing addition, when it was still 2 times slower.

*** correction ***
It would seem that Java is improving : http://osnews.com/story.php?news_id=5602&page=3

However it is still only as fast as C, and only when doing integer arithmatic


It would seem, by the graph you linked to, that Java 1.4.2 is faster than everything else at just about everything except Trig. It has the fastest long math, fastest double math, fastest int math, 3rd fastest i/o. and BY FAR the slowest trig. Assuming that Java 1.5 (the newest version) is an improvement on 1.4.2, then it's looking like Java wins in every category except trig.

In fact, even in the trig category, the site admits that

Quote:
This was especially puzzling given the much faster trigonometry performance of Java 1.3.1, and suggests that there may be more efficient ways to code the benchmark in Java. Perhaps someone with more experience with 1.4.2 can suggest a higher-speed workaround.

Author:  md [ Tue Nov 16, 2004 12:19 pm ]
Post subject: 

First, the sources reliability is definitly questionable, as it's the result of a quick google search.

Second, I'm not sure what table you read, but Java 1.4.2 is only faster than C++ in two cases, int math and io, and then only by a very small amount. Java 1.3.1 is slower in all areas (althoug it's trig is much better than 1.4.2). If you look at the overall scores C++ score HALF of what Java 1.3.1 and less htan half of what 1.4.2 scores.

Getting back on topic, C# scores second best at slightly more than half of the score Java got.

Author:  bugzpodder [ Sat Nov 20, 2004 10:52 am ]
Post subject: 

http://www.topcoder.com/rtables/viewThread.jsp?forum=7167&thread=390999&mc=34


: