Foundations
From Source to Silicon
The instructions you write are not the instructions the machine runs. Something translates, and when it does the translating is the difference between a game that keeps up and one that cannot.
Begin — Unit 01 →What this is
You write SHOW "Hello". The processor cannot read that. It runs numbers, and only
numbers. So between the program you write and the program that runs, something has to
stand in the middle and translate.
There are two ways to do that, and this module is about the difference. A translator can work as it goes, reading each line and puzzling out what it means every time it meets it. Or it can translate the whole program once, ahead of time, and get out of the way. The first is patient with you. The second is fast. Most of the games you will build on these machines were built the second way, and this is where you find out what that choice is.
By the end you will have built a translator of your own, out of two lists and a loop.
Who it’s for
Anyone standing at the top of the stairs down to assembly, wondering why they should bother climbing down. And any BASIC programmer who has ever asked why is this so slow. The answer is here, and it is not the one people expect.
You need Structure, because the translator you build uses lists, and Counting in Twos, because the numbers a processor runs are the ones from there.
What it is not
This is not how to write assembly. Not one real instruction for one real machine. That is Meet Assembly, in your machine’s own words, once you have picked one. Here we stay a level up: what kind of thing an interpreter is, what kind of thing an assembler is, and why the same idea can be quick or sluggish depending only on when the translating happens.
The shape
- The program is not what runs — text for you, numbers for the machine, and the one question that decides everything.
- Translating as you go — the interpreter, and the price of working the same line out a thousand times.
- Translating once — the compiler and the assembler, and you build one.
- What speed costs you — the three things you hand over: the safety net, brevity, and every other machine.
- Put it on the clock — what speed buys, and the measurement this module cannot make for you.
From here the road goes into a real machine, where the numbers stop being made up.