Module 4 Chapter 4 Programming Language Translators Flashcards Preview

A-Level Computer Science AQA > Module 4 Chapter 4 Programming Language Translators > Flashcards

Flashcards in Module 4 Chapter 4 Programming Language Translators Deck (14)
Loading flashcards...
1
Q

Why does code written in anything other than machine code need to be translated before it can be run?

A

Because processors can only “understand” binary.

2
Q

What would be used to translate assembly language into machine code?

A

An assembler.

3
Q

What problems could arise when running assembly language on a machine other than the one it was written on?

A

The assemblers used by the two machines may be different (have a different instruction set) and could therefore translate the instructions incorrectly.
For example, one processor may represent LDA as 0000 whereas another may represent it as 1000 causing the translated code to be different.

4
Q

What is an assembler?

A

A program that converts a program in assembly language (source code) into machine code (object code).

5
Q

What is source code?

A

The input for a translator, written in assembly language or a high-level programming language.

6
Q

What is object code?

A

The output of a translator, written in machine code.

7
Q

What is a compiler?

A

A compiler is a program that translates a high-level language such as Java or C# into machine code. The code written by the programmer, the source code, is input as data to the compiler, which scans through it several times, each time performing different checks and building up tables of information needed to produce the final object code. Different hardware platforms will require different compilers, since the resulting object code will be hardware-specific. For example, Windows and Intel microprocessors comprise one platform, Apple and PowerPC processors another, so separate compilers are required for each. The object code can then be saved and run whenever needed without the presence of the compiler, making it faster to launch.

8
Q

What is an interpreter?

A

An interpreter is a program that translates a high-level language such as Python into machine code. Once a programmer has written and saved a program ad instructs the computer to run it, the interpreter looks at each line of the source program, analyses it and (if it contains no syntax errors) translates it into machine code and runs it. The interpreter may scan through the entire code for certain basic errors such as a missing bracket before running any of the code. This is the case in many languages such as Python.

9
Q

What name is given to code produced by a combination of compiling and interpreting?

A

Bytecode.

10
Q

What is used to run bytecode?

A

A bytecode interpreter.

11
Q

What are the main advantages of using byte code?

A
  • You can achieve platform independence. The bytecode can be interpreted on different types of machine architecture.
  • It may act as an extra layer of security between an unknown program and your computer as the bytecode interpreter will guard against malicious software.
  • It is possible to convert from one programming language to another. For instance, Python can be compiled into Java bytecode and run by the Java interpreter.
12
Q

Give four advantages of using a compiler over an interpreter.

A
  • The object code can be saved on disk and run whenever required without the need to recompile. However, if an error is discovered in the program, the whole program has to be recompiled.
  • The object code executes faster than interpreted code.
  • The object code produced by a compiler can be distributed or executed without having to have the compiler present.
  • The object code is more secure, as it cannot be read without a great deal of reverse engineering.
13
Q

Give two advantages of using an interpreter over a compiler.

A
  • It is useful for program development as there is no need for lengthy recompilation each time an error is discovered.
  • It is easier to partially test and debug programs.
14
Q

Give one disadvantage of using an interpreter over a compiler.

A

The program may run slower than a compiled program, because each statement has to be translated into machine code each time it is encountered. So if a loop of ten statements is performed twenty times, all ten statements are interpreted twenty times.

Decks in A-Level Computer Science AQA Class (36):