Combining Dynamic Languages and Static Languages

The UK MSDN Flash developer newsletter features an article on the Dynamic Language Runtime by Mark Bloodworth:
Traditionally, there has been tension between dynamic languages and static languages. Each language has its distinct strengths and weaknesses, which means a choice: constrain yourself to one language or face the pain of language interoperability.

The Dynamic Language Runtime (DLR) solves this problem. The Common Language Runtime (CLR) provides a unified platform for statically typed languages. The DLR extends the CLR to provide a unified platform for dynamic languages on the .NET platform. This means that there is a common, unified platform for static and dynamic languages. By having one platform, which means one object world, the pain of language interoperability is history.

In addition to dynamic languages such as IronPython and IronRuby, C# and VB will also, in the 4.0 release of the .NET platform, be able to take advantage of the DLR. In C# this capability is achieved through a new type: dynamic. Declaring a dynamic type in C# 4.0 tells the compiler that method resolution is to be performed at runtime. There’s a DynamicObject abstract class (which implements the IDynamicObject interface) that allows you to create your own dynamic objects in your chosen .NET language. In Visual Basic 10, the latebinder will be updated to recognise objects that implement the IDynamicObject interface, which will allow developers to take full advantage of dynamic languages from VB.

To talk to languages and platforms the DLR uses binders. As you would expect, there’s a binder that allows the DLR to call .NET. Binders are also being built to allow calling Javascript (in Silverlight), Python, Ruby and COM. This model removes the n squared problem of language interoperability and replaces it with a standard, well-defined and well-understood platform.

To find out more about the DLR, the following sessions from PDC2008 are a great place to start.

TL10 Deep Dive: Dynamic Languages in .NET – Jim Hugunin

TL16 The Future of C# - Anders Hejlsberg

To see what you can do with the DLR today, download the latest version of IronPython, which comes with the DLR. Then write some ASP .NET with IronPython or call Python from C#.

To experiment with the dynamic capabilities of C# 4.0, download the CTP of Visual Studio 10 and .NET 4.0. There’s a CTP of IronPython 2.0 for Visual Studio 10 that comes with a Dynamic Programming in C# walkthrough.

Comments

  1. ... But no static compilation of (subsets of) a dynamic language, or new both static and dynamic language? http://paddy3118.blogspot.com/2008/11/smearing-static-vs-dynamic-typing.html

    - Paddy.

    ReplyDelete
  2. For a static *and* dynamic language maybe look at Boo. I don't think the kind of static compilation you are looking for will ever be a part of core Python.

    ReplyDelete
  3. Other alternatives include using partial (static) implementations of Python - which allow you to get faster performance whilst (mainly) retaining Python syntax.

    Options include Shedskin, RPython (PyPy), and Pyrex.

    ReplyDelete

Post a Comment

Popular posts from this blog

Extending Abobe Flash Player and AIR with Python and Ruby

IronPython Tools for Visual Studio CTP3

Further Adventures of the Debugger