为什么 C++/CLI 不支持 Web 应用程序?
我花了一些时间学习C++/CLI,我觉得它是强大的.Net语言,特别是在互操作性概念方面。我认为如果这种语言将其互操作性扩展到包括asp.net,那将是伟大的一步,到目前为止,最新版本还不支持asp。但不知道未来版本是否有计划这样做。有什么原因导致最后一个版本的C++/CLI无法像C#或VB一样处理asp吗?
I spent some time to learn C++/CLI, I feel it is powerful .Net language specially in interoperability concept. I think it will be great step if this language will extend its interoperability to include asp.net, till now the recent version doesn't support asp. But I don't know if there is a plan to do that in future version. Is there any reason that made the last version of C++/CLI can not deal with asp like C# or VB?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
C++/CLI 从来就不是通用语言。它的存在几乎只是为了互操作性的目的。
如果您想在 .Net 应用程序中使用 C/C++ 库(无论是您自己的代码还是 WinAPI 之类的代码),C++/CLI 是为该库创建托管包装器或完全编写该库的好方法。整个应用程序,如果这不是那么多工作的话。
除此之外,您可能应该使用 C#(我认为如果您已经了解 C++,那么学习 VB.NET 没有多大意义)。如果您认为您的应用程序会从函数式风格中受益,那么其他替代方案是 F#。如果您认为您会从动态类型中受益,或者 IronPython(或 IronRuby)。
当然,如果应用程序的一部分使用其中一种语言会更好,而其他部分使用不同的一种语言会更好,那么您可以混合使用这些语言。
反对使用 C++/CLI 的另一个原因是它对 VS 的支持较弱(无 IntelliSense),以及 C# 使用 P/Invoke 与本机 DLL 互操作的能力。
重申一下,如果您需要与本机 DLL 或已编写的 C/C++ 代码进行互操作,请使用 C++/CLI。对于其他任务,您可能应该使用 C#。
C++/CLI was never meant as a general-purpose language. It pretty much exists just for interoperability purposes.
If you have a C/C++ library that you want to use in your .Net application (be it your own code or something like WinAPI), C++/CLI is a good way to either create a managed wrapper for that library or to completely write the whole application, if that's not that much work.
Other than that, you should probably use C# (I think it doesn't make much sense to learn VB.NET if you already know C++). Other alternatives are F# if you think your application would benefit from a functional style. Or IronPython (or IronRuby) if you think you would benefit from dynamic typing.
And of course, you can mix the languages if part of the application would be better in one of them and other part in different one.
Another reasons against using C++/CLI at all are its weak support in VS (no IntelliSense) and the ability of C# to interoperate with native DLLs using P/Invoke.
To reiterate, use C++/CLI if you need to interoperate with native DLLs or already written C/C++ code. For other tasks, you should probably use C#.
Visual C++ 编译器不支持分部类,直到 C++/CX 在 WinRT 投影的帮助下出现。每个 cpp 一个 obj 文件的传统很难打破。
如果没有部分类功能,表单设计者需要编辑您正在处理的同一文件。这意味着解析包含大量不相关文本的文件,处理宏等,最重要的是避免会替换设计者生成的重要代码的错误。我想不出有多少团队愿意处理这个问题,特别是对于像设置编辑器这样的小团队。
此外,C++ 解析器比简单语言的解析器慢。对于网页设计师来说,如果切换到类似的语言可以得到更快的设计器和编译器,为什么不呢?
The Visual C++ compiler does not support partial class, that is, until C++/CX come along with the help of WinRT projection. The one-obj-file-per-cpp tradition is hard to break.
Without the partial class feature, form designers need to edit the same file you are working on. That means parsing a file with a lot of irrelevant text, dealing with macros, etc, and most importantly avoiding bugs that would replace your important code as designer-generated. I can't think of many teams want to deal with that, especially for small teams like the Settings editor.
Besides, C++ parsers are slower than those for simpler languages. For web designers, if switching to a similair language can get a faster designer and compiler, why not?
我不确定是否有任何原因 ASP.NET 本身不支持 aspx 文件中的 C++ 内联,除了开发团队认为不值得付出代价(我假设这就是您的意思)。
但是,您应该能够在 C++ 中实现代码隐藏。尽管您仍然需要使用 C# 或 VB.NET 编写页面代码,但这应该可以完成 95% 的工作。
http://www.codeproject.com/KB/mcpp/helloworldmc.aspx (不是我的文章,仅供参考)
I'm not sure if there's any reason ASP.NET does not natively support C++ inline within aspx files besides the development team didn't think it was worth the cost (I'm assuming this is what you mean).
You should be able to implement code behinds in C++, however. This should get you 95% of the way there, although you'll still need to code your pages in C# or VB.NET.
http://www.codeproject.com/KB/mcpp/helloworldmc.aspx (not my article, just a reference)