在标准C ++或C#上使用C ++ / CLI有什么好处?

时间:2022-09-01 19:11:43

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.

我没有看到任何真正的优势,除了你有一个C ++语法,以及它,如指针和析构函数。

4 个解决方案

#1


13  

If you're talking about why you would use C++/CLI over C#, I think the main reasons are that:

如果你在谈论为什么要使用C ++ / CLI而不是C#,我认为主要原因是:

  1. it might be more natural for C++ developers (though I think this is probably not true)
  2. 对于C ++开发人员来说可能更自然(尽管我认为这可能不是真的)

  3. C++/CLI has very nice capabilities for bridging the native and managed environments (using the 'IJW' - It Just Works - technology)
  4. C ++ / CLI具有非常好的功能,可以桥接本机和托管环境(使用'IJW' - It Just Works - 技术)

I think that Herb Sutter probably gives the best overview:

我认为Herb Sutter可能会给出最好的概述:

A Design Rationale for C++/CLI

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 ++而不是C#/ .NET,这可以归结为为什么你需要一个托管环境(安全,更容易开发)而不是本机代码(绝对控制,可能是速度优势)。每个都有争论,答案实际上取决于你想要发展什么以及你的市场可能是什么。

#2


6  

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.

我认为你指的是C ++ / CLI并将它与C#进行比较。 C ++ / CLI不是C ++的“味道”。它是一种全新的语言,具有完全不同的标准库和完全不同的约定。

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.

在工作中我们发现C ++ / CLI作为C ++和.NET之间的粘合语言是有价值的,但我们不会将它用于除界面粘合之外的任何东西 - 在所有其他应用程序中,C#比C ++具有巨大的优势。

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.

如果你指的是像亚当描述的那样的MS C ++扩展,那么没有理由不使用它们,如果它们使你的工作更容易。

#3


1  

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 ++ \ CLI的真正好理由是将DotNet语言与Native C ++进行通信,例如,许多公司首先将其GUI迁移到.Net并在C ++中使用某些逻辑,而C ++ \ CLI是在两个techno之间进行通信的良好桥梁,你也可以使用COM组件,但由于很多原因,它不是一个好的选择。

#4


0  

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

我不认为将C ++的不同风格相互比较是与将C ++与C#进行比较的问题相同。与不同风格的C ++之间的差异相比,C#是一个非常不同的野兽。

#1


13  

If you're talking about why you would use C++/CLI over C#, I think the main reasons are that:

如果你在谈论为什么要使用C ++ / CLI而不是C#,我认为主要原因是:

  1. it might be more natural for C++ developers (though I think this is probably not true)
  2. 对于C ++开发人员来说可能更自然(尽管我认为这可能不是真的)

  3. C++/CLI has very nice capabilities for bridging the native and managed environments (using the 'IJW' - It Just Works - technology)
  4. C ++ / CLI具有非常好的功能,可以桥接本机和托管环境(使用'IJW' - It Just Works - 技术)

I think that Herb Sutter probably gives the best overview:

我认为Herb Sutter可能会给出最好的概述:

A Design Rationale for C++/CLI

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 ++而不是C#/ .NET,这可以归结为为什么你需要一个托管环境(安全,更容易开发)而不是本机代码(绝对控制,可能是速度优势)。每个都有争论,答案实际上取决于你想要发展什么以及你的市场可能是什么。

#2


6  

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.

我认为你指的是C ++ / CLI并将它与C#进行比较。 C ++ / CLI不是C ++的“味道”。它是一种全新的语言,具有完全不同的标准库和完全不同的约定。

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.

在工作中我们发现C ++ / CLI作为C ++和.NET之间的粘合语言是有价值的,但我们不会将它用于除界面粘合之外的任何东西 - 在所有其他应用程序中,C#比C ++具有巨大的优势。

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.

如果你指的是像亚当描述的那样的MS C ++扩展,那么没有理由不使用它们,如果它们使你的工作更容易。

#3


1  

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 ++ \ CLI的真正好理由是将DotNet语言与Native C ++进行通信,例如,许多公司首先将其GUI迁移到.Net并在C ++中使用某些逻辑,而C ++ \ CLI是在两个techno之间进行通信的良好桥梁,你也可以使用COM组件,但由于很多原因,它不是一个好的选择。

#4


0  

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

我不认为将C ++的不同风格相互比较是与将C ++与C#进行比较的问题相同。与不同风格的C ++之间的差异相比,C#是一个非常不同的野兽。