Translator(Compilers, Interpreters and Assemblers) Flashcards
What is a translator?
A program that converts code from one language into equivalent code written in another
What does an assembler translate?
Assembly to machine
How does an assembler work?
Uses the processor’s instruction set to convert the instructions to the machine code equivalent(Produces an object file)
Optimisation will occur, E.G substituting subprogram calls as if they were inline, calculating values of constants etc
What does an Compiler translate?
High-Level to machine
how does a compiler work?
A compiler scans through the whole code, and translates it all into machine code
A compiled program can be directly executed(a binary file is produced)
After translation, the compiler and source code are no longer needed
- You can distribute your program without the source code
Error messages are only shown after scanning whole code
- Can be awkward and time-consuming for debugging
What does an Interpreter translate?
High-Level to machine
How does a Interpreter work?
Work Line-by-line –> translates a line =, then immediately executes it
Everytime you want to execute code, it must be translated again
Stops as soon as it reaches an error
Both the interpreter and the source code are needed at all times
Slower than a compiler