Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the DLR needed in .NET 4.0?

I'v been looking into using DLR for my toy language, and I'm a bit confused. If .NET 4.0 has LINQ Expression trees, Dynamic Objects and the "dynamic" type, then do we really need the DLR anymore? What does the DLR provide that would make my life easier as a language developer

--- Edit ----

Let me explain my question a bit better. The DLR project found on codeplex (dlr.codeplex.com), is there much of a need for that anymore? Are all the features of this DLR project rolled into .NET 4? Or is there something of value left to be found in DLR?

like image 627
Timothy Baldridge Avatar asked Jul 18 '11 23:07

Timothy Baldridge


People also ask

What is DLR in dotnet?

The dynamic language runtime (DLR) is a runtime environment that adds a set of services for dynamic languages to the common language runtime (CLR). The DLR makes it easier to develop dynamic languages to run on the . NET Framework and to add dynamic features to statically typed languages.

What is net dynamic?

ASP.NET Dynamic Data is a Ruby on Rails-inspired web application scaffolding framework from Microsoft, shipped as an extension to ASP.NET, that can be used to build data-driven web applications.


3 Answers

During the development of the DLR we split it into two parts - the inner layer and the outer layer. The inner layer consisted of call site caching, the extended expression trees, and the meta object protocol. All of that was intended to and was added to .NET 4.0.

The outer layer consisted of the hosting APIs, expression tree interpreter, COM interop support, a customizable overload resolver for calling .NET methods, a default binder for most of the DLR operations, and many other various helpers. None of this has shipped w/ the .NET framework but could still be useful to you. When using this on .NET 4.0 it relies upon the DLR APIs shipped w/ .NET 4.0.

The outer layer was also split into two parts - the hosting APIs (Microsoft.Scripting.dll) and everything else (Microsoft.Dynamic.dll). You can target the DLR hosting APIs if you want people to be able to host your language in the same way they host IronPython and IronRuby. And you could either use Microsoft.Dynamic.dll or just pull useful pieces of code from it rather than re-inventing the wheel. In either case if you want the latest version you'll need to check out the IronPython/IronRuby web sites as Microsoft is no longer actively developing the outer layer components.

like image 81
Dino Viehland Avatar answered Oct 14 '22 14:10

Dino Viehland


It doesn't quite answer your question but I was very interested to read Jim Hugunin's message about leaving Microsoft a while ago.

One of the things that he pointed out was that the DLR was the driver behind many of the nice advances we have in .Net 4.0 that you now say are the reason why you might not need the DLR anymore.

Edit: Link to the messsage - http://hugunin.net/microsoft_farewell.html

On the other hand, I think that the DynamicSite system is still something that's quite valuable to have, whilst not necessarily something important to put in the CLR itself.

2nd edit: this is an interesting query really, I've just been looking at the docs on Codeplex. As you state and clarified, the .net 4.0 CLR does implement the kind of things that used to make the DLR special; Reading the DLR overview, I think that basically the idea is that things that are implemented with the DLR have the advantage of getting access to new features more quickly then waiting for a new version of the Framework.

This might be moot as they've not released a new version of the DLR for a while now!

Another possible advantage, but I admit I've not explored this properly, is that the AST in the DLR has more features:

Shared AST (Expression Trees) -- This is one of the core pillars of the DLR. We have extended LINQ Expression Trees to include control flow, assignment, etc. We also ship the sources for all of Expression Trees v1 and v2 (the new stuff for the DLR). Expression Tres are part of lowering the bar for porting languages to .NET, and we use them in the binders and DynamicMetaObject protocols.

like image 30
Russ Clarke Avatar answered Oct 14 '22 14:10

Russ Clarke


As this wiki page (http://en.wikipedia.org/wiki/Dynamic_Language_Runtime) explains, the DLR is used with IronPython and IronRuby, so yes, it is still needed.

It will make your life easier if you can use a more dynamic language for your development.

like image 42
James Black Avatar answered Oct 14 '22 12:10

James Black