Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I've been wondering to myself, what uses does IronPython have in a .NET environment? what can it do that can't be done with VB, C# or F#? It seems kind of strange to go through all the trouble of making the DLR and enabling dynamic languages on the clr just to add another language.
What do people use IronPython for?

share|improve this question

closed as too broad by gnat, MichaelT, Bart van Ingen Schenau, Kilian Foth, ratchet freak Sep 8 '14 at 14:56

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

Please update your question to be complete. Don't add comments, they're hard to read. It's your question, you can update it. – S.Lott May 4 '11 at 20:08
Oh, FrustratedWithFormsDesign originally posted his answer as a comment. I'll move this comment to the correct place. – Ziv May 4 '11 at 20:18
You don't need to post a lot of status. Just update the question, please. – S.Lott May 4 '11 at 20:26

5 Answers 5

up vote 17 down vote accepted

IronPython (or DLR languages in general) make some things extremely easy that are very hard to do with compiled .NET languages. Some use cases would include:

Use case 1: In a C# application, you have a string like "x+3*sin(angle)" and you want to evaluate it. The simplest way to do that is to include a dynamic language and let it evaluate the string. Writing a parser for arithmetic expressions isn't rocket science, but with the DLR you get a very powerful expression interpreter with list comprehensions, operator overloading and access to all the .NET objects you want for less than 10 lines of code.

Use case 2: You want to allow your users to enhance your C# application's functionality with some kind of macro facility. If you use a DLR language for that, the script code automatically has access to the plain old .NET objects you give it as parameters or put in the script's global scope.

Use case 3: You want to make some part of your code be easy to change, possibly at runtime. (Think business logic.) You want more changeability than a config file can offer but you don't want to adjust your application's source code for every installation. So you make some part of the code dynamic, load it at runtime and let it interact with your host application.

Use case 4: You want to write your application in a dynamic language because you think it's the best tool for this specific task, but you need some .NET library.

share|improve this answer
+1, nice listing of use cases, I was going to write this myself – Matěj Zábský May 5 '11 at 10:19
  • Python scripts that use .NET libraries. Great if you want to script something to interoperate with something that has a .NET API.
  • A .NET-enabled REPL. Great for quick scripts, one-time actions, or playing around with methods and stuff.

The key question for me was "why Python instead of PowerShell?" I admittedly haven't spent that much time with PowerShell but it just repels me for some reason, and I'm taking it as an opportunity to learn a language that I can use to expand my thinking and use outside the .NET ecosystem as well (full-time C# dev here).

share|improve this answer

I would guess they use it for making .NET applications, written in Python instead of C# or VB or F#. Probably they do this if they don't know C#/F#/VB, but they do know Python.

Using the .NET framework gives you access to all the existing .NET libraries which may or may not have equivalent functionality in other Python libraries. And it would make interactions between IronPython components and other .NET components easier. This matters if you work in a place that uses the .NET stack.

share|improve this answer
Or they do it because C#, F# or VB are inconvenient for the task at hand. Or they do it because Python is more portable to other OS's. Or they do it because Python's REPL is easier to work with than the various compilers and IDE's. – S.Lott May 4 '11 at 20:09
That's my question, what kind of task (in a .net environment, which is only available in windows), do you need python? The REPL is one answer but it's just one small advantage that I don't believe warrants using a new language in a business environment. – Ziv May 4 '11 at 20:21
@Ziv: You never need Python. You merely prefer it. "that I don't believe warrants using a new language in a business environment" doesn't make any sense at all. If that was true, we'd all be using assembler (That was the first business language. Really.) – S.Lott May 4 '11 at 20:27
C# offers major advantages compared to assembler, python offers advantages over C#, but what does python on .net offer over python on the python interpreter? – Ziv May 4 '11 at 20:46
Obviously, integration with existing CLI copde - libraries and applications. – delnan May 4 '11 at 20:52

IronPython Has access to both the .Net world and the standard python world. Which was really nice. I mostly used IronPython for loading up my classLibs so I could play with them in an interactive terminal. It made for easy debugging.

share|improve this answer

I think the DLR was designed for the cool new features in .NET 4, like LINQ that requires some of them.

Then Microsoft decided to either:

  • show off that .NET is not only C#, but you can code in .NET using a load of different languages (I think they missed the point here, but it was probably driven more by marketing types :) ),
  • liked Python (and Ruby) and some devs wanted to put Ruby/Python on the .NET framework just for the fun of it.

I'm surprised they didn't do IronJava but they might still be smarting over losing the lawsuit (or maybe there's all kind of further legal issues they didn't want to handle).

share|improve this answer
It's called J# it's not exactly the same but it's there. – Erin May 4 '11 at 21:22
ah yes, I had completely forgotten (or blanked it from my mind) Its hardly spoken about much in the web, maybe that's why I forgot it. – gbjbaanb May 4 '11 at 21:39
You are aware that Jim Hugunin created IronPython before he started at MS? I don't think he was driven by "marketing types" – nikie May 5 '11 at 8:18
@gbjbaanb: I'm not sure who "they" are, but, Jim Hugunin wrote about how and why he created IronPython in his blog. If we read that, we'd know why he did it ;-) – nikie May 5 '11 at 19:01
Other inaccuracies being: IronPython works with .NET 3.0, and thus some of the DLR is available to that version of the framework, if you include the correct libraries. LINQ does not require the DLR; Dynamic LINQ does, but LINQ on the whole does not. – Matt Ellen May 5 '11 at 19:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.