What is a compiler, or How to make a computer understand what you want from it?

Table of contents:

What is a compiler, or How to make a computer understand what you want from it?
What is a compiler, or How to make a computer understand what you want from it?

Video: What is a compiler, or How to make a computer understand what you want from it?

Video: What is a compiler, or How to make a computer understand what you want from it?
Video: How do computers read code? 2024, May
Anonim

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 in order to perform any task, computers need to be given commands in a language they understand, close to binary and operating with primitive data structures (bit, byte or word). The process of translating domain-specific statements of high-level languages into binary code is called translation. There are two translation methods - compilation and interpretation.

compiler is
compiler is

Compiler - what is it?

Analysis of many interpretations of the terms "compiler" and "compilation" allows us to highlight the following definition. A compiler is a program designed to translate the text of a source 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

An interpreter is a utility thatas well as a compiler, designed to translate source code into machine code. However, unlike the compiler, the interpreter runs every time with the program and performs the translation line by line.

You 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

compiler is a program
compiler is a program

Compilers are classified mainly by features related to their areas of practical application.

Vectorizing compiler is a utility that translates source code into object code and is adapted for computers equipped with vector processors.

A 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 of compilers.

Incremental compiler is a language processor that retranslates separate fragments of source code and additions to it. However, it avoids recompiling the entire application.

An interpretive (stepping) compiler is a utility that sequentially performs independent compilation of each statement or command of a high-level source code.

A compiler of compilers is a translator capable of accepting a formal description for a programming language and independently generating a compiler for any language.

compiler and interpreter
compiler and interpreter

The debug compiler allows you to find and fix some kinds of syntax errors made when writing source code

A resident compiler occupies a permanent place in RAM and is therefore reusable by a wide range of tasks.

The self-compiled compiler is written in the same language as the translation.

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 core, syntactic and semantic loaders.

Compiler device

A compiler and a linker are at the heart of any compiler. 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 that is associated with the translator (or translators, if different programming languages were used when writing the source code) and the linker and starts their execution when necessary.

Programming languages and translation methods

language compiler
language compiler

Despite the fact that a program written in any programming language can be both compiled and interpreted, many high-level languages have a predisposition to one or another method of translation. So, the C language was originally designed for compilation, and Java - for the interpretation of the written program. Are being developedC compilers are quite easy, thanks to its relatively low level and a small number of structural elements.

Advantages and disadvantages of compilers and interpreters. Applications

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, in 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 bytecode (in this case, the source program is converted into an intermediate form that can be executed on various hardware platforms).

Recommended: