Concept in Definition ABC
Miscellanea / / July 04, 2021
By Guillem Alsina González, in Sep. 2017
How can we get along with someone with whom we have no language in common? Through a translator. This translation function is what performs a compiler to turn into code executable source code written by a programmer.
Compilation is the process by which a program written in a high-level language is translated to the machine code used by a certain computer architecture, for its execution direct.
Therefore, and according to the explanation that we have just proposed, this system requires the choice of a architecture destination, which may be different in each case and will force us to compile separately for each of the different architectures in which we want our program to run.
Thus, for example, we can advance on a certain program for the 32-bit x86 architecture, the 64-bit x86, the PowerPC or the ARM also differentiating 32 and 64 bits, depending on the type of device in which we want run it.
In addition, we must also take into account the different operating systems, even if we are working for the same platform hardware, since each one has a different way of interacting with the physical machine
Let's take the x86 64-bit platform as an example. We may want to compile for Windows, GNU / Linux or macOS, or for each and every one of them, which involves three separate compilation processes.
Sometimes, this forces us to slightly tweak the source code, often keeping three separate versions (or more, depending on the case) in order for them to interact correctly with the peculiarities and differences of the destination platform.
The compilation process follows a series of steps, such as detecting syntactic errors in the source code, then a pre-processed to know the resources that the program needs, and finally the link with the libraries and resources necessary for its execution.
In this way, a file executable containing all resources necessary for its execution, and the instructions necessary for accessing external resources, such as shared code libraries (shared).
The compilation process is done with a specific tool or tools (compiler), although it is common for this to be integrated into development environments (IDE), thus facilitating its use.
Each language of programming It has its own compiler, although for a long time, the compiler corresponding to a language and environment, is capable of generating executables for various platforms software different.
Is there an alternative option to the build process? Yes, and they are interpreted languages.
Interpreted languages are those that are translated at runtime, and not compiled.
Therefore, their source code is always available, and what they need is that in the operating system on which they are executed, there is an interpreter.
By avoiding the compilation process, if the interpreter is available for multiple platforms, it will be possible to run the program directly on each and every one of them, usually without changes.
Other focus alternative, halfway between compiled and interpreted languages, are those that require a virtual machine to run, for example, Java.
Programming languages that run on top of a virtualization layer (virtual machine) require an intermediate process similar to that of compilation, but that results in a code that is not directly executable, although more optimized than that executed by a language interpreted.
In these cases, it does require a process similar in form to that of compilation, but that gives a different result and that still requires, in any case, the installation of a runtime in the operating system in which we want to run our program.
Photos: Fotolia - Alexander Pokusay / Onot
Topics in Compilation