Open Source.NET

The IronLanguages Open Source Project

Late last year Microsoft took IronRuby, IronPython and the Dynamic Language Runtime projects open source. Here's a look at the open source dynamic language resources for Visual Studio.

With dynamically typed languages gaining momentum, we can’t help but see what options are available in the .NET ecosystem. Many may not know it, but we have open source implementations of Ruby and Python, along with integrations for Visual Studio, readily available.

The IronLanguages project started off as a six-year Microsoft endeavor to bring dynamic languages to the .NET platform. Late last year, Microsoft opened the source code and the community has taken over the project’s development. This includes IronRuby, IronPython and the Dynamic Language Runtime (DLR).

The DLR is is a set of services that sit on top of the Common Language Runtime (CLR) and provide the foundation for dynamically typed languages. Thus, the DLR enables IronRuby and IronPython to run on the .NET platform.

In addition to providing language services, the IronLanguages project also has IronStudio, a set of Visual Studio 2010 extensions with support for both IronRuby and IronPython. You can download the iron languages along with their tools for Visual Studio through their download pages on CodePlex (IronRuby Releases, IronPython Releases). Once installed, you can use Visual Studio to create a new project File | New | Project and select the language(s) that you installed.

The integrations provide a number of different project options. Take a look at the IronRuby projects and for now, we’ll select the Sinatra Web Application project. Sinatra is a popular Domain Specific Language (DSL) for quickly creating Web applications in Ruby. We can take advantage of Sinatra in IronRuby, giving us an elegant and simple way to create an IronRuby Web site.


[Click on image for larger view.]
Figure 1.IronRuby projects in Visual Studio.

As Visual Studio is creating your project, it will acquire the required gems and create a simple Sinatra Web application for you. Press F5 once the project is created, and you should see your Web app running in a browser. You will also notice a console window running along with your browser -- this is WEBrick. WEBrick is a Ruby library providing simple HTTP Web server services like Cassini (open source as well, distributed with Visual Studio) or IIS Express.


[Click on image for larger view.]
Figure 2.The Sinatra Web application code.


[Click on image for larger view.]
Figure 3.The Sinatra app displaying "Hello, World" in a browser.


[Click on image for larger view.]
Figure 4.The WEBrick console.

In addition to the many project types supplied by the Visual Studio integrations, you can also load interactive windows from View |Other Windows | IronRuby Interactive, and from View | Other Windows | IronPython Interactive. Very quickly we can open both interactive windows and implement a Fibonacci number generator in both languages.


[Click on image for larger view.]
Figure 5.IronRuby Interactive.


[Click on image for larger view.]
Figure 6.IronPython Interactive.

Outside of Visual Studio 2010, you can also open 32-bit and 64-bit consoles for IronRuby and IronPython, just as you would with their non DLR counterparts.

If you are thinking about creating Visual Studio 2010 extensions, I highly recommend looking through the IronStudio source code. There are a number of integrations implemented by the IronLanguages project and they can be a great source of information and examples.

IronStudio provides most of the development tools you would expect from a language service, including IntelliSense, debugging, syntax error detection, local window and more. IronStudio gives you a full .NET development environment with the flexibility of dynamic languages.

If you want to work on these projects, or have questions, you can go to the IronLanguages GitHub page or the mailing list and talk with other users and the developers.

Sites to Visit:
Iron Code Home: https://github.com/ironlanguages
IronPython Home: http://ironpython.net/
IronPython Download: http://ironpython.codeplex.com/releases
IronRuby Home: http://www.ironruby.net/
IronRuby Download: http://ironruby.codeplex.com/releases

About the Author

Ian Davis is the Master Code Ninja for software architecture and development consulting firm IntelliTechture. A C# MVP, Davis is an expert on the .NET Tramework and co-organizer of the Spokane .NET User Group who frequently speaks at industry events. He spends most of his free time as an open source author and advocate, publishing and working on many open source projects.

comments powered by Disqus

Featured

Subscribe on YouTube