IronPython is a dynamic language, yet the Common Language Runtime (CLR) is a static environment. While you can build a compiler that makes it possible to use a dynamic language with CLR, as was done for IronPython 1.0, you’ll find that certain functionality is missing because CLR simply doesn’t understand dynamic languages. Consequently, Microsoft started the Dynamic Language Runtime (DLR) project (see http://dlr.codeplex.com/ for additional information). DLR sits on top of CLR and performs a level of interpretation that offers additional functionality for dynamic languages. By relying on DLR, IronPython gains access to the following support:
- Shared dynamic type support
- Shared hosted model
- Quick dynamic code generation
- Interaction with other dynamic languages
- Improved interaction with static languages such as C# and Visual Basic.NET
- Shared sandbox security model and browse integration
DLR is now part of the .NET Framework 4.0. Consequently, you can begin accessing these features immediately when using Visual Studio 2010 without having to install any additional support. Microsoft currently supports these languages using DLR:
- Visual Basic
Silverlight also provides support for DLR and there’s even a special SDK for Silverlight DLR. You can discover more about this SDK at http://silverlight.net/learn/dynamic-languages/.
- Makes it easier to port dynamic languages to the .NET Framework
- Lets you include dynamic features in static languages
- Creates an environment where sharing of objects and libraries between languages is possible
- Makes it possible to perform fast dynamic dispatch and invocation of objects
This section provides a good overview of DLR. You’ll discover additional details about DLR as the book progresses. However, if you’d like to delve into some of the architectural details of DLR, check out the article at http://msdn.microsoft.com/library/dd233052.aspx.