javac++cinterpreter

C/C++/Java interpreter


Why has no one ever made a C/C++/Java interpreter which requires no compilation to run? It can't be that hard to make something akin to IDLE for Python.

The same goes for other languages such as FORTRAN, Pascal and others. Is there some kind of code based reason for this or is it just that people prefer to compile their code.


Solution

  • C and C++ are languages designed to be compiled and generate fast and efficient code.

    Interpreters, by the definition that they "interpret" the code, are generally slow (or at least slower than the same compiled language, assuming a good compiler).

    However, there are combinations of clang and llvm-jit that could be (and has been) built into an "interpreted version of C or C++". I think there are some limitations, and I've never actually used it.

    There is no great technical reason NOT to do this, it's just that it's about the same amount of work, if not more than, the work to write a compiler, and the end result of writing a compiler is "better".