The Dynamic Language Runtime (DLR) from Microsoft is an ongoing effort to bring a set of services that run on top of the Common Language Runtime (CLR) and provides language services for several different dynamic languages. These services include:
* A dynamic type system, to be shared by all languages utilizing the DLR services
* Dynamic method dispatch
* Dynamic code generation
* Hosting API
The DLR will be used to implement dynamic languages like Python and Ruby on the .NET Framework. The DLR services are currently used in the development versions of IronRuby, a .NET implementation of the Ruby language, and the upcoming IronPython 2.0.Microsoft plans to use the DLR for the upcoming Visual Basic .NET 10.0 (VBx) and Managed JScript (ECMAScript 3.0).
By having several dynamic language implementations share a common underlying system, it should be easier to let these implementations interact with one another. For example, it should be possible to use libraries from any dynamic language in any other dynamic language. In addition, the hosting API allows interoperability with statically typed CLI languages like C#.
The Dynamic Language Runtime is built on the idea that it is possible to implement language specificities on top of a generic language-agnostic abstract syntax tree, whose nodes correspond to a specific functionality that is common to many dynamic languages. This architecture is backed by the idea that the number of elementary language constructs that would have to be implemented on the generic stack should be inherently limited. The DLR dynamically generates code corresponding to the functionality expressed by these nodes. The compiler for any dynamic language implemented on top of the DLR has to generate DLR abstract trees, and hand it over to the DLR libraries.
The DLR provides dynamically-updated DynamicSite objects that cache the task of binding methods to objects. Since in dynamic languages, the type of an object, as well as the members it contains, can change during a program lifetime, a method invocation must check the method list to see if the invocation is a valid one. DynamicSite objects represent and cache the state of the object and its methods; any update to the object is reflected in the DynamicSite objects as well. DLR routes all method invocations via the DynamicSite objects, which then performs a fast lookup and binding of the method with the actual implementation.