r/AskComputerScience • u/Successful_Box_1007 • Nov 18 '25
Can somebody help me understand how a dev can trust building an app in a virtual machine that is only emulating hardware but not a true representative of it ? (I thought about it an even if the VM is the same as the native architecture they want to run on, how can they trust this VM)?
Can somebody help me understand how a dev can trust building an app in a virtual machine that is only emulating hardware but not a true representative of it ? (I thought about it an even if the VM is the same as the native architecture they want to run on, how can they trust this VM)?
0
Upvotes
View all comments
Show parent comment
2
u/Graumm Nov 21 '25
VMs are generally not doing assembly-wise translation; at least the ones that most people run. If a company owns a codebase it is usually much easier and less risky to rebuild an application for another platform. If they have dependencies that rely on a specific platform they will generally design the code to be able to replace those dependencies with equivalent ones depending on the target platform, which is known at build time.
They do exist yes, but generally speaking these are called emulators. Apple has a lot of experience with these kinds of tools having moved from PowerPC to x86 to ARM. Emulators need to know about what is being translated to what, and the differences between the platforms. If differences between the platforms are significant there can be serious performance impacts. Maintaining emulators can be expensive. Platforms continue to evolve over time and you can’t always leverage new features of newer platforms without having more information about the application that only exists at build time. Or that the code has to intentionally be written to leverage those features, which is not something that an emulator can always translate. Generally speaking there is a “lowest common denominator” of functionality where the program can be made to work, but that it takes a lot of time and effort to make these emulators fast.
On your last question it kind of depends on the driver. Again there is usually a lowest common denominator, a minimum set of functionality that can be made to work on anything. Hardware and paravirtualization come into play when there are benefits to writing drivers that understand what the underlying environment is. They can be written in a way that is more optimal than the most generic of interfaces because they can make assumptions. These assumptions usually allow drivers to avoid doing extra copies of data, eg if known memory layouts can be passed directly through as a memory address.