what is compiler and explain it?
Answers
Compiles parse the given program. Check it for grammatical errors. This is called parsing. Then if there are no errors, the program statements are converted into equivalent target language statements.
Compilers are necessary because computers do not understand higher level languages. Programmers cannot write huge and complicated programs in machine level languages. But computers understand only machine level instructions.
The output of a compiler can be executed directly by the user.
Compiler
A complier is a computer program which converts the High level programming language to Low level programming language or Machine language. The codes written in the High level programming language in a computer are turned into the Machine level programming language by complier. A computer system cannot understand the high programming language, Hence it is necessary to convert the programming language to Low level programming or Machine level language.
A computer system can only understand the Machine level language and Binary codes. This language is in the form of Binary codes in the form of "0,1". A computer can understand only the language of binary code.
When a programmer simply writes a code or program in the text editor by using programming languages like C and Python. This files containing the code are called as "Source statement". When the code has to be executed, The compiler parses the High level programme to the low level programme, This process is also called as Parsing.
Each and every line passes through the complier and after the execution of all lines, The output code is created in the form of Binary code. This output of the object is also called as 'Object module'. This object code is nothing but the Machine code that processor can process and execute it.
Later, The processed code is sent to the output unit. And this is how the code is executed and output is shown.
Programming languages like Java, C and C++ uses object oriented language. This helps the complier to perform it's work with the help of bytecode in bits of seconds. Rather than it, some programming languages are very high level programming languages which don't use Object Oriented Programming language. This programming languages require more time to get executed. Examples of this programming languages can be given as Python and JavaScript.
Additionally, In some Operating systems like Mac and Linux, one more step is to be done before executing the code which is to "resolve the instructions locations and data" for executing the more code at same time.
A complier contains 2 main parts. 3GL and Assembler. 3GL works with the complier and High level programming languages. And Assembler works on the code written using assembler language by processor.