PDC 2008: Deep Dive Dynamic Languages in Microsoft .NET
(Presenter: Jim Hugunin)
What they said:
The CLR has great support for dynamic languages like IronPython. Learn how the new Dynamic Language Runtime (DLR) adds a shared dynamic type system, a standard hosting model, and support for generating fast dynamic code. Hear how these features enable languages that use the DLR to share code with other dynamic and static languages like Microsoft Visual Basic .NET and C#.
What I said:
The Dynamic Language Runtime and CLR 4.0 are working to bring static and dynamic languages closer together. Having a common platform allows dynamic languages to get optimization work invested in the CLR for free and simplifies the execution runtime. Key features coming for dynamic languages are improved expression trees, a consistent mechanism for dynamic dispatch (similar to how the CLR unified static dispatch), and caching of optimizations for dynamic invocation. The DLR will be delivered both through CodePlex and future versions of Visual Studio.
C# and VB are increasingly taking advantage of the DLR for binding to environments that don't use statically typed C# objects. Dynamic typing today requires different incantations for interacting with each different environment. In the CLR 4.0, there is an abstraction layer for dynamic dispatch that allows languages to translate type concepts to a common set of CLR/DLR actions. Examples of these actions are member actions (GetMember, InvokeMember, etc.), operator actions (unary, binary, cast), invocation, instantiation, and indexers. An object binder for the execution environment implements the standard set of actions to be performed by the runtime. The introduction of these concepts overlaps Anders Hejlsberg's talk "The Future of C#" and Jim makes frequent references to concepts and demos introduced by Anders. Jim goes deeper than Anders in explaining the IDynamicObject and MetaObject interfaces that are used to implement dynamically typed objects.
Other improvements for dynamic languages are in the areas of expression trees and call-site caching. Expression trees from LINQ have been augmented with assignments, flow control, and dynamic dispatch, allowing expressions to represent the full implementation of a method body. C# and dynamic languages will generate similar expression trees for similar programs, but each language is able to retain its own semantics. Call-site caching is an optimization to generate specialized code when a dynamic type is bound in a particular instance to a statically known type. Future invocations at the call site are able to reuse the optimization by sharing a commonly updated delegate.
The key features being added to support dynamic languages on the .NET platform are improved expression trees, a consistent mechanism for dynamic dispatch, and caching of optimizations for dynamic invocation. Over time, statically typed languages, such as C#, and dynamic languages are growing closer together. These investments in dynamic languages benefit developers using any of the languages on the .NET platform. Sharing this common runtime doesn't require dynamic languages to adopt a common set of semantics or in any way stray from the true intentions of the language. These improvements make the entire platform better and dynamic languages are positioned to take particular advantage of these improvements while retaining their unique character.
Comments
- Anonymous
October 30, 2008
After a flurry of PDC specific posts, back to a mixture. Architecture I wanted to give a big mention