View Single Post
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#135
Originally Posted by Radu View Post
Anyway, the main reason why I don't believe VMs/JIT will ever catch native code in terms of speed is because it's a bit like the telephone game.
In a C program, you more or less tell the CPU what to do, step by step (assuming the compiler is smart enough not to do really stupid things). You can even use custom ASM in C, you can use registers for variables, and so on.
A JIT can do this too, and better because ...
Originally Posted by Radu View Post
For Java, the compiler will translate stuff to virtual code (one step) then the JIT will translate that code in native code (another step). The more steps you have in a process the least likely it is for the final code to do things the way you want it to be done
... why do you thing "the way you want it to be" is the fastest.

Java (or java-like language) is not a better just because it has a VM and
JIT, and C++ is not faster just because you can use asm, or
because it is more "native". But,
a VM and a just in time compiler have information that is just not
there when writing code (the programmer) or generating code (the compiler):
The runtime and execution path information.
This is not a judgment for Java, just a point you shouldn't miss,
you or the c++ compiler may not know what will be the best
code to generate.

Nicolai
 

The Following 2 Users Say Thank You to nicolai For This Useful Post: