On many blog entries around the world, specially from the bloggers from Microsoft, one would find a numerous mention about the Dynamic Language Runtime (also known as the DLR). Specially since many MS bloggers are writing a lot about IronPython, DLR is reflected in their topics. So I was questioning myself a few days ago about the DLR and how is it different from the CLR? Here are my findings.
Dynamic Programming Languages
These behaviors can be emulated by standard runtime like the .NET CLR but, it takes a lot of work to do that. Thus the DLR is born.
Dynamic Language Runtime
First of all let me state that the CLR already has support for dynamic languages, however adding the DLR on top of CLR makes it much more easier to implement a dynamic language and makes communication between multiple dynamic languages a breeze just the way CLR did it for multiple .NET languages. This added layer on top of the existing CLR provides the following services.
Shared Dynamic Type System (I am calling this DTS)
Unlike the CTS where type safety is a crucial requirement the DTS allows us to morph the types at runtime. So we can add methods to the a type or modify it. Also two dynamic languages can talk to each other with same vocabulary.
Dynamic Method Dispatching
Ever heard of C++ virtual function tables? Dynamic dispatching is dynamically being able to change which code executes for a method at runtime. There is also another form of dynamic dispatching which is per instance dynamic method dispatching. For example at runtime we can define what code will execute for the method of a class, which is simple method dispatching. But if we are able to define for an instance of a class which code will execute for the instance of that class type that would be instance based dynamic dispatching.
Dynamic Code Generation
Just like the CLR, the DLR also has a hosting API.
So the DLR makes it a whole lot easier for two dynamic languages to have shared code. The keyword here is sharing. Also the DLR is built on the existing CLR. Microsoft has its DLR source code available at codeplex with IronPython project. IronPython is the first sample DLR language and MS plans to implement DLR in VB.NET 10 and next Jscript.