How does the DLR work?

2019-02-06 22:28发布

问题:

.Net 4 will have the a DLR (Dynamic Language Runtime). I know that it will be used for things like Iron Python and Iron Ruby. But is that all it's good for?

How is the DLR useful?

How does the DLR work?

回答1:

It is useful for allowing developers to build a dynamic language more easily, compatibility between a dynamic language and CLR and dynamic languages(built on the DLR) with each other.

The DLR is built on top CLR and as such you will be able to access other .Net libraries. Multiple language support enables you to pick the right language for the right task. The DLR allows developers to more easily create your own dynamic language (which I think is a lot of developers dream)

It works by using Dynamic Code Generation(code generation at run time) Dynamic Type System(Change type at runtime and allow DLR languages to have a common communication platform) Dynamic Method Dispatch(Dynamic dispatching is dynamically being able to change which code executes for a method at runtime).

Basically the DLR dynamically generates code based off the expression tree. The expression tree is a list actions that is being sent to the DLR to compile and run.

I think the DLR is going to be a game changer. After the DLR is released I think you are going to see a bunch of new languages springing up as well as more ports of existing languages.



回答2:

Another interesting use for DLR beyond serving as the "CLR bridge for dynamic languages" is to serve as the "CLR bridge for (potentially) any structured logic sequence representation".

In other words... a "dynamic language" could be a Visio flowchart, an XML document, data stored in a database, etc. DLR provides the tools to map from structured data to executable code. There's overlap here between DLR and WF... curious to see how that's going to play itself out.

If you consider what Oslo does (provide the tools to layer structure to otherwise unstructured "data") you can see where this is all going. Oslo + DLR is probably going to be a Very Big Deal over the next few years.

Naturally, some of us aren't just waiting around for this to happen on it's own. ;-)