您会推荐 Iron Ruby、Iron Python 或 PowerShell 将 C# 应用程序设为脚本宿主吗?

发布于 2024-09-14 01:01:47 字数 524 浏览 15 评论 0原文

您会推荐 Iron Ruby、Iron Python 或 PowerShell 将 C# 应用程序设为脚本宿主吗?

经过一些快速修补后,现在我倾向于使用 powershell 有两个主要原因(请注意,这些纯粹是我的观点,如果它们是错误的,我很想知道!!!):

1)创建一个运行空间很简单您的应用程序中的类;因此,很容易使您的应用程序可编写脚本。

2) 我听说一些传言称 IronRuby 和 IronPython 正在失去 Microsoft 的支持,因此它们可能不是一个糟糕的长期解决方案?

由于这是我第一次向应用程序添加脚本,因此我欢迎从以前走过这条路的人那里得到的所有建议。

具体来说,除了让我知道您是否同意我的上述两点之外,我还想知道 IronRuby 和 IronPython 是否比 powershell 更容易使用(对于用户,而不是开发人员),以及根据您使用 DLR 的经验是否更容易使用就像将对象传递到 powershell 运行空间一样简单吗?如果我添加了对 DLR 和 IR/IP 脚本的支持,我的应用程序是否仍然向后兼容 XP?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

子栖 2024-09-21 01:01:47

2022 年 6 月编辑

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

郁金香雨 2024-09-21 01:01:47

第 2 点是正确的(充满活力的 lang 团队现在已经失去员工一段时间了)并且是一个很好的理由。 Ruby 和 Python 不是 MS 语言,因此 Iron * 只是“让它在 .NET 上运行”。 PowerShell 是 Microsoft 创建、由 Microsoft 控制并由 Microsoft 支持的。

更重要的是,多个 Microsoft 产品已经深深依赖于 PowerShell(Exchange、SharePoint 等),因此 PowerShell 作为一种语言的持续支持几乎没有问题。

最后,PowerShell 将其他应用程序的脚本语言视为其一流的支持目标之一。

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.

北凤男飞 2024-09-21 01:01:47

我也处于类似的情况。我决定使用 IronPython 脚本,但自从我看到 Anders Hejlsberg 的演讲“C# 的未来”后,我有一种感觉 IronPython 注定要失败。

开发 DLR 符合 Microsoft 的利益,但他们最终希望我们使用他们控制的工具和语言。毕竟,您使用的不是 C# 而不是 Java 吗?那么微软的动态语言会是什么样子呢?动态的解释型 C# (Iron C#) 怎么样?海尔斯伯格的讲话清楚地表明,这一目标并不遥远。他甚至有一个带有 REPL 界面的控制台窗口。也就是说,Iron VB 总是有可能的。谈论闭环。

对于我们程序员来说,有利的一面是,Iron C# 还解决了我遇到的另一个问题——存在两个并行对象环境,一个是 .Net 对象,一个是 Python 对象。从一个到另一个需要付出努力。我假设 Iron C# 将利用 .Net 类结构。

我的建议:坚持使用 Iron Python 和 .Net 类。当 Iron VB 或 Iron C# 出现时,这将是一种快速的、也许是自动的语言翻译。此外,如果我们有足够多的人使用 IronPython,微软可能会改变他们的思维方式。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文