Save
Comp Sci
Translators
Save
Share
Learn
Content
Leaderboard
Learn
Created by
Matthew Ayomide
Visit profile
Cards (13)
Translator
A program that
converts
code from one
language
into equivalent code written in another
All code needs to be
translated
to
machine code
in order to be executed by a computer
Main types of translators
Assembler
Compiler
Interpreter
Assembler
1.
Takes assembly code
2.
Converts
to
machine code
3.
Output
is an
object file
Assembly code
One-to-one nature with machine code
Optimization
like replacing subroutine calls with inline functions
Evaluating
constants
Assembly
code
is used when
memory
and
processing
power are at a
premium
, e.g. in
embedded
devices
Compiler
1. Scans through whole code
2.
Translates
to machine code
3. Produces an
executable binary file
Compiler
Error messages only shown after scanning whole code
Compilation
can take significant time for
large
programs
Interpreter
1. Translates and executes
line
by
line
2. Needs both
interpreter
and
source code
to run
Interpreter
Slower
than compiler
Provides
instant feedback
on errors
Modern translators can be more complicated, using a mix of
interpretation
and
compilation
for optimization
Bytecode
Intermediate
code that can be run by a
virtual machine
Object code
Machine code
plus
extra instructions