Difference Between a Compiler and An Interpreter


« Previous
Next »

Difference Between a Compiler and An Interpreter

Compiler and Interpreter are used to convert a program written in high-level language to machine language; however, they work differently. The key differences between a compiler and an interpreter are as follows:

» Interpreter looks at a source code line-by-line. Compiler looks at the entire source code.
» Interpreter converts a line into machine executable form, executes the line, and proceeds with the next line. Compiler converts the entire source code into object-code and creates the object code. The object code is then executed by the user.
» For a given source code, once it is compiled, the object code is created. This object code can be executed multiple number of times by the user. However, interpreter executes line-by-line, so executing the program using an interpreter means that during each execution, the source code is first interpreted and then executed.
» During execution of an object code, the compiler is not required. However, for interpretation, both interpreter and the source code is required during execution (because source code is interpreted during execution).
» Since interpreter interprets line-by-line, the interpreted code runs slower than the compiled code.





« Previous
Next »