Marc Andreson
Marc Andreson

Reputation: 3495

Is .NET VM a compiler or an interpreter?

Does the .NET's Virtual Machine compiles the CIL bytecode (and then execute the code at the lowest level - CPU assembler), or it is an interpreter (that reads the following instructions and execute them) ?

Upvotes: 7

Views: 5845

Answers (2)

Yousha Aleayoub
Yousha Aleayoub

Reputation: 5618

Is .NET VM a compiler or an interpreter?

There isn't any VM in .Net ecosystem like Java ecosystem, but which .Net? .Net SDK, .Net Runtime, or .Net Framework?

.Net Framework components:

  • Common Language Runtime (CLR)
  • FCL (Framework Class Library)
  • Common Type System (CTS)
  • Common Language Specification (CLS)
  • Garbage collector
  • Just-in-time compiler (JIT)
  • Language compilers
  • Libraries

And you can't see any VM here...

.Net Runtime components:

  • Common Type System (CTS)
  • Garbage collector
  • Just-in-time compiler (JIT)
  • Common Language Specification (CLS)
  • Assemblies

Still you can't see any VM here...

.Net Runtime CONTAINS a Just-in-time(JIT) compiler while .Net SDK CONTAINS both JIT and IL compilers.
So they are NOT a VM while both CONTAIN compiler.

So IMO, you could say that IL + CLR + JIT together are MAYBE a virtual machine.

Is .NET VM a compiler or an interpreter?

Neither.

Upvotes: -1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

Does the .NET's Virtual Machine compiles the CIL bytecode (and then execute the code at the lowest level - CPU assembler)

Yes, it's a component of the CLR called JIT (Just-In-Time compilation) that converts the Intermediary Language code (emitted by the compiler of the programming language) into a machine code.

There's no interpreter as there is in the dynamic languages such as Ruby, PHP, Python.


UPDATE:

As pointed out in the comments by @Nick Craver since the addition of the DLR in .Net 4 brings the possibility of using dynamic language concepts in the CLR.

Upvotes: 8

Related Questions