Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What features of interpreted languages can a compiled one not have?

Interpreted languages are usually more high-level and therefore have features as dynamic typing (including creating new variables dynamically without declaration), the infamous eval and many many other features that make a programmer's life easier - but why can't compiled languages have these as well?

I don't mean languages like Java that run on a VM, but those that compile to binary like C(++).

I'm not going to make a list now but if you are going to ask which features I mean, please look into what PHP, Python, Ruby etc. have to offer.

  • Which common features of interpreted languages can't/don't/do exist in compiled languages? Why?
like image 754
sub Avatar asked Mar 25 '10 15:03

sub


People also ask

How is an interpreted programming language different from a compiled one?

In a compiled language, the target machine directly translates the program. In an interpreted language, the source code is not directly translated by the target machine. Instead, a different program, aka the interpreter, reads and executes the code.

Is interpreted language not a compiled?

Interpreted languages differ from compiled languages; for example, interpreted code, such as shell code, is compiled on the fly each time the program is run. Bytecode, such as Java bytecode, is also interpreted code.

Can interpreted languages be compiled?

Also, most interpreted languages are "compiled" into byte-code before execution. Byte-code interpreters can be very efficient and rival some compiler generated code from an execution speed point of view.

What is an advantage and disadvantage of interpreted languages?

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.


1 Answers

Whether source code is compiled - to native binaries, some kind of intermediate language (Java Bytecode/IL) - or interpreted is absolutely no trait of the language. It's just a question of the implementation.

You can actually have both compilers and interpreters for the same language like

  • Haskell: GHC <-> GHCI
  • C: gcc <-> ch
  • VB6: VS IDE <-> VB6 compiler

Certain language features like eval or dynamic typing may suggest a distinction between so called "dynamic languages" and static ones, but how this is run can never be the primary question.

like image 95
Dario Avatar answered Sep 29 '22 19:09

Dario