Iron Python : what are good uses for Iron Python [closed]
Asked Answered
D

12

29

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?

Devanagari answered 2/12, 2010 at 14:47 Comment(1)
What part of the python.org web site do you find confusing? It seems to provide a good overview of Python. Perhaps you could provide specific quotes or links to things that confuse you.Hemorrhoid
N
30

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...)

Nordau answered 2/12, 2010 at 14:49 Comment(2)
I've been working in C# since 2.0, Python was just the first language I learned, and you never forget your first...Devanagari
"Come on in, the water's lovely, but there's a Python in it!". Great.Boutin
I
12

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...).

Ish answered 9/1, 2011 at 4:52 Comment(1)
I find this the best way to test code, test code usability and avoid the release of useless in-house features that stain legacy code for no reason.Gualterio
J
8

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.

Joanjoana answered 3/12, 2010 at 19:17 Comment(1)
This app looks very interesting. It combines wpf and productivity. Is it possible to elaborate it more? E.g. A tutorial on this topic?Cougar
M
6
  • 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.
Marimaria answered 2/12, 2010 at 14:56 Comment(0)
S
4

We use it as an embedded language inside of our software. I had an article on my blog, but recently switched to a new system. You can find an archived version (with broken image links) here:

Our field engineers now use the embedded language to test things on the fly, our quality assurance people use it to create small scripts to test all features of the hardware, etc....

Hope this helps.

Slapdash answered 2/12, 2010 at 14:50 Comment(0)
K
4

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 :)

Kadner answered 2/12, 2010 at 14:59 Comment(0)
N
2

You use it to write Python code that runs on the .NET platform. It's good for anything that Python is good for.

The Python language is the Python language, no matter what. IronPython is an implementation of the runtime for that language - the support code that compiles your source, creates a virtual machine to execute the bytecode in the resulting .pyc file, communicates with the OS in order to put command line arguments into sys.argv, and all that other fun stuff. (Well, OK, the .NET platform itself does a lot of the work, too. :) )

Newsom answered 2/12, 2010 at 14:51 Comment(0)
M
2

My experience of IronPython is usage it as part of engine that can be changed after installation of base .Net application. With help of Python we have described really large set of business rules, that can be changed from two system installation. Partially IronPython was used as plugin language.

The difference from script language - that after compilation IronPython executed as CLR code.

Maryleemarylin answered 2/12, 2010 at 14:52 Comment(0)
M
2

First: IronPython is really more of a compiler than an interpreter in the strictest sense - it will be used to generate .NET Assemblies from your python source files. So yes, you can write apps and most anything the .NET Framework can do.

One of the largest benefits of IronPython is that it has (effectively) no GIL - meaning that if you are both writing Python code and it is multi-threaded - you can often get performance that is better than CPython without having to spawn multiple process and pickle objects across the boundaries. It doesn't solve the problem of concurrency, but .NET provides much more robust constructs for dealing with it. I think this is pretty niche honestly, but it is certainly there.

The python.org wiki page for IronPython lists a bunch of key differentiators as well:

Michellmichella answered 2/12, 2010 at 16:12 Comment(0)
H
1

You can write an app in it, you can use it as a scripting language in your app.

It's used for accessing existing Python libraries and, if needed, writing parts of your code in Python if a .NET languages doesn't seem well enough suited for that job.

Hurley answered 2/12, 2010 at 14:51 Comment(0)
V
1

I think Resolver Systems built their products with IronPython. So there is definitely some real-world use of IronPython.

Enthought also anounced that they will port NumPy to IronPython and .Net. This will certainly broaden the appeal of IronPython.

Versify answered 2/12, 2010 at 15:52 Comment(0)
A
1

You can use it for cool things like having an embedded web server within your application which can be developed with one of the available Python web frameworks. It is much easier and smoother to develop for than hosting an ASP.NET web server within your application. CherryPy for example comes with a builtin web server as well that should work fine with IronPython with a few small modifications.

Aceous answered 5/12, 2010 at 10:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.