What are the pros and cons of interpreted languages?

跟風遠走 提交于 2020-01-01 01:14:13

问题


I'm now learning Perl. What are the pros and cons of the interpreted languages?


回答1:


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):

  • 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.




回答2:


Pros:

  • Rapid prototyping (no write, compile, execute cycle)
  • Cross-platform (assuming interpreters exist for each platform)

Cons:

  • Performance (won't be as fast as compiled languages)



回答3:


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.




回答4:


Con:

  • The biggest drawback is probably execution speed

Pro:

  • The biggest upside is probably turn-around time i.e. code-test iteration loop



回答5:


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.




回答6:


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.




回答7:


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




回答8:


As java is interpreted language

Pros:

  • 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.


来源:https://stackoverflow.com/questions/1610539/what-are-the-pros-and-cons-of-interpreted-languages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!