Tuesday, May 29, 2018

compiler

What is a compiler and its need?

A Compiler is a program or set of programs that converts source code written in a high-level language to low-level language (assembly language or machine language). A programming language can have many compilers. For example – GCC C, Turbo C, Quick C etc. are different compilers for C programming language.

Why do we need a compiler?

A Computer understands only binary language and executes instructions coded in binary language. It cannot execute a single instruction given in any other form. Therefore, we must provide instructions to the computer in binary language. Means we must write computer programs entirely in binary language (sequence of 0s and 1s).

But think for a while, how cumbersome programming would have been, if we have to write every program as a sequence of 0s and 1s? It would have been a nightmare to write complex software's. Humans are good at giving instructions in English language, whereas computers can only process binary language.

So, there was a need of a translator that translates the computer instructions given in English language to binary language. Hence, to accomplish the job of a translator compiler was invented. The world’s first compiler was written by Grace Hopper in 1952 for the A-0 programming language.

What do a compiler do?

Apart from translating source code from high level language to low level language, compiler has other responsibilities too. After reading source code written in high level language it performs below operations -

1.Performs a pre-processing of source code. Gather all files required for the source code to compile.

2.Parses the entire source code. Checks for any syntax errors in the source code.

3.Performs a thorough syntax analysis of the source code. To understand the structure and semantic of the source code.

4.Optionally translates the source code in an intermediate code known as object code to enhance the performance.

5.Translates the object code to binary language known as executable code.

Source code and object code

Some popular compilers

LanguageCompilersDeveloped by
BASICFreeBASICFreeBASIC development team
QuickBASICMicrosoft
Visual BasicMicrosoft
CGCC CGNU Project
Borland Turbo CEmbarcadero
Quick CMicrosoft
C++GCCGNU Project
Borland C++Borland
Visual C++Microsoft
C#Visual C#Microsoft
MonoXamarin
JavajavacSun Microsystems (Owned by Oracle)
gcjGNU Project



Instagram



No comments:

Post a Comment