IronPython in SharpDevelop 3.1 and Converting C# to IronPython

SharpDevelop is an open source Windows IDE for the .NET framework. MonoDevelop, the Mono IDE, started life as a fork of SharpDevelop.

SharpDevelop lists amongst its features:
  • Support for Mono
  • Supported languages include C#, VB.NET, Boo, IronPython and F#
  • IDE features like refactoring, code completion, Windows Forms designer
  • Can run from a USB device
  • Read only projects
  • Parallel build support for multi-core machines
  • Multi-framework targetting (.NET 2.0, 3.0 and 3.5)
  • Integrated support for tools like FxCop, Wix, NUnit, TortoiseSVN, MSBuild etc
One area where it distinguishes itself from Visual Studio, the 10 000 pound gorilla in the world of Windows IDEs, is its excellent support for IronPython. This just got a lot better in their latest release; 3.1 beta.

Matt Ward, who I believe is responsible for the IronPython support, has written a couple of blog entries on the new features:
Support for designing Windows Forms in IronPython is now available in SharpDevelop 3.1. The original IronPython forms designer was removed when SharpDevelop 3.0 began supporting IronPython 2.0 which had removed support for generating IronPython code from Microsoft's CodeDOM. The forms designer has now been re-implemented to use the IronPython abstract syntax tree (AST) and no longer relies on the CodeDOM.
This is extremely interesting as the lack of CodeDOM support in IronPython 2.0 is part of the reason why IronPython Studio is stuck with IronPython 1. The blog entry demonstrates how to use the IronPython forms designer (with copious screenshots) along with outlining its limitations and how it works. This means that the IronPython support in SharpDevelop far surpasses anything available for Visual Studio or MonoDevelop and gives both Microsoft & Mono a real incentive to improve. I will be trying out SharpDevelop as I am intrigued as to how good their intellisense is for Python; something which is difficult for dynamic languages, but some IDEs do a very good job.
SharpDevelop 3.1 now supports converting C# and VB.NET code to IronPython. It can convert a single file or an entire project. The code to convert between these languages is still under development and has some limitations.

Converting code to IronPython was originally supported in SharpDevelop 2.2 and was based on converting code to a Microsoft CodeDOM and then getting IronPython 1.0 to generate the Python code. In IronPython 2.0 this CodeDOM support was removed so the code conversion feature was removed from SharpDevelop 3.0 since that was using IronPython 2.0. In SharpDevelop 3.1 the code conversion has been rewritten to no longer use the CodeDOM support. It now works by executing the following simple steps:
  1. The C# or VB.NET code is parsed using SharpDevelop's parsing library NRefactory and an abstract syntax tree (AST) is generated.
  2. A visitor class then walks this AST and generates Python code which is added to a StringBuilder.
  3. Once the visit is complete the generated Python code is then displayed or saved to disk.
This is a really interesting feature. Whilst it can't, and doesn't attempt, to cover every possibility it could be very useful for converting example code into an IronPython equivalent. The news was picked up by InfoQ in their Moving to IronPython article and also by Dror Helper (the author of the article covered in my last entry) who recommends using SharpDevelop for developing with IronPython: SharpDevelop 3.1 Beta released – with some IronPython goodness.

Comments

Popular posts from this blog

Extending Abobe Flash Player and AIR with Python and Ruby

Should Python Projects Support IronPython and Jython?

Further Adventures of the Debugger