Authors Top

If you have a few years of experience in Computer Science or research, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

1. Overview

In this tutorial, we’ll learn about language processors, what they do, their characteristics, and their differences.

2. What Is a Language Processor?

A language processor, or translator, is a computer program that translates source code from one programming language to another. They also identify errors during translation.

Computer programs are usually written in high-level programming languages (like C++, Python, and Java). Further, to make them understandable by the computer, a language processor needs to translate the source code into machine code (also known as object code, which is made up of ones and zeroes).

There are three types of language processors: assembler, compiler, and interpreter.

3. Assembler

The assembler translates a program written in assembly language into machine code.

Assembly language is a low-level, machine-dependent symbolic code that consists of instructions (like ADD, SUB, MUX, MOV, etc.):

Assembler

4. Compiler

A compiler reads an entire source code and then translates it into machine code. Further, the machine code, aka the object code, is stored in an object file.

If the compiler encounters any errors during the compilation process, it continues to read the source code to the end and then shows the errors and their line numbers to the user.

Compiled programming languages are high-level and machine-independent. Moreover, examples of compiled programming languages are C, C++, C#, Java, Rust, and Go:

Compiler

5. Interpreter

An interpreter receives the source code and then reads it line by line, translating each line of code to machine code and executing it before moving on to the next line.

If the interpreter encounters any errors during its process, it stops the process and shows an error message to the user.

Interpreted programming languages are also high-level and machine-independent. Python, Javascript, PHP, and Ruby are examples of interpreted programming languages:

Interpreter

6. Comparison Between Interpreter and Compiler

Compilers and interpreters both have their pros and cons:

6.1. Debugging

Debugging is easier with an interpreter since they stop right after encountering an error message, whereas a compiler shows error messages after reading the entire program.

6.2. Object File

A compiler generates a file containing machine code after translating the source code. This file is known as an object file.

An interpreter doesn’t create an object file.

6.3. Execution Time

The execution time of a program written in an interpreted language is slower since an interpreter needs to translate and execute each line of the source code. However, since a compiler generates an object file, the execution time is faster.

6.4. Needs Source Code

A compiler generates an object file, so we don’t need the source code to execute the program later. In contrast, an interpreter requires source code to execute the program.

6.5. Memory Usage

A compiler needs to generate object codes, so it requires more memory than an interpreter.

7. Conclusion

In this article, we learned about programming language processors and their differences.

Authors Bottom

If you have a few years of experience in Computer Science or research, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

Comments are closed on this article!