Every universal computer is “just” an interpreter

Today I was struck by the realization that every von Neumann universal computer (e.g. your laptop) is an interpreter.

In the olden days of computing, logic gates were connected by wires to form custom electronic programs. If you connect them together this way you get a calculator. If you connect them that way you get Pong. Each was a program embodied in electronic hardware, only ever capable of one task. The hardware is the program.

Later came the universal computer with the von Neumann architecture. It is another piece of hardware that is also a program, but it doesn't really do anything on its own. All it knows how to do is the fetch-decode-execute cycle: Fetch a chunk of a program, figure out what it "wants" to do, and send data this way and that in response. It checks each instruction for validity, executes, and goes off and grabs the next one. Does this remind you of anything?

If you've ever written an interpreter, this should all sound very familiar. Your software reads the next instruction of some script, figures out what it wants (and if it's valid), and then takes action on its behalf.

What does this all imply?

  • The only thing "running" in your laptop is the processor.
  • All your low-level "machine code" is just an interpreted script (like javascript.)
  • The only difference between the processor and an interpreter that you write is that the former runs by itself, while the latter runs atop yet another interpreter.
  • User applications themselves are the equivalent of those custom-built calculator circuit boards.

So the next time you get to harshing on some scripting language, remember: It's all interpreted.


Responses: One so far

  1. Ric Roberts says:

    Although this is really just stating the obvious, it's a very wise and thought-provoking observation, Tim :-)