
Compiler
A compiler is a computer program (or a set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language), with the latter often having a binary form known as object code. The most common reason for converting a source code is to create an executable program.
Interpreter
In computer science, an interpreter is a computer program that directly executes instructions written in a programming or scripting language, without previously compiling them into a machine language program. An interpreter generally uses one of the following strategies for program execution:
- parse the source code and perform its behavior directly.
- translate source code into some efficient intermediate representation and immediately execute this.
- explicitly execute stored precompiled code made by a compiler which is part of the interpreter system.
Compiler vs Interpreter
Whether execute the command is the biggest difference between an interpreter and a compiler. Refer the following chart for more comparisons.
| Field | Compiler | Interpreter |
|---|---|---|
| Input | Entire program | Single instruction |
| Execution | No | Yes |
| Intermediate Object | Yes | No |
| Conditional Statement | faster | slower |
| Memory | More | Less |
| Compile | Not every time | Every time |
| Errors (if any) | After entire program | For every instruction |
| Example | C Compiler | BASIC |




近期评论