P2 T2 L4 Programming Language Translators Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Define translators (1 point)

A
  1. Software that converts a program from one language to another
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the types of translators? (3 types)

A
  1. Compiler
  2. Assembler
  3. Interpreter
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does a compiler do? (1 point)

A
  1. translates high level language into machine code by translating all of the code at once
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does an assembler do? (1 point)

A
  1. translates a program written in assembly language to machine code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does an interpreter do? (2 points)

A
  1. Translates a program written in a high level language to another language.
  2. Converts the code line by line.

You may use this if you are trying to run a program on a different computer than the one you wrote it on as it might have a different processor.

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

Explain the compiler (4 points)

A
  1. Translates high level language into machine code by translating all of the code at once.
  2. The compilation is done before execution.
  3. It turns the code into object code and executes it.
  4. Display all errors after compilation, all at the same time.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Reasons to use a compiler (4 reasons)

A
  1. So that source code cannot be accessed by users;
  2. Users do not need to have an interpreter / compiler / translator. Users do not need to install an IDE (e.g. NetBeans)
  3. Users do not need knowledge of the programming environment
  4. So that the program will execute more quickly (when complete)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain an interpreter (3 points)

A
  1. Converts the code line by line so the program can run with errors in it
  2. May either convert the code into machine code and execute it OR call instructions to carry out the high level language
    statements in the source code.
  3. Displays error of each line one by one.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Reasons to use an interpreter (3 reasons)

A
  1. Can’t know what type of processor will be in user’s computer. Internet users have range of computers / devices with different processors.
  2. A compiled program will only execute on a processor of specific type / with same instruction set.
  3. A program run using an interpreter can execute on a computer with any type of processor.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Explain Bytecode (3 points)

A
  1. Some programming languages use/support Bytecode.
  2. Bytecode is set of instructions (object code) used for programming that can be executed on any computer using a virtual machine. Eg JVM
  3. The virtual machine converts each generalised machine instruction into a specific machine instruction or instructions that this computer’s processor will understand.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do we use bytecode? (2 points)

A
  1. Once the bytecode for a particular subroutine or method has been translated into machine code, the machine code is retained for the next time that code is required, so the translation does not have to be done again.
  2. Using a language that comes with a virtual machine for each platform, your source language statements need to be compiled only once and will then run on any platform – usually speeds up Java execution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is source code? (1 point)

A
  1. Code which has not yet been compiled into an executable file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is object code? (2 points)

A
  1. Compiled code which can be run as an executable file on any computer
  2. Difficult to reverse engineer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly