WHERE C STANDS
Let us now see how C compares with other programming languages. All the programming languages can be divided into two categories:
These languages have been designed to give a better programming efficiency, i.e., faster program development. Examples of language falling in this category are FORTRAN, BASIC, and PASCAL…………..
These languages have been designed to give a better machine efficiency, i.e., faster program execution. Examples of languages falling in this category are Assembly language and Machine language.
C stands between these two categories. That’s why it is often called a Middle level language, since it was designed to have both: a relatively good programming efficiency (as compared to Machine oriented languages) and relatively good machine efficiency (as compared to Problem oriented languages).
C IS A MIDDLE-LEVEL LANGUAGE
C is often called a middle level computer language. This does not mean that C is less powerful, harder to use, or less developed than a high-level language such as BASIC. Or Pascal, nor does it imply that C has the cumbersome nature of assembly language. Rather, C is thought of as middle – level language because it combines the best elements of high level languages with the control and flexibility of assembly languages.
As middle – level language, C allows the manipulation of bits, bytes and addresses. Despite this fact, C code is also very portable. Portability means that it is easy to adapt software written for one type of computer or operation system to another type.
High Level Languages are: Ada, Modula-2, Pascal, COBOL, FORTRAN, and BASIC
Middle Level Languages are: Java, C, C++, Forth, and Macro-assembler
Low Level Languages are: Assembler.
Computers can understand only machine language instructions. Therefore, the program written in any other language should be translated into machine language.
There are two types of translators.
Difference between Compiler and Interpreter
A compiler checks the entire program at a time and if it is error free then it produces the machine language instruction.
The interpreter translates one statement at a time and if it is error free it produces the machine language instruction. Executing a program written in a high level language is a two step process.
The code (source program) should be compiled (i.e., by either compiler or interpreter) to produce machine language instructions.
Then the machine instructions are loaded into memory and it gets executed.
COMPILERS vs. INTERPRETERS
It is important to understand that a computer language defines the nature of a program and not the way that the program will be executed. There are two general methods by which a program can be executed. It can be compiled, or it can be interpreted. Although programs written in any computer language can be compiled or interpreted, some languages are designed more for one form or execution than the other. For example, Java was designed to be interpreted, and C was designed to be compiled. However, in the case of C, it is important to understand that it was specifically optimized as a compiled language.
In its simplest form, an interpreter reads the source code of your program one line at a time, performing the specific instructions contained in that line. This is the way earlier version of BASIC worked. In languages such as Java, a program’s source code is first converted into an intermediary form that is then interpreted. In either case, a run-time interpreter is still required to be present to execute the program.
A compiler reads the entire program and converts it into object code, which is a translation of the program’s source code into a form that the computer can execute directly. Object code is also referred to as binary code or machine code. Once the program is compiled, a line of source code is no longer meaningful in the execution of your program.
In general, an interpreted program runs, slower than a compiled program. Hence a compiler converts a program’s source code into object code that a computer can execute directly. Therefore, compilation is a one time cost, while interpretation incurs an overhead each time a program is run.