What's the difference between compiled and interpreted language?

前端 未结 7 1421
Happy的楠姐
Happy的楠姐 2020-12-02 03:46

After reading some material on this subject I\'m still not sure what the difference between a compiled language and an interpreted language is. I was told this is one of the

7条回答
  •  被撕碎了的回忆
    2020-12-02 04:17

    Java and JavaScript are a fairly bad example to demonstrate this difference, because both are interpreted languages. Java (interpreted) and C (or C++) (compiled) might have been a better example.

    Why the striked-through text? As this answer correctly points out, interpreted/compiled is about a concrete implementation of a language, not about the language per se. While statements like "C is a compiled language" are generally true, there's nothing to stop someone from writing a C language interpreter. In fact, interpreters for C do exist.

    Basically, compiled code can be executed directly by the computer's CPU. That is, the executable code is specified in the CPU's "native" language (assembly language).

    The code of interpreted languages however must be translated at run-time from any format to CPU machine instructions. This translation is done by an interpreter.

    Another way of putting it is that interpreted languages are code is translated to machine instructions step-by-step while the program is being executed, while compiled languages have code has been translated before program execution.

提交回复
热议问题