What is Compiler and Interpreter

Programming languages are notations for describing computation to people and to Machines. The world Know it depends on Programming languages because all the Software running on all the computers was written in some Programming language,
But before a program can be run, it first must be translated into a form in which it can be executed by a computer. The Software systems that do this translation are called Compiler.

What is Compiler:

Most programmers write software in a high-level language, such as Pascal, C, C++, Java, Cobol and others.
Many are not aware of the fact that they are really making use of a sophisticated program called a compiler that bridges the gap between their chosen language and a computer architecture.
Some have no concept at all, or a very poor grasp of the computer’s instruction set, memory organisation, and other details that make their software work.
A compiler, therefore, provides a valuable form of information hiding. Most programmers don’t need to know anything about the details of translation and execution, only the properties claimed to be supported by the high-level language and its libraries.
A professional computer engineer cannot afford to be ignorant of the details. Compilers are a valuable and reliable tool for the most part, but no software is perfect.
If a bug arises in code, it’s sometimes useful to be able to trace it down into the assembler/microinstruction level.
High performance may require certain low-level operations. Finally, knowing something about the strategy used by a compiler helps the engineer understand the high-level language at a deeper level.
A compiler is a program that can read a program in one language—–the source language—-and translate it into an equivalent Program in another language— The target language. An important role of the compiler is to report any errors in the source Program that it detects during the translation process .” 


I use the word translation in roughly the same sense as a person learns to translate from English to (say) German. Knowing the German equivalent of lots of English words is an important first step, and this may be the most difficult step for a person to take.
However, there’s more. Good German requires paying attention to gender in all nouns. A chair, a pencil, or an automobile in the Romance languages is either masculine, feminine, or neutral.
The gender determines just how adjectives and verbs may be applied to the nouns. Also, the ordering in a German sentence is different than English.
Germans love to place the verb at the end of the sentence, whereas in English, it’s between the subject and the predicate.
In order to design and implement a useful compiler, one must be reasonably expert in all these disciplines:
• The source language (what language we’re trying to translate, i.e. Pascal),
• The host language (what programming language we’re using to write the translator, i.e. C++),
• The host metalanguages (special little languages that describe tokens or language structure),
• The target language (what we’re translating into, i.e. Microsoft symbolic assembler), and
• The target machine (what CPU will finally execute our program).
• Compiler tools, the algorithms and data structures that are commonly used to design a compiler.

Interpreter :

An interpreter is another common kind of languages processor. Instead of producing a target program as a translation, an interpreter appears to Directly execute the operations specified in the source program on input supplied by the user.



Language Processors:

The Machine language target program produced by a compiler is usually much faster than an interpreter at mapping inputs to outputs. An interpreter gives better error diagnostic than a compiler because it executes the source program statement.
In the compiler, several other programs may be required to create an excusable target program. See in Fig.


A source Program may be divided into modules stored in separate files. The task of collecting the source Program is sometimes entrusted to a separate Programs, called a pre-processor.
The compiler may produce an assembly language program as its output because assembly language is easier to produce an output and as its easier to debug.
The assembly language is then Processed by a program called an assembler that produces relocatable machine code as its output.
Large programs are often compiled in pieces so the relocatable machine code may have to be linked together with other relocatable object files and library files into the code that actually runs on the machine.
The linker resolves external memory address, files were the code in a file may refer to a location in another file, then the loader puts it all together executable files into memory for execution
Read Here: Structure of a Compiler
I hope this will surely help you. If you have any questions or problem let me know.
Have some suggestion about this post comment below



Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.