Why do you need a compiler

Compiler and interpreter

Compilers and interpreters are forms of software implementation. In general, compiling and interpreting is about converting the source text that was written with a high-level programming language (for example C ++, C # or Java) into machine instructions. This means that the readable programming instructions have to be translated into less complex instructions so that the processor can execute them.
In theory, the source code of any programming language can be implemented with both a compiler and an interpreter. In practice, however, the implementation is fixed. The use of a programming language defines the use of a compiler or interpreter.


The compiler is a program that creates the actual program from the source text. The source code could be written in C or C ++, for example. Individual instructions from the source text are translated into sequences of machine instructions. After compiling, the program is created that contains executable code. When the program is executed, these instructions are executed "directly" by the processor. Each machine instruction corresponds to a defined bit sequence. This bit sequence is processed within the processor. The executable code also processes input and produces the output.
When compiling software, the compiler determines which instructions are sent to the processor in which order. If these instructions do not have to wait for others, the processor can even process several of them in parallel.

As soon as a new operating system or a new processor is used, the source code has to be recompiled. In practice, processors and operating systems have a compatibility mode so that old programs also run on new platforms. This means that compiled programs do not always have to be recompiled. But of course the compatibility has its limits.

For each programming language (m) a separate compiler (m x n) is required for each processor (s). Typical programming languages ​​with compilers are Pascal, Modula, COBOL, Fortran, C and C ++.

Advantages: The translation into executable code is extremely efficient and optimizes the generated code. Compiled programs work very quickly, which is particularly worthwhile with long-running programs.

Disadvantage: Compiling increases the effort involved in software development, which takes up a lot of time and resources. Every time the source code is changed, it must be compiled again if the program is to be tested.


The programming language converts the source text into a hardware-independent byte code. The interpreter converts this bytecode into machine instructions. You have to think of the interpreter as a virtual machine (VM) in which the program runs. The interpreter should not be confused with a virtual machine using virtualization technology. These are two different techniques with the same name.

The interpreter is a software library that accepts inputs and bytecode and interprets them at runtime. The interpreter acts as a virtual machine that executes the bytecode. The interpreter takes on the role of the processor.
The virtual machine is to be understood as an intermediate layer between the programming language and the processor. It is a software container. Now you only need one interpreter per processor.

Typical programming languages ​​with an interpreter are BASIC, Smalltalk, LISP and Python.

Advantages: When developing the software, you can test immediately, which makes debugging (troubleshooting) easier. The executable code used is only generated at runtime.

Disadvantage: In general, interpreted programs are slower and inefficient. The same program parts, such as loops and functions, always have to be compiled again.

JIT compiler (JIT = just in time)

There are also programming languages, such as C # and Java, that combine compilers and interpreters. As with the interpreter, the source text is translated into hardware-independent VM instructions (bytecode). When these instructions are executed by the JIT compiler, the instructions are translated into machine code. The JIT compiler takes the various peculiarities of the processor into account.

With the JIT compiler, the machine code for the processor is generated from the bytecode of the programming language, because this is faster than when the interpreter executes the bytecode. The bytecode is discarded after the execution and has to be compiled again when the execution is repeated.

Typically you work with a JIT compiler when it comes to the principle of "write once, run anywhere".
So when it comes to using the source code on different operating systems and hardware.
Software is written once and can then be run on different platforms (portability).

Other related topics:

NEW 5th edition of the computer technology primer

The 5th edition of the Computertechnik-Primer has been completely revised and is available as a printed book, as an eBook in PDF format and in the Google Store, for Amazon Kindle and Apple iBook.

The Computertechnik-Fibel is a book about the basics of computer science, processor technology, semiconductor memory, interfaces, drives and important hardware components.

Order or download now

Everything you need to know about computer technology.

Computer technology primer

The computer technology primer is a book about the basics of computer technology, processor technology, semiconductor memory, interfaces, data storage, drives and important hardware components.

I want that!