Translators Flashcards
What is a translator and its use?
a program that converts high-level source code into low-level source code which is then ready to be executed by a computer
used to convert HLL or LLL source code to object code, intermediate, executeable or machine code and detects errors in source code
Name 3 types of translators
compiler
interpreter
assembler
What does a Compiler do / How does it work?
translates high level code into machine code all at once. it carries out checks and reports back any errors there may be after, however some may be false.
this process is longer than the other two translators
if any changes need to be made the whole program has to be recompiles
once code is compiled to machine code, it can only be executed on certian devices as compiled code is specific to a particular processor type and OS.
code can be run without a translator being present
Compiler /compiled code characteristics
compiled code is not human readable which helps preserve intellectual property and protect the program from malicious use.
compiled code is machine dependendt and architecture specific so multiple versions of the code will need to be maintained for different architectures
optimisation imrpoves program speed and size so compiled code runs more quickly
compiler is no longer needed when executeable code is produced
produces intermediate code for VM’s
easy to access lower level features such as GPU access
What does an Assembler do / How does it work?
translates assembly code into machine code
each line of assembly code is equivalent to almost one line of machine code so code is translated on one-to-one basis
Assembler / Assembly code characteristics
considered low level language
platform specific, as instructions used are dependent on the instruction set of the processor
program uses low level source code to translare assembly code into machine/object code
one-to-one basis allow storage to be reserved for instructions and data
What does an Interpreter do / How does it work?
interprets and runs high-level language source code which is machine independent
translates and executes code line-by-line
stops and produces an error if line contains an error. may initially appear faster than compilers as code is instantly executes, but are slower than running compiled code as code must be translated each time it is executed with an interpreter
makes interpreters useful for testing sections fo code and pinpointing errors, as time is not wasted compiling the entire program before it has been fully debugged
Interpreter characteristics
interpreted code requires an interpreter in order to run on different devices. however, code can be executed on a range of platforms as long as the right interpreter is available thus making interpreted code more portable
interpreters useful for testing sections fo code and pinpointing errors, as time is not wasted compiling the entire program before it has been fully debugged
translated one statment then runs it before translation of next line
reports one error at a time as they’re found then stops to indicate position of error
interpreter must be present each time program is run - program runs slower due to this
used by VM’s and during program development
source code is visible - easily can be copied and amended by can be obstructed