解释器/编译器如何工作 [英] How does an interpreter/compiler work
问题描述
解释器/编译器如何工作?
编译器 / p>编译器是要编写的第一个
转换程序。
的想法很简单:你编写程序,
然后交给编译器,
翻译它。然后运行
结果。
解释器
也是一个程序,
将高级语言翻译成
a低级语言,但它在
时刻运行程序。你使用文本编辑器编写
程序,或者使用
类似的程序,然后指示
解释器来运行程序。它
采用程序,一次一行,
并翻译每行前
运行它:它翻译第一个
行并运行它,然后翻译
第二行并运行它等。
编译程序特性:
- 花费大量时间分析和
处理程序 - 生成的可执行文件是某种形式的
机器特定的二进制代码 - 计算机硬件解释
(执行)结果代码 - 程序执行速度快
解释器特性:
- 花费相对较少的时间
分析和处理程序 - 生成的代码是某种类型的
中间代码 - 生成的代码由
另一个程序解释 - 程序执行相对较慢
How does an interpreter/compiler work? What is the difference between interpreter and compiler.
Compilers
Compilers were the first sort of translator program to be written. The idea is simple: You write the program, then hand it to the compiler which translates it. Then you run the result.
Interpreters
An interpreter is also a program that translates a high-level language into a low-level one, but it does it at the moment the program is run. You write the program using a text editor or something similar, and then instruct the interpreter to run the program. It takes the program, one line at a time, and translates each line before running it: It translates the first line and runs it, then translates the second line and runs it etc.
Compiler characteristics:
- spends a lot of time analyzing and processing the program
- the resulting executable is some form of machine- specific binary code
- the computer hardware interprets (executes) the resulting code
- program execution is fast
Interpreter characteristics:
- relatively little time is spent analyzing and processing the program
- the resulting code is some sort of intermediate code
- the resulting code is interpreted by another program
- program execution is relatively slow
这篇关于解释器/编译器如何工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!