3. Virtual machine for intermediate code
In addition to hosting entire operating systems, virtual machines are also used to run code designed for a specific virtual machine.
First the source code of the program is written, and then it is compiled into intermediate code or byte code which is designed for a virtual machine.
The advantage of doing it this way is that programmers do not have to rewrite and recompile every program they code to run on every possible operating system. Instead, they write programs to run on a specific type of virtual machine. Then the virtual machine can then be run no matter what operating system the host computer is using.
The Java Virtual Machine (JVM) is very popular and has been ported to virtually all hardware platforms. It is designed to run Java intermediate code. The source code is written in Java which is then converted into intermediate code by the compiler.
Another example is the Adobe Flash Actionscript Virtual Machine (AVM). The code is written in Actionscript which is then converted into flash byte code to run in the AVM.
- Portable. The same code can run on any hardware platform that supports the virtual machine.
- No need to change the source code
Security. The current version of the VM may have security vulnerabilities that allow rogue code to take control of the host computer. This is why this type of VM is patched quite frequently with updates.
Challenge see if you can find out one extra fact on this topic that we haven't already told you
Click on this link: What is the Java Virtual Machine