Translators Flashcards

1
Q

What is a translator and its use?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name 3 types of translators

A

compiler
interpreter
assembler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does a Compiler do / How does it work?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Compiler /compiled code characteristics

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does an Assembler do / How does it work?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Assembler / Assembly code characteristics

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does an Interpreter do / How does it work?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Interpreter characteristics

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly