Interpreter and Compiler in programming explained! (Never forget again)

Interpreter and Compiler in programming explained! (Never forget again)

Short article with detailed explanation of interpreters and compilers

·

2 min read

This is a very short article with a detailed explanation of interpreters and compilers

What is a programming language?

A programming language is a language that enables humans (developers) to communicate with a computer system. So yeah, HTML is not a programming language as it can only be interpreted by the browser. It is parsed.

What language does a computer understand?

As we all know, a computer only understands machine-level code (binary) which consists of 0's and 1's.

Every programming language has an in-built interpreter or compiler to help convert them into binary.

What are an interpreter and compiler?

An interpreter is an in-inbuilt medium in a programming language that translates this programming language into binary for the computer to understand. An interpreter translates the code line by line from the beginning to the end.

A compiler is also an in-built medium in a programming language that translates this programming language into binary for the computer to understand. A compiler translates the whole code at once into binary.

Interpreter and Compiler explained with examples

INTERPRETER

Let's create a scenario to show how an interpreter works

I want to prepare a Spanish meal, I buy a cooking book showing the steps on how to prepare this Spanish meal**.**

Now, this book is written in Spanish and I do not understand Spanish, I understand English.

Luckily for me, I have a Spanish friend who understands both Spanish and English.

While I cook, my friend translates each step line by line into English, so that I can understand.

In the above scenario, I am the computer, my friend is the interpreter, Spanish is the programming language, and English is the binary language.

COMPILER

Using the same scenario above.

I replace my friend with a translated version of the book in English, so now I understand and I can cook.

Some programming languages and their various in-built mediums

Python - Interpreter

Java - Interpreter and Compiler

C# - Compiler

C++ - Compiler

Rust - Compiler

Go - Compiler

PHP - Interpreter

Ruby - Interpreter

Javascript - Interpreter

Conclusion

Interpreter and compiler perform the same task, an interpreter does it line by line WHILE a compiler does it all at once.

Did you get value? like, comment and follow to always get content like this.

Made with ❤️ from rivondave