Microsoft has released a new Dynamic Language Runtime to support various dynamic languages running on the .Net platform. eWEEK senior editor Darryl K. Taft spoke with Microsoft dynamic language gurus Jim Hugunin and John Lam about the effort.
What can you tell me about the Dynamic Language Runtime and where it came from?
Hugunin: Where this all came from is I joined Microsoft with IronPython, but I joined to make the CLR [Common Language Runtime] a better platform for dynamic languages. In some ways this is what weve been working on for the past two and a half years. The way that we did that is we started by building one real high-quality production implementation of a language, which was IronPython, and getting a lot of users to beat on it and make sure that we could do it well. Now that we have that one quality implementation we started saying, Well, how can we make more languages run well on the platform and make them run even better?
So the idea of the DLR is to support a broad spectrum of languages building on what weve learned already. taking all the things in the CLR… IronPython runs well in the CLR because its got great things inside it, like really excellent GC [garbage collection], JITs [just-in-time compilation], excellent type system that you can work within, debugging, profiling, sandbox security model – great features that make it easy to build a language on top of it.
When we built IronPython we found that there were specific things to a dynamic language that we had to re-implement. So we had to re-implement, for the dynamic parts of Python, we had to build a Python type system on top of it. For the parts of hosting a scripting language, we had to build a hosting API that was a Python hosting API. And for making the dynamic operations run really fast, we had to build custom optimizations to make Python dynamic operations run really fast.
By having this shared type system and these dynamic languages using the same sets of types, you can go back and forth between them. In the long run, things like wiring up event handlers, every language is going to have. But every language is always going to have the things that it does better. And the really cool code that somebody went out and wrote in just one language…if they could all talk to each other, you just get a lot of power as a language developer.
In what ways?
Hugunin: The hosting API is in some ways obvious. Microsoft did this a long time ago with its IActiveScript APIs. And that worked really well. Theres an interesting thing about the IActiveScript APIs, the biggest technical issue, I find with the IActiveScript API was actually the security model. That in order to use those APIs…I can run Python in the browser today with the IActiveScript APIs. The only way I can do it, though, is if I have somebody ship me a version of Python that they guarantee is completely secure. With the DLR plus Silverlight I can now run Python in the browser again on top of the Silverlight engine. And the Python implementation that were shipping is completely security transparent. What that means is all the security is in the Silverlight engine; its in the .Net engine that were running on top of. And the language implementer just has to do all their code generation. And if we generate, and weve done it, but if we generate unverifiable code—essentially code that would lead to things like buffer overruns and horrible security exploits – and when our engine does that we get a nice error message that pops up in the browser saying you generated unverifiable code and tried to run it. And that makes it possible for a lot more languages to start running in this kind of environment, because you can build on the .Net security model.
The fast dispatch is sort of obvious. Everybody said these languages couldnt run fast on top of .Net, and IronPython was showing that they can run fast. But it was a lot of work. It took us a lot of work to get it to run fast. And what we want it to do is both to get it to run even faster and to make it easy for other languages to run in this environment.
John, what has your role been?
Lam: My role since getting here has been bootstrapping our Ruby effort. When I got here nothing had been done yet. Then we started off work in earnest against our Ruby implementation. And its really only been in the last month or so that things have really come together to the state where weve gotten this thing in the form that we could actually demo it outside.
And the cool thing is building Ruby on top of the DLR was so much quicker and cleaner and easier than having to go off and reinventing everything on our own – inventing our own object model, our own dispatch mechanism and the rest of those things. So the experience from Ruby really is to kind of validate the idea of the DLR.
Hugunin: Johns been really pushing on making sure that thats in fact true. Hes been building a wonderful demo for Mix. And its not those four languages; I want to make sure we dont forget that fifth language. The fifth language is C#.
We have a demo of a chess application. And chess is great because its a very compute-intensive kind of thing that really makes static type systems shine in terms of showing the benefits of making code run really fast. So thats a great example of being able to use this chess engine, written in C#, and using it from the client inside of the UI that you can absolutely build out of one of the dynamic languages.