An interpreter is a program that translates source code written in high-level language to machine code. It is similar to compiler and does the same task of translation from high-level to low-level language. Despite of its similarity, the working mechanism of interpreter and compiler are different.
An interpreter does not translate whole code at once like compiler. Rather, is reads entire source code at once. Translates single instruction to machine code or some intermediate code. Then executes the translated machine code instruction immediately and translates next instruction if needed.
The first and vital need of an interpreter is to translate source code from high-level language to machine language. However, for the purpose there exists another program called compiler. The compiler also translates source code from high-level language to machine language. So, why we need an interpreter when there exists a similar software compiler.
The real need of interpreter comes where compiler fails to satisfy the software development needs. The compiler is a very powerful tool for developing programs in high-level language. However, there are several demerits associated with the compiler. If the source code is huge in size, then it might take hours to compile the source code. Which will significantly increase the compilation duration. Here interpreter comes handy and can cut this huge compilation duration. Interpreters are designed to translate single instruction at a time and execute them immediately.
The real need of interpreter comes where compiler fails to satisfy the software development needs. The compiler is a very powerful tool for developing programs in high-level language. However, there are several demerits associated with the compiler. If the source code is huge in size, then it might take hours to compile the source code. Which will significantly increase the compilation duration. Here interpreter comes handy and can cut this huge compilation duration. Interpreters are designed to translate single instruction at a time and execute them immediately.
An interpreter also comes handy when you frequently update the source code. As if it takes 5 minutes to compile entire source code. If you have updated it 5 times. Then the total compile time would be 25 minutes which is significantly big. However, if we use an interpreter we can reduce this compile time.
0 Comments: