1

I have a question. I actually know the difference between compiling and interpreting languages. But, What I do not really understand is , how can any programming language be both compiling and interpreting ? Thank you.

  • 1
    It can be that the language follows different phases(talking about Java here specifically) : it is both a interpreting language, and also a compiling language. javac compiles source code into java byte code; and the JIT compiler compiles the bytecodes of that method into native machine code.[Check this answer for more detail](http://stackoverflow.com/a/14708631/3482140) – Am_I_Helpful Nov 15 '15 at 12:21
  • 1
    A programming language is neither compiling nor interpreting. Only an implementation is, and one language can have multiple different implementations. – SK-logic Nov 18 '15 at 20:50

2 Answers2

2

If an interpreting language is one for which an interpreter exists and a compiling language is one for which a compiler exists, then a language can be both if someone wrote an interpreter for it and someone else (or the same person/team) wrote a compiler for it.

sepp2k
  • 363,768
  • 54
  • 674
  • 675
2

One possible way to "interpret" a program fragment is to compile it and then invoke the compiled code. Using this procedure would allow you to implement any behavioural aspect of an interpreter, such as a REPL, or the eval function itself.

rici
  • 234,347
  • 28
  • 237
  • 341