Geek talking

Pinoy geek talking about everything under the sun

Speed of Java

Posted by rom on November 27, 2005

Java is often pitted against C++ (and C#) when it comes to the preferred programming language. Each one has its own strengths and weaknesses. Java, however, is often at a disadvantage when it comes to execution speed. Some say that Java will never be as fast as C++ – is this true?

Well, Java runs on top of a virtual machine (JVM or KVM) that runs on top of the operating system. Contrast this against C++ that is a systems programming language, i.e. it interfaces directly with the operating system and even directly to the underlying hardware. This simple layering will tell you why Java is slower but only to an extent.

Compared to C#, which runs on the virtual machine as well, C# has a tight integration with its underlying operating system. This is evidently an advantage. Unfortunately, it only runs on one operating system as opposed to Java. Don’t get me to discuss Mono, that is another story.
Personally, I’d rather use Java for its portability (compared to C++ and C#) and ease of use (compared to C++). Performance can be tuned, of course. In addition, Java’s native interface may help improve the execution speed of Java applications that require direct hardware access but at the expense of portability. Some argue that portability is not 100% and I agree but 95% is close enough. 🙂 I’d rather have code that runs on most operating systems than just exclusively on one.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: