top of page

5.1: Languages & Translators

Exam Board:
OCR

Specification:
J277

There are two types of programming languages used within computer systems:

High-Level Languages

Why do programmers use high-level languages?

​

High-level programming languages use code written in a way that is similar to a natural human language, such as English, making it easier to understand and use the language.

​

Using high-level languages leads to fewer errors and allows for more powerful and complex commands compared to low-level languages.

​

However, a high-level language must be translated into machine code (binary) before it can be run, as high-level languages cannot be executed directly by the CPU.

Popular high-level languages:

PYTHON

C++

Java

Visual Basic

Low-Level Languages

Low-level languages do not closely resemble a natural human language, making it harder for humans to understand and write in.

​

Low-level languages are used when a program must be executed quickly or when programmers need to write code that interacts directly with the hardware, such as device drivers.

​

There are two types of low-level language

Machine Code

​

This is the pure binary code that computers can directly process and execute.

​

It is extremely tedious and difficult for humans to understand and write machine code.

​

However, machine code can be used when a programmer needs to perform a very specific command that can't be done in a high-level language.

​

Machine code will be executed faster than high-level programs because it is already in a format the CPU can execute and does not need to be translated.

0010 1011 0101 0101 0110 0111 0101 0001 0101 0101 0101 0100 1010 1010 1010 1010 1111 1110 0010 1001 0100 1001 0010 0111 0111 0101 0011 1010 1000 0101 0110 0111 0000 1010 1010 0011 1101 1001 0010 1101 0010 0100 1001 0011 1010 1001 0101 0101 0010 0101 0111 0101 0101 1000 1011 0111

Assembly Language

​

Assembly language uses specialised command mnemonics to perform actions. See the Assembly Language section in the programming tab for a list of mnemonics such as INPOUT and HLT

​

Assembly language is preferred by many programmers over machine code because it is easier to understand and spot errors.

​

It is faster to execute than high-level languages and, like machine code, can be used to directly control the CPU.

INP

STA Number1

OUT

HLT

Number1 DAT

Translators

A translator changes (translates) a program written in one language into another language (usually machine code).

​

There are two main types of translator:

Interpreter

An interpreter converts high-level language one line at a time into machine code and executes it.

Compiler

A compiler converts high-level language into machine code for execution at a later time. The entire program is converted at once

PYTHON

PYTHON

0010 1011 0101 0101 0110 0111 0101 0001 0101 0101

0010 1011 0101 0101 0110 0111 0101 0001 0101 0101

Interpreters vs Compilers

Interpreter

Compiler

  • Execution Method:

    • An interpreter translates source code (high level code) into machine code one line at a time.

​

  • Execution Speed:

    • An interpreter is slower than a compiler because the code must be reinterpreted each time the program is run.

​

  • Complexity:

    • Interpreters are smaller, simpler programs.

​

  • Error Reporting:

    • In error reporting, the interpreter would encounter the errors and report it to the user immediately and stops the program from running.​

​

  • Repetition:

    • Interpreted programs can be edited and run without translating the whole program.

    • Interpreters must reinterpret the program every time it is run.

  • Execution Method:

    • A compiler translates all the source code (high level code) into machine code in one go.

    • A compiler produces an executable file that will run on other machines without the compiler needing to be installed.

​

  • Execution Speed:

    • Compilers can produce much more efficient code than interpreters making the compiled programs run faster.

​

  • Complexity:

    • Compilers tend to be large complex programs.

​​

  • Error Reporting: 

    • The compiler would analyse the entire program, taking note of where errors have occurred and record them in an error file.

​

  • Repetition:

    • Compilation requires analysis and the generation of the code only once, whereas interpreters must re-interpret each time.

    • However, compiled programs have to be re-compiled after any changes have been made.

x1

x1

Monochrome on Transparent.png

Questo's Questions

5.1 - Languages & Translators:

​

1a. Describe three reasons why programmers use high-level languages[3]

1b. Explain one limitation of using high-level languages. [2]

​

2a. Describe a key difference between low-level languages and high-level languages.  [2]

2b. Describe when a low-level language would be used instead of a high-level language. [2]

2c. Describe an advantage and a disadvantage of writing directly in machine code. [2]

2d. Describe what assembly language is. Give one benefit to using assembly language instead of machine code and one benefit to using it instead of a high-level language. [3]

​

3. Compare high-level and low-level languages by stating which is:

  • a. Easier to understand [1]

  • b. Requiring translation [1]

  • c. Quicker to execute [1]

​

4. Compare interpreters and compilers for each of the following features:

  • a. Execution Method

  • b. Execution Speed

  • c. Complexity

  • d. Error Reporting

  • e. Repetition           [10 total]

bottom of page