A compiler is a program that converts a program written in a high-level format (Human understandable) to a low-level format (Machine understandable).

High-level format :

#include <stdio.h>
int main(){
    printf("Hello, world!");
    return 0;
}

Low-level format:

01001000100001111100001011
10011001110000101001011001
00110100101010101010001110
00110010101010100101100011
100100

Above, we have seen both high-level and low-level formats of a program to print “Hello world!”. The low-level format program is known as Binary language. The high-level format program is a C program.

Why Compiler?

Computers are only capable to execute binary instructions. But for humans, it is very difficult to write a program in binary format. So high-level programming languages like C, Java e.t.c. were introduced to write a program in a human-understandable format. Later by using a compiler, we can convert it to binary format.

Every programming language follows its own set of syntactic rules. As a programmer, we should be aware of those rules before writing a program. Even though you are a good programmer, you may do some mistakes. These mistakes will be reported as syntax errors by the compiler during the translation process or compilation process.

Categorized in:

Tagged in: