The final stage of creating a program is to translate an algorithm written in one of the programming languages (C / C ++, Pascal, etc.) into a low-level machine language. This is due to the fact that computers must perform commands in a language they understand that is close to binary and operates with primitive data structures (bit, byte or word) to perform a task. The process of translating problem-oriented operators of high-level languages into binary code is called translation. There are two translation methods - compilation and interpretation.
Compiler - what is it?
An analysis of the many interpretations of the terms “compiler” and “compilation” allows us to single out the following definition. A compiler is a program designed to translate the text of an original algorithm from a high-level language into an equivalent set of instructions in a machine-oriented language. This is the so-called object code, for the subsequent assembly of the resulting object code into a ready-to-use program module.
Compiler and interpreter - similarities and differences
The interpreter is a utility, as well as a compiler, designed to translate source code into machine code. However, unlike the compiler, the interpreter is launched each time along with the program and performs the translation line by line.
We can say that the compiler and interpreter are language processors that allow the computer to recognize and execute commands given by the programmer.
Compiler Classification
Compilers are classified mainly by features related to their fields of practical application.
A vectorizing compiler is a utility that translates source code into object code and is adapted for computers equipped with vector processors.
The flexible compiler is programmed in a high-level language in a modular fashion. Its management is carried out using tables. It is also possible to execute it using the compiler compiler.
An incremental compiler is a language processor that re-translates individual fragments of the source code and additions to it. However, it eliminates the recompilation of the entire application.
An interpreter (step-by-step) compiler is a utility that sequentially independently compiles each statement or command from the source high-level code.
A compiler compiler is a compiler capable of perceiving a formal description for a programming language and independently generating a compiler for any language.
The debug compiler allows you to find and fix some types of syntax errors made when writing source code
The resident compiler takes up a permanent place in RAM and, therefore, is available for reuse by a wide range of tasks.
The self-compiling compiler is written in the same language from which the translation is performed.
The universal compiler is based on a formal description of the semantic and syntactic parameters of the input language. The main components of such a utility are the kernel, syntactic and semantic loaders.
Compiler device
At the heart of any compiler are the translator and linker. Often, when compiling, an external linker is used, and the compiler itself performs only the translation function. It also happens that the compiler is implemented as a kind of manager program associated with the translator (or translators, if different programming languages were used when writing the source code) and the linker and launching them if necessary.
Programming Languages and Translation Methods
Despite the fact that a program written in any programming language can be either compiled or interpreted, many high-level languages are predisposed to one or another translation method. So, the C language was originally designed for compilation, and Java - for the interpretation of a written program. C compilers are developed quite easily, due to its relatively low level and a small number of structural elements.
Advantages and disadvantages of compilers and interpreters. Areas of use
Note that compiled applications are faster than interpreted ones, but at the same time, the machine code obtained as a result of compilation depends on the hardware platform. So, a program written and compiled for Windows will not work, for example, on Linux. Therefore, in the case of Internet applications, when it is impossible to say in advance in which environment they will work, they use interpretation or byte code (in this case, the original program is converted into an intermediate form that can be executed on various hardware platforms).