Iron Python : what are good uses for Iron Python

18,758

Solution 1

Either or both :)

I wouldn't claim to know a specific "purpose" for IronPython but it certainly can be used to write applications, and it can be used for scripting within a larger .NET application.

Aside from anything else, it's a handy way of gently easing Python developers into the world of .NET. (Why not learn C# at the same time? Come on in, the water's lovely...)

Solution 2

The biggest benefit of IronPython is that it brings the worlds of Python and .NET very close together.

If you have libraries (assemblies) written in C# you can import those directly into IronPython and use them, like this:

import clr
clr.AddReferenceToFileAndPath('MyAssembly.dll')

import MyNamespace

c = MyNamespace.MyClass()

c.MyFunction()

This is very nice for reusing exisiting .NET code when scripting or even interactive use with the IronPython interpreter.

Ordinary CPython requires Python .NET to do the same or similar things. In my experience, Python .NET works most of the time, but not always and IronPython provides a much more polished experience in accessing .NET from Python.

IronPython will probably always lag the reference implementation of CPython in terms of standard library support etc., but in general the development is not that far behind, that it would hard to work with coming from a CPython background.

Lastly, there are a few substantial differences between CPython and IronPython, to which, one should pay attention. Example - garbage collection (bit me the other day...).

Solution 3

IronPython with WPF is the most productive way to design a GUI that I'm aware of. Almost all of the app pictured below is written in IronPython. Only very small parts are done in C# or C++/CLI for performance reasons.

Sure, you do miss some WPF/C# integration, but you gain much more on the productiveness side.

alt text

IronPython is also much easier to extend than CPython. You take your C++ code and just add a small C++/CLI wrapper on top of it. CPython has nothing which is as easy as this. That's the reason that I've started using IronPython, because I got tired of writing wrappers for my C++ code in CPython. Boost.Python, SWIG, and the like didn't work for me.

Solution 4

  • IronPython is just Yet Another Python Implementation. You can use it anywhere you would use any other Python implementation. (Modulo platform constraints, of course – obviously you can't use IronPython on a Java-only device.)
  • IronPython is just Yet Another .NET Compiler. You can use it anywhere you would use any other .NET language.
  • IronPython is More Than Just Yet Another Python Implementation. It's a Python implementation that gives you full access to any .NET library.
  • IronPython is More Than Just Yet Another .NET Compiler. It's a .NET compiler that gives you full access to any Python library.
  • IronPython is an embeddable scripting engine for any .NET app, library and framework.

Solution 5

I think the Iron family of languages is primarily for adding more flavours to the platform, allowing you to get into .NET using a language that you are familiar with. It lowers the bar a lot for getting new people with different backgrounds into .NET

Even though the syntax is Python, the implementation is still built on top of the CLR and the end product will not differ a lot if you decide to go for an IronPython project instead of say C#.

I've had some experience with IronPython and find it nice to work with (it helps of course that I really like the language). IronPython is now considered a first class citizen by Microsoft, and that is also the impression you get when using it. One downside to using it though is that it isn't as widely adopted as the two main languages, causing some issues when it comes to collaboration and maintaining a code base over time.

I found it particularly useful when doing a .NET port of a search algorithm that was first implemented in Python.

Regarding adding scripting abilities to your app, that is probably not the original intention with IronPython, but it has been done. The Umbraco CMS has (or at least had) the ability to create widgets using Python as a dynamic scripting language within their platform. A pretty neat feature to have.

You should go ahead and try it out.. It's always good to have more tools in the belt :)

Share:
18,758
Master Morality
Author by

Master Morality

Updated on June 07, 2022

Comments

  • Master Morality
    Master Morality about 2 years

    I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.

    Could you write an app in it? or is it for adding a scripting language to your app?

    How do you guys use it?