Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can be done in VC++ (native) that can't be done with VC#?

Tags:

c++

c#

visual-c++

What can be done in VC++ (native) that can't be done with VC#?

From what I can tell the only thing worth using VC++ native for is when you need to manage memory yourself instead of the CLR garbage collector, which I haven't seen a purpose in doing either (but thats for another question to be asked later).

like image 953
Phillip Avatar asked Apr 16 '09 16:04

Phillip


2 Answers

Cross-platform development. Yes Mono exists, and Java's somewhat more predictable to have it function EXACTLY the same on more platforms, you can find a C/C++ compiler for just about any platform out there, where you can't with C#.

Also linking into 3rd-party libraries, while I'm sure there's a way to leverage them in C#, you'll be able to take advantage of them without interop (Marshaling, etc) in C++.

Edit: one last thing: RELIABLE memory management. Yes you can use dispose(), and try-finally, but there's nothing quite like KNOWING the memory is gone when it's popped off of the stack. Through techniques like RAII, when you use well-constructed classes, you will KNOW when your classes release resources, and not waiting around for the GC to happen.

like image 128
Kevin Anderson Avatar answered Nov 15 '22 20:11

Kevin Anderson


With P/Invoke there is very little that is impossible in .NET (most obviously device drivers).

There are also things where the advice is to not use .NET (e.g. shell extensions, which get loaded into any process that opens a file dialogue1).

Finally there are things which will be much harder in .NET, if possible at all (e.g. creating a COM component that aggregates the FTM).

1 This can create a problem if that process is already using a different version of .NET. This should be alleviated in the future with .NET 4 having the ability to support side by side instances of the runtime.

like image 45
Richard Avatar answered Nov 15 '22 21:11

Richard