与标准 C++ 相比,使用 C++/CLI 是否有任何优势? 还是C#?
除了拥有 C++ 语法以及指针和析构函数之类的东西之外,我没有看到任何真正的优势。
I'm not seeing any real advantages, other than the fact that you have a C++ syntax, and with it, things like pointers and destructors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您正在谈论为什么要使用 C++/CLI 而不是 C#,我认为主要原因是:
我认为 Herb Sutter 可能提供了最好的概述:
C++/CLI 的设计原理
如果您想知道为什么要在 C#/.NET 上使用本机 C++,这可以归结为为什么您想要一个托管环境(安全、更容易开发)优于本机代码(绝对控制,可能是速度优势)。 每个问题都有争论,答案实际上取决于您想要开发的内容以及您的市场可能是什么。
If you're talking about why you would use C++/CLI over C#, I think the main reasons are that:
I think that Herb Sutter probably gives the best overview:
A Design Rationale for C++/CLI
If you want to know why you might want to use native C++ over C#/.NET, this boils down to why you would want a managed environment (safety, easier development) over native code (absolute control, possibly speed advantages). There are arguments for each, and the answer really depends on what you want to develop and what your market might be.
我认为您指的是 C++/CLI 并将其与 C# 进行比较。 C++/CLI 并不是 C++ 的“风格”。 它是一种全新的语言,具有完全不同的标准库和完全不同的约定。
在工作中,我们发现 C++/CLI 作为 C++ 和 .NET 之间的粘合语言很有价值,但除了接口粘合之外,我们不会将其用于任何其他用途 - C# 在所有其他应用程序中比 C++ 具有巨大的优势。
如果您指的是像 Adam 所描述的那样的 MS C++ 扩展,那么如果它们使您的工作变得更轻松,就没有理由不使用它们。
I think you're referring to C++/CLI and comparing it to C#. C++/CLI isn't a 'flavor' of C++. It's an entirely new language with entirely different standard libraries and entirely different conventions.
At work we find that C++/CLI is valuable as a glue language between C++ and .NET, but we don't use it for anything besides interface glue - C# has enormous advantages over C++ in all other applications.
If you're referring to MS C++ extensions like what Adam describes, there's no reason not to use them if they make your job easier.
使用 C++\CLI 的真正原因是为了与 Native C++ 沟通 DotNet 语言,例如许多公司首先将其 GUI 迁移到 .Net,并让一些逻辑在 C++ 中,而 C++\CLI 是两种技术之间沟通的良好桥梁,您也可以使用 COM 组件来实现此目的,但由于多种原因,这不是一个好的选择。
the really good reason to use C++\CLI is to communicate DotNet language with Native C++, for example many companies migrate first their GUI to .Net and let some logic in C++, and C++\CLI is the good bridge to communicate beteween two techno, you can also use COM components for that, but for many reasons it's not the good choice.
我不认为比较不同风格的 C++ 与比较 C++ 和 C# 是同一个问题。 与不同风格的 C++ 之间的差异相比,C# 是一个非常不同的野兽。
I don't think comparing different flavors of C++ to each other is the same question as comparing C++ to C#. C# is a very different beast compared to the differences between different flavors of C++.