Is C # an interpreted language?

Sergio23 271 Reputation points
2021-08-24T06:24:37.307+00:00

C # is an interpreted language, therefore slower than C or C ++.
Why use C Sharp?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,962 questions
{count} votes

Accepted answer
  1. Sam of Simple Samples 5,546 Reputation points
    2021-08-24T18:31:59.893+00:00

    In the context of computer languages, there is no official (or standard) definition of compile, translate and interpret.

    Like Java, C# provides binary portability. See Slashdot | Interviews | C++ Answers From Bjarne Stroustrup (I assume you know who Bjarne Stroustrup is). In that he says:

    The technical hardest problem is probably the lack of a C++ binary interface (ABI).

    C and C++ do not have a binary interface, therefore they do not provide binary portability.

    As has been said, C# is compiled into IL (providing binary portability) then during execution the IL is compiled into machine code. Since it becomes machine language during execution, it is usually as efficient as C++.

    Note that C++ is not used for websites, I assume due to the security risk of the machine language.

    1 person found this answer helpful.

5 additional answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 65,576 Reputation points
    2022-09-21T20:42:58.13+00:00

    C# is not a direct interpreter, because it compiles to bytecode (IL code), which is executed by the dotnet binary runtime (virtual machine). this is a two step process. create the output il code. then use a "runtime" program to execute it.

    an interpreter (say javascript) converts the source to abstract syntax tree and directly executes the tree.

    both technologies can use a JIT compiler for performance.

    C/C++ compiles to a native machine code, but this not the main difference (as C# can be compiled to native machine code). the main difference is in memory management:

    • C/C++ uses a heap and the developer is responsible for the code to allocate and free heap storage.
    • C# uses implicit memory allocation via new operator and free via internal reference counting and the GC
    • C/C++ also allows direct memory access via pointers.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.