Is C# partially interpreted or really compiled?

后端 未结 13 1129
别跟我提以往
别跟我提以往 2020-12-07 11:51

There is a lot of contradicting information about this. While some say C# is compiled (as it is compiled into IL and then to native code when run), others say it\'s interpre

13条回答
  •  无人及你
    2020-12-07 12:51

    First off let's understand the definitions of interpreted and compiled.

    "Compile" (when referring to code) means to translate code from one language to another. Typically from human readable source code into machine code that the target processer can... process.

    "Interpret" (when referring to code) ALSO means to translate code from one language to another. But this time it's typically used to go from human readable source code into an intermediate code which is taken by a virtual machine which interprets it into machine code.

    Just to be clear
    Source code -> Compiler -> Machine code
    Source code -> Compiler -> Byte Code -> Interpreter -> Machine code

    Any language can, in theory, be interpreted or compiled. Typically Java is compiled into bytecode which is interpreted by the Java virtual machine into machine code. C# is typically interpreted into bytecode which is compiled by the CLR, the common language runtime, another virtual machine.

    By and far the whole thing is a marketing gimmick. The term "interpreted" was added (or at least, increased in usage) to help showcase how neat just-in-time compiling was. But they could have just used "compiled". The distinction is more a study of the English language and business trends rather than anything of a technical nature.

提交回复
热议问题