Search code examples
formal-languages

What characteristic of the language grammar defines that it will be interpreted or compiled?


Is there any element or characteristic on the language grammar that defines that it will be interpreted or compiled? Or it will only depends on the implementation of the compiler/interpreter to process that language?


Solution

  • You tagged this question which should give you a hint: a formal language is a mathematical abstraction whereas interpreters and compilers are depressingly concrete.

    So it is more or less like asking the relationship between the Peano axioms and currency. Nothing in the formal model of a number tells you whether it makes cents, so to speak.

    On a practical level, if a language has anything like an eval primitive, you can be reasonably assured that it includes an interpreter, but of course the interpreter might consist of compiling the code to be evaluated and then running the resulting code. Unlike formal mathematical models, the real world is full of leaky abstractions.