SLR 15 - programming languages and translators Flashcards

1
Q

What is the difference between how programs that have been compiled and programs that have been interpreted can run?

A

Compiled programs can be run without requirement for any other software to be present. This is not the case with interpreters

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

How do interpreters work?

A
  • They have procedures that can be used to translate each kind of program instruction
  • They check for errors as they translate rather than before
  • A program with errors with be partially translated until the error is reached
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How is bytecode executed?

A
  • With a virtual machine which can execute bytecode of different processors
  • Each different processor instruction set will have its own virtual machine
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why do we need translators?

A

A program needs to be in machine code to be executed, so translators are needed to convert HLL and Assembly language into machine code (binary)

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

What are the 3 types of translator?

A
  • assembler
  • interpreter
  • compiler
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does an assembler do?

A

It converts assembly language into machine code

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

Why is assembly language translation quick and easy?

A
  • an assembly language instruction has a one to one relationship with machine code
  • this means translation is quick
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why do different assembler need to exist for each different type of processor instruction set?

A

They are platform specific

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

What do compilers do?

A

They translate programs written in high-level languages into machine code

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

How do compilers work?

A
  • They take the HLL as their source code
  • They check it for any errors
  • Then translate the whole program at once
  • If there is an error the source code then it will not be translated
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why are compilers deemed platform specific?

A

They produce machine code

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

What do interpreters do?

A
  • they translate HLL into machine code LINE BY LINE
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why do interpreters offer poor protection for their source code?

A
  • during translation, the program source code and the interpreter must be present
  • it makes the original code difficult to extract
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Advantages of interpreters?

A
  • useful when writing programs
  • no need for lengthy, time consuming recompilation every time an error is found
  • makes it much easier to partially test and debug programs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Advantages of compilers?

A
  • Generated object code is kept on a disk, it can be run when needed without needing to recompile it
  • once created, object code executes much faster then interpreted code
  • the object code is relatively secure, it is hard to read it and work out what the source code would have been (protected from extraction)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What do compilers sometimes produce before machine code? Example?

A

intermediate language e.g., bytecode. its a half-way standard language which can then be translate to computer specific machine code

17
Q

Why do compilers produce intermediate language?

A

it allows for platform independence

18
Q

What is the advantage of intermediate language?

A

It allows the interpreter to translate the source code just once, while still being able to execute the translated code with a variety of different processors

19
Q

What is source code?

A

The name given to the input to a translator e.g., assembly language for an assembler and HHL for compilers and interpreters

20
Q

What is object code?

A

The translators output and is produced from source code

21
Q

Define a quick time-line of computer languages:

A
  • limited speed and memory of computers meant programmers coded in LLL (machine code), which directly manipulated the processor (often difficult and prone to errors)
  • Assembly code
  • Then HHL developed (one to many relationship) where instructions could be communicated to the computer processor
22
Q

What are the characteristics of a LLL?

A
  • they are specific to the type of processor they are written for
  • they directly affect the computer processor
23
Q

What are the two types of low level language?

A
  • machine code
  • assembly code
24
Q

What are the disadvantages of Machine code?

A
  • it uses only binary but its very long and difficult for humans to understand
  • Machine code programs are prone to errors
  • Very difficult to debug
25
Q

What are the advantages of Machine code?

A
  • it directly manipulates a computer’s processor so it a powerful paradigm
  • you’re never limited programming in machine code
  • no ned for translation so useful when working with embedded systems and real time applications
26
Q

Why was assembly language created?

A
  • it simplified machine code by using mnemonics like ADD and MOV
  • it made programming ore compact and less error prone
27
Q

Why was assembly language still quickly processed?

A

the language instruction has a one to one correlation to a machine code instruction

28
Q

What is the difference between HHL and LLL?

A
  • HHL are not processor specific
  • HHL must be translated into machine code before they can be executed
  • HHL lets programmers use built in functions
  • Easier to debug due to named variables, indentation etc
29
Q

What are the two types of HLL?

A
  • interpretive
  • declarative
30
Q

What is an imperative HLL?

A
  • are formed from instructions that specify how the computer should complete a task
  • code executed one line at a time e.g. C# and Java
31
Q

What is an declarative HLL?

A
  • describes what a computer should do
  • SQL?
32
Q

Machine code:
- portability?
- ease of use?
- ease of debugging?
- ease of execution?

A
  • Not portable
  • Code is difficult for humans to understand
  • Errors are very difficult to spot and correct.
  • Machine code is directly executed by processors.
33
Q

Assembly Language:
- portability?
- ease of use?
- ease of debugging?
- ease of execution?

A
  • Programs are processor specific
  • Mnemonics help to make code slightly easier for humans to understand
  • Debugging is easier than with machine code but still far more difficult than with high-level languages
  • An assembler must be used before a program is executed, but each instruction has a 1-to-1 correlation to a machine code instruction so translation is quick.
34
Q

High Level Language:
- portability?
- ease of use?
- ease of debugging?
- ease of execution?

A
  • Portable. Programs are not specific to certain processors.
  • Code uses English, making it easy for humans to understand.
  • Named variables, indentation and commenting make debugging fairly easy
  • A compiler or interpreter must be used to translate source code into object code before it can be executed. This can be time consuming.
35
Q

What is intermediate code designed to run on?

A

A virtual machine installed on each make of computer