I
I
Insolent Muzzle2022-01-18 17:57:20
Programming
Insolent Muzzle, 2022-01-18 17:57:20

VM vs native, what are the pros and cons?

What are the pros and cons of translating to VM bytecode versus compiling to native code? In what situations does bytecode perform better than native, and in what situations does it perform worse?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Bannikov, 2022-01-18
@pluffie

Advantages of the native - no need to drag some kind of interpreter or jit compiler into runtime, so the application itself often turns out to be more compact, eats less RAM, and starts faster.
And also the AOT compiler can do more complex optimizations, since it has no resource and time restrictions.
A native application is usually difficult to decompile
Pros vm - to port applications, you only need to port vm.
If the vm is already installed on the target machine, then the bytecode will take up less space than the native code.
In theory, it can be faster than a native application, because the JIT has more information than the AOT compiler even with a profile.
Compiling to bytecode is faster than to native, because you don't need to do a lot of complex optimizations - this will be done by JIT in the background. And it will compile only what is used, and what is not used or rarely used - no (it will be without complex optimizations)
Problems with the speed of a cold start can be solved.

R
rPman, 2022-01-18
@rPman

If we consider specifically llvm, then this infrastructure can give optimization based on execution, i.e. collecting code statistics on the fly can optimize cycles so much that the final execution speed can become higher than similar code compiled natively (for example, my llvm code optimized 'almost' unused blocks in this way).
Yes, there are analyzers for c++ compilers that collect data by running the algorithm on specially assembled versions, but there are not enough people who do this, for sure 99.99999% of the projects that exist do not bother with this (and it’s difficult)
ps with other virtual machines, such tests are difficult to conduct, and what I heard jvm or clr work slower than native, noticeably

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question