The virtual machine

The concept of the virtual machine is a rather old one and allows the elegant solution of complex tasks. Anybody knows that each computer has at least one CPU - today usually a single chip. This CPU understands some type of machine instructions - and each executable program must be translated into instructions for this special type of CPU. The compiled programs will no longer work if the CPU is replaced by another one - for example on another computer with another CPU type.

Beside this, depending of the CPU type, the production of "native" code can be rather complicated. So people started early to think about virtual machines. These machines are not available in reality - in hardware. But they are more convenient for the actual purpose.

So, lets imagine a simple CPU with only 10 instructions but with an unlimited number of registers. In fact writing compilers for such a machine is rather simple and straightforward. The only task we have to do in addition is to write an add-on program on the actual, physical CPU to interpret the code produced by the compiler.

Now, lets call this program - the interpreter - the virtual machine. This virtual machine runs on a physical machine and executes programs written in code for the virtual machine.

A "classical" example for such a virtual machine were the early 360 machines by IBM. They were based on different types of CPU's but all of them understood the 360 machine code. This was possible as all machines implemented the same virtual code - partially in microcode, partially in software and partially in hardware. The most expensive types had everything in hardware (so they were faster), the cheap ones had most in software.

This approach was also used in the first distributed Pascal compiler (the P-code) and reused in the USCD Pascal project. A recent version of a virtual machine is  JVM - the Java Virtual Machine.

But there are virtual machines on a much higher level. Each spreadsheet is build based on such a virtual machine implementing statistical and mathematical functionality.

The speed

Virtual machines are said to be slow. This is correct for "low level" machines - like JVM. But it is not true if the level of the machine is high enough. A typical example of this is an SQL machine - a database server, in fact a virtual machine programmed with SQL. Nobody will claim that accessing such a machine is slow and could be sped up by programming in native assembly code.


The DM approach

We call the pictures on the screen "programs". These programs are written as a collection of widgets - each with an association to an object or to attributes of an object. The program can only be executed if there is a proper "machine" - and Eiffel is an excellent language with which to specify such a machine.

the DM virtual machine the DM program
is a combination of DM (the Display Machine) and a collection of Eiffel classes describing objects and functionality. DM allows you to "run" a DM program and to access the underlying Eiffel program. is a collection of GUI forms. Each of these forms consists of one or many widgets. Each of these widgets can be used to access a corresponding object or attribute - and also different forms belonging to these objects.

For example, look at the calculator example. It consists of the Eiffel class CALC describing the virtual machine for such a calculator. The program itself is a collection of widgets - each with some relation to the calculator object and its functionality. If we want to extend our calculator, it may also be necessary to extend the virtual machine.


Copyright © Object Tools -- info@object-tools.com
Last updated: 2005/02/02 11:51:07