Virtual machine
A virtual machine is an implementation of a computer on top of another. An emulator is specifically a virtual machine that simulates a different type of computer that also exists as real hardware. If the "emulated" computer is similar to the one that runs the emulator, the commonly used term is virtualization. Virtual machines that have no real-hardware counterpart (such as the Java Virtual Machine) are usually just called VMs, but their machine languages are usually referred to as bytecode rather than machine code.
Virtual machines can be used to ensure compatibility of a software – both across different types of hardware and in constantly changing software environments (i.e. to avoid software rot). Very simple virtual machines (ones that may be very slow but can be implemented in a very short time) are sometimes suggested as a means for very-long-term software preservation.
Virtual machines designed to run applications usually have the same kind of dependency and obsolescence problems as modern computer platforms in general. So, instead of ensuring compatibility, things like the Java Virtual Machine are more likely to add just another unreliable layer of dependencies. In order to avoid this, the design of the VM should be frozen and discourage software dependencies.
A general problem with virtual machines is the virtualization overhead, especially if the instruction set differs from that of the host computer. An emulated program may require several times the computing resources of an equivalent native program. JIT translation can be used to reduce this overhead. ?Static binary translation could be used to remove (nearly) all of the overhead, but is far more difficult to implement automatically.
Fantasy platforms are a class of virtual machines designed to be superficially similar to classic home computers, including immediate and worriless programmability with a simple programming language. A common design mistake in otherwise constrained fantasy platforms (such as ?TIC-80) is uncapped speed that allows the host computer to run the programs as fast as it can. This encourages programs that "push the limits" of the VM while actually taking advantage of the speed of the host computer and wasting a lot more energy for doing the same thing.
Virtual machines:
Languages that are usually compiled into virtual machine bytecode instead of native code: