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:
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:
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.