DEV Community

Discussion on: Do they know it's C in PHP 🎄

out0 profile image

Opcodes are the commands of a processor. When you compile your code to the machine, it is translated into opcodes for that machine. When you compile for a VM, it's translated into opcodes for that VM.

So when we say that something is compiled to opcodes for a VM, we are saying that a virtual non existent machine will interpret this opcodes much like it (the machine) was a real computer, only that instead of running them like a real machine, it will translate those opcodes to the real machine opcodes that it is running.

The main "advantage" of that is that the code is really ubiquitous, because the machine (the virtual) is fixed.

You must have a virtual machine to every single type of hardware you intend to run your compiled code, to do the bridging. BUT, for the point of view of the developer, it looks like the code runs magically anywhere