Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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)

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:

  • The biggest drawback is probably execution speed

Pro:

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

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:

http://steve-yegge.blogspot.com/2008/05/dynamic-languages-strike-back.html

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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top