📜  编译器和解释器的区别

📅  最后修改于: 2021-09-28 09:49:15             🧑  作者: Mango

1.编译器
它是一个翻译器,它接受输入即高级语言,并产生低级语言即机器或汇编语言的输出。

  • 编译器比汇编器更智能,它会检查各种限制、范围、错误等。
  • 但其程序运行时间较多,占用内存较大。它的速度很慢,因为编译器会遍历整个程序,然后将整个程序翻译成机器码。

图 –编译器进程

2.翻译
解释器是将编程语言翻译成可理解语言的程序。 ——

  • 它一次只翻译一个程序语句。
  • 解释器通常比编译器小。

图 – Interpreter-Process

让我们看看编译器和解释器之间的区别:

S.No. Compiler Interpreter
1. Compiler scans the whole program in one go. Translates program one statement at a time.
2. As it scans the code in one go, the errors (if any) are shown at the end together. Considering it scans code one line at a time, errors are shown line by line.
3. Main advantage of compilers is it’s execution time. Due to interpreters being slow in executing the object code, it is preferred less.
4. It converts the source code into object code. It does not convert source code into object code instead it scans it line by line
5 It does not require source code for later execution. It requires source code for later execution.
Eg. C, C++, C# etc. Python, Ruby, Perl, SNOBOL, MATLAB, etc.