C is fastest (was: McMaster University Creates Open Source eHealth Records System)

Yanni Chiu yanni-bJEeYj9oJeDQT0dZR+AlfA at public.gmane.org
Wed Oct 14 03:49:18 UTC 2009


Lennart Sorensen wrote:
> On Tue, Oct 13, 2009 at 01:29:12PM -0400, Dave Cramer wrote:
>> This is not the  problem, and nor is java inefficient, look at the 
>> performance comparison between C++, or even C and java. You will be
>> amazed.
> 
> Yes C is much easier to write efficient code in.  C++ can (with a
> good compiler if you can find one) be made to do efficient code as
> long as you avoid most of its stupid features (which makes it mostly
> C anyhow). Java is just hopeless.

When I read the original comment, I assumed that "efficient language"
meant efficient use of the developer's time. I'm surprised (but I
shouldn't be) that people still want to talk about "code written in
language A, runs faster than if written in language B).

As to runtime efficiency, the Sun Java HotSpotVM technology is derived 
from the Animorphic VM built for Smalltalk, which was bought by Sun. At 
runtime, the VM chooses "hot" methods to compile its bytecodes into 
native machine code, and caches the compiled machine code for subsequent 
invocations. And, this still works for polymorphic invocations (i.e. the 
calling code doesn't know the exact class in the hierarchy of the object 
being invoked). This will execute faster than any C++ compiler that uses 
vtables.

I'll also contend that, except for very short programs, a system written 
in Smalltalk or Java, running with Animorphic VM ideas, could run faster 
than a well written C version. There are two reasons. One, once a 
program gets big enough, you need to do memory mgmt, and the VM's 
garbage collection would probably do a better job than ad hoc code. Two, 
the VM optimizations are discovered and applied at runtime, and it will 
  find optimizations that developers could not have imagined, when 
looking at a small bit of code -- i.e. like what happens when the global 
optimization switch is used for a C compiler.

-- 
Yanni
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list