Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?
Asked Answered
I

3

12

Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?

After some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!):

1) It's simple to create a runspace with classes in your application; therefor it's easy to make your application scriptable.

2) I've heard some rumors that IronRuby and IronPython are losing support from Microsoft, so they may be a poor long term solution?

As this is my first time adding scripting to an application though, I'd welcome all the advice I can get from people who have been down this road before.

Specifically, besides letting me know whether you agree with my two points above, I'd like to know if IronRuby and IronPython are much easier to use (for a user, not developer) than powershell, and if in your experience using the DLR is as easy as just passing an object to a powershell runspace? And if I added support for the DLR and IR/IP scripting would my application still be backwards compatible with XP?

Inopportune answered 14/8, 2010 at 16:47 Comment(0)
B
12

EDIT in June, 2022

With 12 years behind us, the original answer is terribly bad 😣

  • PowerShell became a DLR language (sort-of) in 2012
  • IronRuby was basically abandonware by then
  • PowerShell was open-sourced in 2016
  • PowerShell was cross-platform in 2018 on .NET Core
  • IronPython 3 was ported to .NET Core in 2020

The Microsoft-run PowerShell open source project has multiple orders of magnitude more community involvement and popularity than the IronLanguages ever did...

While it is still not designed as an embedded scripting language, PowerShell definitely has the capability to be used as such.

While it never worked with the DLR hosting model, it definitely has a working hosting model now.

With the new licensing, PowerShell is completely redistributable.

With expanded OS support (and even compatibility with ARM), there's really no reason not to choose PowerShell.

ORIGINAL ANSWER from 2010:

I'm not convinced PowerShell has "being a scripting language for applications" anywhere in it's long-term goals. It's first a shell, second an integration & automation engine, and third a shell scripting language ... since it's not redistributable at all, I'm not sure where embedded scripting fits in.

It's certainly very easy to host PowerShell -- assuming that it's pre-installed on your target PCs-- so it's a very viable option, but I think that in general it's just as easy to do it with IronRuby or IronPython.

I doubt the DLR itself is going away, so I think using a DLR language is still a good choice for this: you'd be set up to accept other DLR languages with much less effort, and the DLR and languages are redistributable.

Also, the work to host PowerShell only gets you PowerShell -- whereas you can leverage the same work to get IronPython and IronRuby working. Who knows, since PowerShell is a dynamic language, maybe it will be ported to the DLR with proper dynamics support in a future version ... but it's unlikely to ever be redistributable, because Microsoft doesn't consider it a dev tool, but rather a core part of the OS.

Bottom line: using the DLR is much more portable -- and not just to XP but even to Mono (and thus to Linux, OS X, iOS, Android, etc... and even to the web or Windows Phone via Silverlight).

Bartel answered 16/8, 2010 at 19:30 Comment(1)
Actually, being a scripting language for application administration and automation IS one of the major targets, as presented by the powershell team. While I don't disagree with your other points, using PS this way is nearly certain to be supported and improved as long as PS is around. With that said, I am confused by the redist policy and practice around powershell. – Irksome
P
7

number 2 is true (the dynamic lang teams have been losing headcount for awhile now) and an excellent reason. Ruby and Python aren't MS languages, and as such Iron * is just 'get it working on .NET'. PowerShell is a Microsoft creation, Microsoft-controlled, and Microsoft-supported.

More importantly, multiple Microsoft products have taken deep dependencies on PowerShell (Exchange, SharePoint, etc.) so there's very little question of PowerShell's ongoing support as a language.

Last, PowerShell considers being the scripting lang for other applications as one of its first-class support targets.

Propaganda answered 14/8, 2010 at 17:25 Comment(2)
Sadly, the bit about IronXxx is true. Just when we started hoping for official VS support... – Matland
Well, IronPython is still Microsoft-supported. IronRuby is the one that is being abandoned. – Wisnicki
B
2

I'm in a similar position. I decided to use IronPython scripting but ever since I saw Anders Hejlsberg's talk "The Future of C#", I've had a feeling IronPython was doomed.

It was in Microsoft's interest to get the DLR developed but they ultimately want us to use tools and languages they control. After all, aren't you using C# and not Java? So what will a Microsoft dynamic language look like? How about dynamic, interpreted C# (Iron C#)? Hejlsberg's talk made it clear it isn't that far away. He even had a console window with a REPL interface. That said, there's always a possibility for Iron VB. Talk about closing the loop.

On the plus side for us programmers, Iron C# also solves another problem that I'm having trouble with -- the existence of two parallel object environments, one of .Net objects, one of Python objects. It takes work to get from one to the other. I assume an Iron C# would utilize the .Net class structure.

My advice: Stick with Iron Python and .Net classes. When Iron VB or Iron C# happens, it'll be a quick, maybe automatic, language translation. Besides, if enough of us use IronPython, Microsoft may change their mindset.

Bloodyminded answered 17/8, 2010 at 17:4 Comment(2)
is F# a dynamic language that Microsoft supports? – Cootch
No F# is statically typed programming language – Vanden

© 2022 - 2024 β€” McMap. All rights reserved.