Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you recommend Native C++ to C++\CLI shift? [duplicate]

Tags:

c++

c#

c++-cli

I have been working as a native C++ programmer for last few years. Now we are starting a new project from the scratch. So what is your thoughts on shifting to C++\CLI at the cost of losing platform independent code. Are there are any special advantages that one can gain by shifting to C++\CLI?

like image 508
TG. Avatar asked Sep 30 '08 09:09

TG.


People also ask

What does C++/CLI stand for?

C++/CLI is variant of the C++ programming language, modified for Common Language Infrastructure.

How do I call C++ code from C#?

If you want to use C++ in c# code directly, you can create a CLR(C++/CLI) project, then you can write c++ and c# code in the same project.

What is CLI wrapper?

Zigbee CLI wrapper (zb_cli_wrapper) is a Python package for the nRF5 SDK for Zigbee that includes a wrapper for automating communication with the Zigbee CLI Agent example and improving the control of the Zigbee network. It is a standalone package and can be used on both Windows and Linux machines.


2 Answers

I would recommend the following, based on my experience with C++, C# and .NET:

  • If you want to go the .NET way, use C#.
  • If you do not want .NET, use traditional C++.
  • If you have to bridge traditional C++ with .NET code, use C++/CLI. Works both with .NET calling C++ classes and C++ calling .NET classes.

I see no sense in just going to C++/CLI if you don't need it.

like image 182
OregonGhost Avatar answered Sep 20 '22 08:09

OregonGhost


Some questions to consider before switching:

[1] Are you fine with sticking to Windows? There are .NET clones for other OS's, but your app is not going to just run transparently. A complexity you might not need.

[2] Are you considering switching just for the garbage collection support? If so, you can just use some C++ garbage collector libraries. And if you figure out how to leverage std::shared_ptr, you might not feel the need for garbage collectors. An overhead you might not need.

[3] Are you considering C++/CLI because of the garbage collection & all the useful .NET classes that you can leverage? If so, why not just switch to c#. C++/CLI is a transitional technology, and it is best not to invest resources in such things. c# is getting pretty mature and usable.

Personally, I would just stick with C++ ;).

like image 42
user15071 Avatar answered Sep 21 '22 08:09

user15071