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):
platform independence (Java's byte code, for example)
reflection and reflective usage of the evaluator (e.g. a first-order eval function)
dynamic typing
ease of debugging (it is easier to get source code information in interpreted languages)
small program size (since interpreted languages have flexibility to choose instruction code)
dynamic scoping
automatic memory management
Disadvantages of interpreted languages
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.
Biggest drawback? Most would say execution speed, but isn't always necessarily true. Most modern interpreted languages these days convert the files to be interpreted into an intermediate state upon building, which when executed is turned into machine code just as any other language. With clever caching being mostly prevalent within these language VMs these days, it shouldn't be too much of an issue. This is certainly not to say that performance is not an issue with interpreted languages, just that it is often not as bad as most would suggest.
Keep in mind that even with the performance problems though, it is often easier to achieve the same tasks as a compiled language in less and more efficient code, making the performance loss during compilation negligible over the execution time of a program.
Personally for me, the biggest drawback is the need for the interpreter to always be present before execution can occur. This quite often reduces portability, especially because interpreted languages aren't always cross platform.
To put for the obvious and broad point, compiled languages tend to have higher performance than interpreted ones, since compiling precludes the need for a runtime interpreter.
Compiled languages are more suitable for commercial desktop software, since the source code is not shipped along with it.
Interpreted languages tend to be a bit quicker to learn, insofar as they allow you to quickly edit/run/repeat without waiting on a compiler. In my experience they also tend to be higher-level, which makes them easier as well.
Wikipedia has a page on the advantages and disadvantages. Any significantly advanced interpreted language can be actual compiled into a native binary thus blurring the lines between the pro's and cons of an interpreted language.
PERL is one of those languages which blurs the lines. Whilst its famous for being a powerful scripting language, you could compile it to be native.
The "slowness" of Dynamic Languages such as PERL may not be an issue any longer. Here is an excellent presentation on the latest trends in the Dynamic Language area:
Compatibility: Java virtual machine approves this concept "Write once, run everywhere."
Security: The program running in JVM so if any failure happens this not affects on operating systems files.
Memory management.
Cons:
Java virtual machine has many implementations, for example when writing a program that uses Java 8 features this program must run on JVM with 8 version not less.
发布评论
评论(9)
公然复制维基百科,所以我将制作这个社区维基。
解释型语言的优点
与编译型语言相比,解释型语言为程序提供了一定的额外灵活性。在解释器中比在编译器中更容易实现的功能包括(但不限于):
解释性语言的缺点
由解释器执行通常比常规程序执行效率低得多。发生这种情况是因为要么每条指令都应该在运行时传递解释,要么在较新的实现中,代码必须在每次执行之前编译为中间表示。虚拟机是性能问题的部分解决方案,因为定义的中间语言更接近机器语言,因此更容易在运行时进行翻译。另一个缺点是需要本地机器上的解释器才能执行。
Blatant copy from wikipedia so I'll make this community wiki.
Advantages of interpreted languages
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):
Disadvantages of interpreted languages
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.
优点:
缺点:
Pros:
Cons:
最大的缺点?大多数人会说执行速度,但并不总是如此。如今,大多数现代解释语言都会在构建时将要解释的文件转换为中间状态,执行时会像任何其他语言一样转换为机器代码。如今,巧妙的缓存在这些语言虚拟机中非常普遍,因此这不应该是一个太大的问题。这当然并不是说性能不是解释性语言的问题,只是它通常并不像大多数人认为的那么糟糕。
请记住,即使存在性能问题,通常也更容易以更少但更高效的代码实现与编译语言相同的任务,从而使得编译期间的性能损失在程序的执行时间内可以忽略不计。
就我个人而言,最大的缺点是在执行之前需要解释器始终存在。这通常会降低可移植性,特别是因为解释语言并不总是跨平台的。
Biggest drawback? Most would say execution speed, but isn't always necessarily true. Most modern interpreted languages these days convert the files to be interpreted into an intermediate state upon building, which when executed is turned into machine code just as any other language. With clever caching being mostly prevalent within these language VMs these days, it shouldn't be too much of an issue. This is certainly not to say that performance is not an issue with interpreted languages, just that it is often not as bad as most would suggest.
Keep in mind that even with the performance problems though, it is often easier to achieve the same tasks as a compiled language in less and more efficient code, making the performance loss during compilation negligible over the execution time of a program.
Personally for me, the biggest drawback is the need for the interpreter to always be present before execution can occur. This quite often reduces portability, especially because interpreted languages aren't always cross platform.
缺点:
优点:
Con:
Pro:
显而易见的是,编译语言往往比解释语言具有更高的性能,因为编译不需要运行时解释器。
编译语言更适合商业桌面软件,因为源代码不随其一起提供。
解释型语言往往学习起来更快一些,因为它们允许您快速编辑/运行/重复而无需等待编译器。根据我的经验,它们也往往是更高级别的,这也使它们变得更容易。
To put for the obvious and broad point, compiled languages tend to have higher performance than interpreted ones, since compiling precludes the need for a runtime interpreter.
Compiled languages are more suitable for commercial desktop software, since the source code is not shipped along with it.
Interpreted languages tend to be a bit quicker to learn, insofar as they allow you to quickly edit/run/repeat without waiting on a compiler. In my experience they also tend to be higher-level, which makes them easier as well.
维基百科有一个关于优点和缺点的页面。任何非常先进的解释语言都可以实际编译为本机二进制文件,从而模糊了解释语言的优缺点之间的界限。
PERL 是那些模糊界限的语言之一。虽然它以强大的脚本语言而闻名,但您可以将其编译为本机语言。
Wikipedia has a page on the advantages and disadvantages. Any significantly advanced interpreted language can be actual compiled into a native binary thus blurring the lines between the pro's and cons of an interpreted language.
PERL is one of those languages which blurs the lines. Whilst its famous for being a powerful scripting language, you could compile it to be native.
PERL 等动态语言的“缓慢”可能不再是问题。以下是关于动态语言领域最新趋势的精彩演示:
http://steve-yegge.blogspot.com/2008/05/dynamic-languages-strike-back.html
The "slowness" of Dynamic Languages such as PERL may not be an issue any longer. Here is an excellent presentation on the latest trends in the Dynamic Language area:
http://steve-yegge.blogspot.com/2008/05/dynamic-languages-strike-back.html
由于java是解释性语言
优点:
缺点:
As java is interpreted language
Pros:
Cons:
解释型语言的显着优点是不必为每个硬件目标单独编译。
缺点是会使代码执行速度变慢。
The significant benefit of an interpreted language is that it does not have to be compiled for each hardware target separately.
The disadvantage is that it makes the code execution slower.