Chapter 4

Programming Languages and Translators

High-level versus low-level languages, and how compilers, interpreters and assemblers translate source code into machine code the CPU can run.

High-level and low-level languages

A high-level language is written in a form close to human language, using words such as if and while. It is easier to read, write and debug, and can run on different types of computer. A low-level language is closer to the hardware. Machine code is written in binary and is the only language the CPU runs directly, while assembly language uses short mnemonics that stand for machine instructions.

Key idea

The CPU can only execute machine code (binary). Any high-level program must first be translated into machine code before it can run.

Translators

A translator is a program that converts source code into machine code. There are three main types:

  • A compiler translates the whole program at once, producing an executable file. Translation is slower, but the finished program then runs quickly without the compiler.
  • An interpreter translates and runs the program one line (statement) at a time. It is useful for testing but runs more slowly, and the interpreter is needed every time.
  • An assembler translates assembly language into machine code.

Remember

  • Compiler = whole program at once; interpreter = line by line.
  • Machine code is binary and runs directly on the CPU.
  • An assembler translates assembly language.

Stuck on this topic? A verified JomKelas tutor can walk you through it.

Find a verified tutor