Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between CLR and DLR in C#?

Tags:

What is the difference between CLR and DLR in C#? are these two concept comparable?

like image 321
masoud ramezani Avatar asked Nov 15 '10 12:11

masoud ramezani


People also ask

What is a CLR in C?

Common Language Runtime (CLR) manages the execution of . NET programs. The just-in-time compiler converts the compiled code into machine instructions. This is what the computer executes. The services provided by CLR include memory management, exception handling, type safety, etc.

What is dlr in computer?

The Dynamic Language Runtime (DLR) from Microsoft runs on top of the Common Language Runtime (CLR) and provides computer language services for dynamic languages. These services include: A dynamic type system, to be shared by all languages using the DLR services.

What is CLR and MSIL?

MSIL is machine-independent code. Now CLR comes into existence. CLR provides the services and runtime environment to the MSIL code. Internally CLR includes the JIT(Just-In-Time) compiler which converts the MSIL code to machine code which further executed by CPU.

What is CLR compiler?

The Common Language Runtime (CLR), the virtual machine component of Microsoft . NET Framework, manages the execution of . NET programs. Just-in-time compilation converts the managed code (compiled intermediate language code) into machine instructions which are then executed on the CPU of the computer.


2 Answers

The Common Language Runtime (CLR) is the core set of services offered by .NET – a type system, JIT, a garbage collector, &c. Those are available to all .NET languages, hence the "Common" part.

The Dynamic Language Runtime (DLR) builds atop of this and offers services for dynamic languages: dynamic types, dynamic method dispatch, code generation, &c. The idea is to make those things uniform and share them among dynamic languages so that they work predictably and similar, just like things on the CLR are across all languages too.

In a way those are comparable, a "normal" language on .NET uses the CLR, a dynamic language should use the DLR, but will use the CLR as well. They are basic sets of functionality that the designers considered to be good when they are common across languages. IronPython and IronRuby were implemented on top of the DLR, as is C# 4's dynamic feature.

like image 190
Joey Avatar answered Nov 15 '22 14:11

Joey


I'll just add a simple diagram to demonstrate the point:

    "*** Runtime & Libraries ***"    │ "*** Languages ***" ┌────────────────────────────────────┤ │ .NET Libraries                     │ │   ┌────────────────────────────────┼──────────────────┐ │   │ Dynamic Language Runtime (DLR) │ C# 4.0 'dynamic' ├────┐ ├───┴────────────────────────────────┼──────────────────┘    │ │ Common Language Runtime (CLR)      │   C# 1.0, 2.0, 3.0    │ └────────────────────────────────────┴───────────────────────┘ 
like image 44
Tomas Petricek Avatar answered Nov 15 '22 15:11

Tomas Petricek