解释器
一句话解释
解释器是 program 那个读取 and 执行源 code directly, 行通过行, at 运行时.
用大白话说
An interpreter reads your source code and executes it directly, one statement at a time, without producing a separate machine code file. The interpretation happens while the program is running.
The advantage is flexibility: you can run code immediately without a compilation step, test snippets interactively, and modify code without rebuilding. This makes development faster and more interactive. The disadvantage is speed — interpreting code at runtime is slower than running pre-compiled machine code.
Interpreted languages include Python, JavaScript, Ruby, and PHP. Many modern languages use a hybrid approach: JavaScript is interpreted (or JIT-compiled), Python compiles to bytecode which is then interpreted, and Java compiles to bytecode which is JIT-compiled.
示例
# Run a Python script directly (interpreted)
$ python program.py
Hello, World!
# No compilation step needed —
# the interpreter reads and executes immediatelyPython 读取 program.py and 执行每个行 directly. 否 separate compilation 步骤是 需要.
常见混淆
容易混淆的对象: 编译器
关键区别: 解释器执行 code 行-通过-行 at 运行时 (否 separate 构建步骤); 编译器 translates 所有 code 到 machine code 之前 execution (faster 但需要 compilation).
相关术语
相关资源
相关课程
- 如何 Programs 工作
学习关于编译器 and 解释器.
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。