I’m pleased to announce the release of the IronRuby and IronPython CTPs for .NET 4.0 Beta 2. This is the third preview of IronRuby and IronPython running under the Dynamic Language Runtime that is built directly into .NET 4.0. As before, this release allows you to use IronRuby objects and types as .NET 4.0 dynamic objects from within C# and Visual Basic code. These binaries are roughly equivalent to the functionality found in IronRuby 0.9 and IronPython 2.6 RC. Take a look at Harry Pierson’s blogpost about this release as well, especially if you’re more into snakes than gemstones.
Here's a small example showing just how powerful the new dynamic feature is for taking advantage of dynamic language functionality in statically typed languages:
Here is the IronPython version as well. It basically loads up the desired scripting engine (in this case, Ruby), loads a script, instantiates the “Mock” class defined in the script, and calls a method on an instance of “Mock” which the C# compiler cannot possibly know of; the Mock class dynamically responds to any method call with a random result. The “dynamic” keyword indicates that the C# compiler should use the DLR to dispatch method calls at runtime, rather than trying to validate the method calls at compile time. This enables a very clean integration between dynamic languages and static languages, and even gives you the ability to define your own dynamic objects. Chris Burrows has a great blog series on how C# “dynamic” works.
Try it out
To try out this release:
- Install NET 4.0 Beta 2 or Visual Studio 2010 Beta 2
- Download either IronRuby or IronPython
- Follow any of the many dynamic walkthroughs online. This would be a good start.
Build from source
To build IronPython or IronRuby for .NET 4.0 Beta 2 from source, get the sources from:
Note: use the "v4" build configurations.
Being a “preview” release, these releases haven’t gone through the usual testing that the normal binary releases go through. However, both IronRuby and IronPython will be supported on .NET 4.0 when it ships for real. Also note that the these releases will run only under .NET 4.0 Beta 2.
There is no project-system integration between IronRuby and IronPython in Visual Studio 2010 Beta 2, so don’t expect to find File->New Project->IronPython or something like that; this release is just about the integration between .NET 4.0 and DLR-based languages. If you’d like that to not be the case, please continue to let Microsoft know that on the open http://connect.microsoft.com issues for IronRuby and IronPython Visual Studio 2010 integration.