Translators. Compiler vs Interpetator

11.5.1.7 analyze the advantages and disadvantages of compilers 

11.5.1.8 analyze the advantages and disadvantages of interpreters

Translators. Compiler vs Interpetator

How can we convert program code into binary so that a computer can understand it? 

Translators translate high-level language programs into machine language programs that the central processing unit (CPU) can understand.  It also detects errors in the program.

Different Types of Translators

There are 3 different types of translators as follows:

  1. Assembler
  2. Compiler
  3. Interpreter

We consider two types: Compiler and Interpreter.

Worksheet to video

Compiler

A compiler is a translator used to convert high-level programming language to low-level programming language.  It converts the whole program in one session and reports errors detected after the conversion. The compiler takes time to do its work as it translates high-level code to lower-level code all at once and then saves it to memory.

Interpreter

Just like a compiler, is a translator used to convert high-level programming language to low-level programming language. It converts the program line by line and reports errors detected at once while doing the conversion. With this, it is easier to detect errors than in a compiler. 

Comparison Compiler and Interpreter.

A look at how compilers and interpreters work, and how their differences affect memory, runtime speed, and computer workload.

  A COMPILER AN INTERPRETER
Input ... takes an entire program as its input. ... takes a single line of code, or instruction, as its input.
Output ... generates intermediate object code. Once compiled, the program can be executed multiple times without needing re-compilation. ... does not generate any intermediate object code. The program code must be translated every time it is launched.
Speed ... is faster, because translates the entire source code into machine code (or some intermediate code) all at once. ... is slower, because it translates the source code line-by-line as it's being executed.
Memory ... requires more memory in order to create object code, because a compiler examines the entire program. ... requires less memory, because processes source code line-by-line and doesn't need to load or analyze the entire program at once.
Workload ... doesn't need to compile every single time, just once. ... has to convert high-level languages to low-level programs at execution.
Errors ... displays all errors once the entire program is checked. ... displays only the first error when executing the first incorrect instruction.

Sources: teachcomputerscience.com

 

Questions:

  1. What exactly are the differences between compiling and interpreting a programming language?
  2. What are the pros and cons of each?

Exercises:

Ex.1

Ex.2 (Author: Litvinova Olga - CS teacher of NIS Pavlodar)

Ex. 3

Exam questions:

Категория: Programming languages | Добавил: bzfar77 (22.09.2020)
Просмотров: 6326 | Комментарии: 3 | Теги: line by line, compiler, Assembler, Translator, object code, advantages, disadvantages, interpretator | Рейтинг: 5.0/4
Всего комментариев: 3
avatar
1
3 miralijn • 22:29, 06.10.2022
спасибо
avatar
1
1 zaa2282012 • 19:56, 27.09.2021
Очень интересная статья
avatar
0
2 bzfar77 • 13:31, 01.10.2021
Спасибо! Стараюсь для вас!
avatar