What is a Abstract Machine?

804 views Asked by At

I don't quite get the definition and use case of an abstract machine and how its actually related to a compiler or interpreter

I googled what abstract machines were but understood very little out of it.

An abstract machine is a model of a computer system (considered either as hardware or software) constructed to allow a detailed and precise analysis of how the computer system works.

Here are some articles I read but understood not that much out of:

2

There are 2 answers

7
Joop Eggen On

A definition of machine would be some working/processing engine. Here it means a computer. It relates to high-level language and machine code. An abstract machine is a model of a computer system/architecture. With many simplifications and generalizations. So the instruction set could be without registers but with a stack holding the operands of instructions.

A compiler or interpreter for code running on this non-existing abstract machine is much simpler to write, than for one single physical machine, and there exist many different physical machines.

You could write an interpreter for the code of your abstract machine and port that interpreter to many physical machines. Or you could compile to a physical machine by first compiling to the abstract machine code, and converting that to physical machine code.

Say you have L programming languages (Java, C) and M different systems (Windows, Linux on ARM, Androids), then going indirect via an abstract machine (JVM, LLVM) simplifies the effort to L+M implementations. Whereas otherwise you would need to write L*M implementations. Furthermore you entirely separate the aspects of programming language quirks and physical machine quirks.

The specification of an abstract machine, a high level theoretical computer, can be more universal and strict. And is just a tiny fraction of the specification of a real computer architecture. And it avoids bugs in chip design.

An abstract machine is the Esperanto intermediary for translating a high level language into machine language.

0
chepner On

A NOT gate is an abstract machine: 0 goes in, 1 comes out, or 1 goes in, 0 comes out. But how does that happen? What is 0? What is 1? We don't care: we can reason about how NOT gates interact with AND gates and OR gates and what have to you to build up more complicated circuits.

There are, however, many ways you can realize this abstract machine as a concrete, working machine: transistors, diodes, DNA, relays, etc.