Back

Compilation

Idealogic’s Glossary

Compilation is the important phase of computer programming where the source code which is written in high level language that can be easily understood by human being, is converted into low level language which can be easily understood by computer. This is the process of translating the written code into machine language which is a process that is vital in developing software since it enables the computer to understand what the programmer has coded for it to do. Compilation is important as it makes the code to be well suited to run on any platform that is specific to the programming language used.

The Compilation Process

It is a step by step procedure that is done in order to come up with the final product. First of all, the compiler verifies the code’s adherence to the syntactic constraints of the programming language which defines how the elements of the code can be combined. This stage is called syntax analysis or parsing where the compiler checks whether the code is syntactically correct or not i. e. whether it follows the rules of the language. In case there are any syntactical errors the compiler will produce error messages which will then inform the programmer to make corrections on the given code.

The next step is the optimization phase of the code after the syntax analysis is done. This step is an optimization step where the code being compiled is analyzed to enhance its execution and minimize on its resource usage such as memory and processor time among others. Some of the techniques that may be used in optimization include; removing duplications, reducing memory space, and improving loops.

Hence, the compiler produces the machine code after the optimization phase. The machine code is a set of instructions which are designed to work with a certain type of hardware platform that the software is intended to be executed on. The last result of the compilation process is a binary file which is capable of being executed by the operating system of the computer. This is a binary file which contains the machine code that the processor of the computer is able to understand and act upon to execute the task set by the high level code.

Types of Compilers

Compilers are of various categories with each having its own distinct use and compatibility with certain platform. Some of the compilers generate machine level code from the source code and the output is in the form of an executable file which can be executed on the target machine. These are the Native compilers and are often used for creating software which is required to have an optimal execution on a particular hardware.

Other compilers produce so called intermediate code which is not directly executable and can be used by other tools for further processing or can be directly executed at runtime. This code can be easily seen in the intermediate languages such as Java where the source code is compiled into bytecode that could be run on any platform that has a compatible Java Virtual Machine.

Importance of Compilation

This page seeks to establish the importance of the compilation process towards the development of functional and efficient software. Proper compilation helps in checking the syntactical correctness of the code and also the code is written in a way that it would perform well on the target hardware. This process also enables developers to generate programs that can be executed on different platforms from the same source code since the same code is translated into machine language for different hardware configuration.

Compilation is one of the most basic operations of software engineering that converts instructions written by developers in high-level languages into machine codes to be understood by computers. In this manner, following a number of stages such as syntax checking, optimization and code generation the compiler generates an executable file which is compatible with the specific hardware platform. There are various types of compilers which are used for a specific purpose, it may compile the code into the native machine code or it may compile the code into the intermediate format which can be executed on any platform. The compilation step is very critical in the performance, the efficiency and the portability of the final software product produced.