C++/CLI : Advantages over C#

前端 未结 11 2221
自闭症患者
自闭症患者 2021-01-05 00:54

Is there any major advantage of managed C++/CLI over C#. Definitely not the syntax I suppose as the following code in C++/CLI is real ugly,

C++/CLI code:

<         


        
相关标签:
11条回答
  • 2021-01-05 00:55

    It's almost exclusively an interopability language - both for allowing .Net code to access legacy C++ libraries, or for extended existing (native) C++ code bases with access to .Net libraries (and some variations on these themes).

    While it is possible to write fully fledged applications solely in C++/CLI, and it even gives you some language features not available in pure C++ (such as garbage collection), I doubt there are many people who would actually do this. If you're already moving away from pure C++ and don't have the goal of interop with .Net there are probably more natural choices (such as D or Scala, for example - depending on which direction you want to go in).

    Similarly, moving from pure C# to C++/CLI could arguably bring the advantages of C++ templates, but it's rare that this need would lead to you taking that step.

    0 讨论(0)
  • 2021-01-05 00:56

    Being a predominantly C# programmer, I was finding myself having to use C++/CLI with a bit of pain. However, as an interop language, it FAR outweighs C# for having to work with native code. The C++/CLI IDE in Visual Studio lacks a lot of the features in the C# flavor.

    Overall, it has its place and will remain viable as long as native code exists. I wouldn't want to have to create WinForm apps from scratch with the C++/CLI IDE if I didn't have to.

    0 讨论(0)
  • 2021-01-05 00:56

    you just turn to c++\cli when you have to, if you can meet you requirement using c#, why bother go c++\cli

    0 讨论(0)
  • 2021-01-05 00:59

    CLI/C++ has many advantages over C#.

    1. STD libraries
    2. Native C++/C cannot be viewed by disassembler (like Reflector) because they are not actually CLI (no need to obfuscate (although a good hacker can already get by this)).
    3. Mingling C/C++ projects as a wrapper to be used with .Net languages. C++/CLI is not a language is just adds support for .Net with C/C++.
    4. Some bit of control on memory via C/C++ pointer pointing to C/C++ objects on the heap.

    I hate having to trust in GC to get to an object stuck on the gen 2. Lord knows when that will be released from the managed heap.

    0 讨论(0)
  • 2021-01-05 01:04

    unmanaged c++ applications do not need a framework to run, c# will only run on machines with dotnet framework 1, 2, 3 or 4. it surprising how many machines still run without these framework.

    0 讨论(0)
  • 2021-01-05 01:05

    Easier interoperation with native C++ code is the one advantage.

    Whether it's a major advantage is subjective.

    Unless you want to mingle with existing native C++ code, you're probably much better off with C#.

    0 讨论(0)
提交回复
热议问题