Compilers and Interpreters are programs that translate a source code (a file that contains the program) to a machine code that can be understood by a processor.
A compiler translates source code as a whole and performs various optimization techniques before mapping it to executable machine code.
But, an interpreter translates source code as needed in runtime - it maps source code to machine code almost immediately.
Role of Compiler • Compilers reads the source code, outputs executable code,
• Translates software written in a higher-level language into instructions that computer can understand.
• It converts the text that a programmer writes into a format the CPU can understand. The process of compilation is relatively complicated.
• It spends a lot of time analyzing and processing the program.
• The executable result is some form of machine-specific binary code,
Role of Interpreter • The interpreter converts the source code line-by-line during RUN Time.
• Interpret completely translates a program written in a high-level language into machine level language.
• Interpreter allows evaluation and modification of the program while it is executing.
• Relatively less time spent for analyzing and processing the program,
• Program execution is relatively slow compared to compiler
Advantages of Compiler • A compiler translates a program in a single run.
• It consumes less time. • CPU utilization is more.
• Both syntactic and semantic errors can be checked concurrently
• It is easily supported by many high-level languages like C, C++, JAVA, etc.
Advantages of Interpreter • An interpreter translates the program line by line,
• The interpreter is smaller in size. It is flexible.
• Error localization is easier.
• The interpreter facilitates the implementation of computer programming language constructs.
Comments
Post a Comment