Compiler Vs. interpreter: explanation and differences

A computer program is typically composed in a high-level language known as source code. The key distinction between an interpreter and a compiler lies in the moment when the source code is executed. This implies that during the process of converting source code into machine code, developers utilize either a compiler or an interpreter. Thus, classifying computer languages solely as "compiled" or "interpreted" may not be entirely meaningful. Presently, interpreting versus compiling involves a trade-off, as the time invested in compiling is often compensated with enhanced runtime performance, whereas an interpretative environment offers greater scope for interaction and adaptability.

Compilers vs. interpreters: explanation and differences

What is a Compiler?

A compiler is a computer program responsible for translating source code written in a programming language into a different computer language. It generates a binary executable in the native format of the target machine, ready to execute without any additional preparation or processing. This compiled binary includes all necessary resources, except for system libraries, and executes efficiently since it contains native code optimized for the CPU of the target machine. Although a compiled program lacks human readability as it is written in architecture-specific machine language, it delivers enhanced performance due to the extensive and time-consuming optimizations performed during compilation.

example :
  1. C
  2. C++
  3. C#
  4. Objective-C
  5. SWIFT
  6. Fortran

Some compilers compile not to CPU-specific machine instructions but to bytecode, a kind of artificial machine code for a fictitious machine. This makes the compiled program a bit more portable, but requires a bytecode interpreter on every target system.

What is an Interpreter?

An interpreter is another type of computer program that also translates a high-level language into a low-level one, but it does so during the actual execution of the program. In this process, the interpreter takes source code written in a programming language and directly executes it, one instruction at a time. This stands in contrast to compiled languages, where the source code is transformed into machine code and then executed directly by the host CPU. Interpreters convert each statement into machine language, execute it, and move on to the next statement. They generate machine-independent code that can be further compiled on-the-fly into assembly code, known as Just-in-Time compilation. Generally, interpreted programs may be slower than compiled ones, but they offer advantages in terms of easier debugging and quicker revision due to their dynamic nature..

example :
  1. Python
  2. Ruby
  3. PHP
  4. Perl
  5. R
  6. Powershell

Many interpreters will pre-compile the code they're given so the translation step doesn't have to be repeated again and again.


interpreter vs. compiler: explanation and differences


  1. Spends a lot of time analyzing and processing the source code.
  2. The resulting executable is some form of machine-specific binary code.
  3. The computer hardware executes (interprets) the resulting code.
  4. Program execution is fast.


  1. Relatively little time is spent analyzing and processing the source code.
  2. The resulting code is some sort of intermediate code (bytecode).
  3. The resulting code is interpreted by another program.
  4. Program execution is relatively slow.

Intermediate to computer-specific compiled programs and interpreted scripts are programs designed for runtime environments. Java and Smalltalk programs are executed in this fashion. Some other computer languages, which are compiled as well as interpreted , are Scala, Haskell or Ocaml. Each of these languages has an interactive interpreter, as well as a compiler to byte-code or native machine code.