4 ms·
How exactly would performance degrade by defining a virtual machine for C programs to run in where assurances are given that all of the standard behavior is ful
by cfv 11y ago
How exactly would performance degrade by defining a virtual machine for C programs to run in where assurances are given that all of the standard behavior is fully defined -this operation either fails, or gives THIS result-? It sounds like it could be massively useful, at least for non-realtime applications.
- 2trill2spill 11y agoCreating a C virtual machine might work for most user space applications, but what about operating systems and system libraries? Most operating systems and low level libraries are implemented in C, or at least partially, and implementing a C virtual machine that you then want to run kernel code on top of, seems daunting. Performance wise I would assume a C virtual machine would be on par with java (JVM). So I would say a C virtual machine wouldn't be a very fruitful endeavor, Most user space applications can be written in a Memory safe language, while the most incumbent C code, kernel and system libraries probably can't or at least shouldn't be executed in a virtual machine.
- im2w1l 11y agoLet's say you have a trapping division on the actual CPU you run on. And let's say the virtual machine specifies that division doesn't trap. Then the compiler has to insert checks for invalid inputs to prevent trapping from happening. Those checks may degrade performance.
- lmm 11y agopcwalton claims a factor of 3x to 5x elsewhere in the thread. Honestly I think the biggest problem here is social. Every programmer thinks they're smarter than others. If you give them a button marked "remove all safety checks, increase performance by 1%", they'll press it. Those who wouldn't press it have probably already moved on from C.