Sunny Chan blogs Can you see the Logic in my Madness?

Is Java really that slow? Does C# compiles to assembly code?

by Sunny Chan


Posted on Thursday April 24, 2008 at 05:07am in Anything


Last weekend I was having a chat with my friend, and they keep telling me "I thought all the banks are using .net". I asked why? They bring out the age old argument, "I thought Java is slow and C# generates native code"... Oh dear. This friend of mine is one of the cleverest guy I ever met, however he has been misinformed.

Java does not necessarily slower than C++. Yes, startup time maybe longer compare to a native application. However there are a lot of clever runtime optimization that can be done through a JIT that is not available to normal static compiler. For example, most of the JIT compiler would have generated fairly optimized assembler code, as well as using compilation techniques that can only be achieved by using run time profiling information. In the recent version of Hotspot it also contains technology like Biased Locking - this cannot be easily done using a normal static C++ compiler. In most case, Java is as fast as C++, and can be quite a bit faster in some circumstances.

C# does not compile into native code straight away, and it employs similar bytecode/JIT organisation similar to Java.

Java used to be pretty slow during the early days, but with the arrival of better runtime this is no longer the case. One of the problem that still need to resolved is the overhead of the garbage collector, especially using the large heap. There are a lot of clever people spending time solving this problem and hopefully we will get somewhere soon.

In the end, I can't be brothered to argue with him as he hold tightly to his beliefs, so we left it there. But I just wish people would take a look at the current state of the affair before dissing Java.

 







 



No one has commented yet.

Leave a Comment

HTML Syntax: Allowed