Translators Flashcards

1
Q

What is a translator?

A

A system which converts high level code to machine code.

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

What is an assembler?

A

An assembler converts assembly code (low level code) directly into the binary machine code (there is usually a 1-1 relation between assembly and machine code).

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

What is a compiler?

A

A compiler converts high level source code into a new executable document for the OS/processor it is being ran on).

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

What is an interpreter?

A

An interpreter converts high level source code into machine code one line at a time (often checking the whole program for errors first).

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

Compilers vs interpreters?

A

A compiler does not need to recompile every time the code runs, the compiled file runs faster, doesn’t require the compiler software and is more secure when distributing programs as you do not need the source code. Interpreters however can often run on lots of different platforms if they have appropriate interpreters (e.g. Java) and are useful for developing as the you don’t have to recompile each time.

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

What is bytecode?

A

It is an intermediate code used by languages like Java, code is compiled into a separate high level code which is then interpreted allows platform independence and code to run faster.

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

Compare compilers and interpreters.

A

For a compiler:
Code can be saved and not re-complied each time,
Executes faster,
Can be distributed without compiling software,
And code cannot be read.
For interpreters:
Code does not have to be completely re-complied when errors are found,
Can have platform independence,
Useful for development.

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

What are the three stages of compilation?

A

Lexical analysis, syntax analysis and code generation.

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

What does lexical analysis do?

A

Removes whitespace and comments, may detect some errors* and all code is converted into tokens and identifiers in code add variables to a symbol table, this is then passed to the syntax analyser.

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

What does the syntax analysis do?

A

This is the stage that tries to catch errors, it uses the tokens to check that the code follows the language rules using something similar to a syntax diagram or Backus-Naur form, also checks for semantic errors like using an undeclared variable.

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

What happens in the code generation stage?

A

This is where the high-level code is turned into machine code, certain code optimisation will also occur at this stage.

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

What is a library?

A

When a certain code function has been written already so the programmers simply use the pre-made functions.

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

What is a linker?

A

Links the program and libraries together during compilation by giving the information the loader will need.

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

What is a loader?

A

Manages the loading of libraries (dll’s) into memory at run-time.

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

Compare linkers and loaders.

A

One required the machine of the person running the program has the required libraries installed, however the alternative could be storing the same libraries multiple times across different programs.

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