Subscribe Us

header ads

Compilation

The translation we are referring to is made by a specialized computer program called a compiler. The process of translating from a high-level language into a machine language is called compilation.

Now let's get back to more interesting issues related to the process of creating a new program. We already know that the main task is to write a program in accordance with the rules of the chosen programming language. Such a program (which in fact is just text) is called the source code, or simply source, while the file which contains the source is called the source file.

To write the source code you need a text editor that allows you to manipulate text without any formatting information (for this reason Microsoft Word isn't a good choice, in contrast to the Notepad). This code is placed in a file and the name of the file should give you some clue as to its content. For example, it’s common for a file containing the source code in the “C“ language to have its name ending with the suffix “.c”, so if you wrote a computer program and decided to name it "proggie" it would be a good idea to put the source code into a file named “proggie.c”.

Next, your source code needs to be compiled. To do this you run a compiler, instructing it where you stored the source code that you want to be translated into machine language. The compiler reads your code, does some complex analysis and its first goal is to determine whether or not you made any errors during the coding. These analyses are very insightful, but remember that they are made by a machine, not a human, and you shouldn’t expect too much from them. OK, if your mistake was that you tried to add up two numbers using “#” instead of “+”, the compiler will kindly inform you of your error.

However, if you typed a "-" instead of a "+", the compiler will no longer be able to guess that your intention was to add two numbers, rather than to subtract them. Do not expect the compiler to think for you. But there’s no reason to be sad about it – thanks to that, developers are still needed.

If the compiler doesn’t notice any mistakes in your source, the result of its work will be a file containing your program translated into machine language. That file is commonly called an executable file. The name of the file depends on the compiler you use and the operating system you’re working with. For example, most compilers designed for the Unix/Linux system create an output file named “a.out” by default. Compilers designed for use in MS Windows® can give this file the same name as the source file, only changing the suffix from “.c” to “.exe”.

We must admit that the whole process is actually a bit more complicated. Your source code might be comprehensive and divided among several or even dozens of source files. It may also happen that the program was not written by you alone, but by a team, in which case the division of sources into multiple files is simply a must. In such cases, the compiling splits into two phases – a compilation of your source, in order to translate it into machine language, and a joining (or gluing) of your executable code with the executable code derived from other developers into a single and unified product. The phase of “gluing” the different executable codes is commonly known as linking while the program which conducts the process is called a linker.

Post a Comment

0 Comments