Aloysius Thevarajah Lloyd wrote:
> Just wondering Sun JVM written in C/C++. How come Java Faster than C or C++?
>   
When C and C++ is compiled the compiler is making assumptions about how
the program is being run and optimizes based on those assumptions. If it
makes the wrong assumptions then performance will not be optimal.

Very skilled C programmers can craft their code and direct the compiler
to make correct, or at least make more appropriate assumptions but even
the programmer can't always predict how an application will be used.

Java code is optimized as it is used. This means that optimizations are
based on actual usage rather than assumed usage. Some advantage is
gained from that. Whether it results in better overall performance
depends on the application and usage.

To some degree I think the above explanation (it's not mine) sounds too
much like marketing. Object Oriented code has made trade-offs of
run-time performance in order to gain programmer performance (i.e. time
to write and debug a program) so comparing Java and C++ is more suitable
than comparing Java and C.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to