问题描述
我现在正在学习 Perl.解释型语言的优缺点是什么?
I'm now learning Perl. What are the pros and cons of the interpreted languages?
推荐答案
公然抄袭维基百科 所以我会制作这个社区维基.
Blatant copy from wikipedia so I'll make this community wiki.
解释型语言的优势
解释型语言为程序提供了比编译型语言更大的灵活性.在解释器中比在编译器中更容易实现的功能包括(但不限于):
Interpreted languages give programs certain extra flexibility over compiled languages. Features that are easier to implement in interpreters than in compilers include (but are not limited to):
- 平台独立性(例如 Java 的字节码)
- 评估器的反射和反射使用(例如一阶 eval 函数)
- 动态输入
- 易于调试(更容易获得解释性语言的源代码信息)
- 小程序(因为解释型语言可以灵活选择指令代码)
- 动态范围
- 自动内存管理
解释型语言的缺点
解释器的执行通常比常规程序执行效率低得多.发生这种情况是因为每条指令都应该在运行时传递解释,或者在较新的实现中,代码必须在每次执行之前编译为中间表示.虚拟机是性能问题的部分解决方案,因为定义的中间语言更接近机器语言,因此更容易在运行时进行翻译.另一个缺点是需要本地机器上的解释器才能执行.
An execution by an interpreter is usually much less efficient than regular program execution. It happens because either every instruction should pass an interpretation at runtime or as in newer implementations, the code has to be compiled to an intermediate representation before every execution. The virtual machine is a partial solution to the performance issue as the defined intermediate-language is much closer to machine language and thus easier to be translated at run-time. Another disadvantage is the need for an interpreter on the local machine to make the execution possible.
这篇关于解释型语言的优缺点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!