Interpreter & Compiler

Programming Concepts #001

Akila Senanayake
4 min readSep 21, 2023

The basic concepts in programming and it will be a great help to understand the functions of programming.

Table of Content

‘· Introduction
Compiler
Interpreter
· Difference between this compiler and interpreter?
Hybrid (Compiled and Interpreted)
Why Do we use both?

Interpreter vs Compiler

Introduction

A machine can understand only binary format programs. But we use high-level languages for programming. High-level language uses English words and symbols. A machine cannot understand that. That is why we use an interpreter or compiler to convert high-level language to machine language (Binary format).

Some programming languages are compiler-based languages, and some languages are interpreted languages.

Compiler

A compiler is a program that translates source code into machine code. This program is then used to generate machine code that can be used to run the program.

Generate a separate executable file with machine code (.exe) by the compiler. We can run this executable file with/without that source code.

Click here to visit more information about Compiler.

Interpreter

An interpreter is a program that directly executes the instructions in a high-level language, without converting it into machine code.

We use a web browser like an interpreter. This does not generate a separate file. Interpreted language read line by line in source code and displayed/executed in a web browser. Source code must have to run this.

Click here to visit if you want more about the interpreter.

Difference between this compiler and interpreter?

A compiler is a software tool that converts human-written computer code into machine code. It generates an executable file, but an interpreter is not.

The executable file runs fast because the machine can understand quickly. Compiler language is faster than interpreted language.

If we want to keep personal our source code within a project, compile language is the best solution. But we must share source code to run the interpreter language.

Compile language fully converts source code to machine code but interpreter language converts it line by line. See more

Difference between interpreter and compiler | See more
Explain about Interpreter and Compiler programming languages

Hybrid (Compiled and Interpreted)

First, the source code is converted to a byte code (.class) by the compiler (if the source code does not have any error). Then, the Interpreter converts it to machine code.

In this case, Java uses JVM (Java Virtual Machine) as an interpreter. We cannot display within the execution like a web browser.

And also Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. (Python uses a compiler inside the interpreter).

Why Do we use both?

When we can use both, we have some Advantages. Byte code compiled by Java that can run (in a JVM) with any operation system. So, we only have to install JVM to our Operating system.

Executed files converted by the compiler can run only one operating system because that file compiles on that operating system. An example of that is if we run that exe file in a Windows operating system, then we can only run this file in a Windows operating system. Cannot communicate with other operating systems.

But in Java, the byte code we created can communicate with a JVM. We have to install Java for our OS and then we have a JVM so this JVM communicates with a system and byte code can run in any operating system with a JVM. That is a reason for compiled byte code by Java can run in any operation system. It defined the Java Portability feature.

That is the reason Java is the most popular for making distributed applications.

In conclusion, machines cannot understand High-level language. That is why we use an interpreter or compiler to convert it to machine language. As mentioned above, different types of programming languages work with different advantages, and the differences between them are also as above.

Hope you get something new from it. Don’t forget to share it with the community, too, so they can also benefit from this context.

— You can follow me on medium.com, I’ll share more valuable articles on different sides of technology and others, so don’t miss those. 🚀

--

--

Akila Senanayake

Undergraduate in Computer Science | The aim is to share in an informed manner the range of information that has been learned and is being learned.