3 step process for source code compilation


Source code is the foundation of computer programs. Unlike human beings, computers can only understand machine language i.e. the binary numbers.

Whatever the code you have written, the computer runs it and converts it to machine language code.

So how does the computer run the source code?

There are two ways a computer can run it:

  1. Interpreter
  2. Compiler

An interpreter directly executes instruction code written. Internet browsers use interpreters. For e.g. you can run JavaScript through an interpreter.

A compiler interprets statements written in a programming language and translates them to computer code, often known as processing code. Languages you can compile include C++, C#, Visual Basic (VB), and F#.

How does a compiler work?

The primary function of a compiler is to create an executable program. It translates source code from a high-level programming language  (e.g. Dot NET, C#, Visual Basic, etc.) to a lower-level one.

How do you complile a source code?

First, you run the code using the respective compiler for e.g. in case of C#, you can use Microsoft Visual Studio.

After compilation, it will generate Intermediate Language Code (IL). The IL process is: runtime, compilation, and execution.

Once IL is produced, Common Language Runtime (CLR) takes over. It uses Just-In Time compiling or more commonly known as JIT compiling.

JIT compiling converts the necessary IL code and executes it into commands for the machine.

The commands for the machine are basically the machine instructions. These instructions are then executed on the CPU.

Below is the complete compilation process:


The source code compilation process

Behind the scenes: The complete compilation process of source code


Any source code that you write is translated into machine language for the computer to execute. The manner in which this translation takes place is determined whether you want the programming language is compiled or interpreted.


Leave a Reply

Your email address will not be published. Required fields are marked *