Still loading. This can take a moment on a slow connection.
Still loading. This can take a moment on a slow connection.
Translate a program with a compiler and with an interpreter, and compare what each does with an error.
Compiler · startThe compiler reads the whole program, all 5 lines, before any of it runs.
Translates the whole program first. The machine code then runs on its own.
program.exe: not made yet
Nothing yet.
Translates one line, runs it, then goes on to the next.
Not started.
OUTPUT "Starting"Total ← 2 + 3OUTPUT "Total is ", TotalOUTPTU "Finished"OUTPUT "Goodbye"When a translator meets a line it cannot translate, reaches a line again, or finishes, say what it will do before you step on. Play waits for you.
After your first prediction, this says why it works.
Try what you found on the lesson’s 39 marked questions. Practise in High-Level and Low-Level Languages
Line 4 has a mistake. Watch what each translator does about it, and how much has been output by the time it is found.
The compiler here checks each line’s form, and the blocks the program opens and closes, before it translates anything. A mistake that only shows when a line runs, such as a variable with no value yet, is found when program.exe or the interpreter runs that line. Each time a translator takes a line to turn it into machine code counts as one translation. A compiler writes machine code, the binary instructions a CPU carries out; an assembler does the same for assembly language, whose mnemonics, such as LOAD and ADD in the fetch–decode–execute lab, each stand for one machine-code instruction.