For example in .NET apps you can't write to the registry without being admina |
I'm fairly sure you would get Access Denied (error 5) when doing the equivalent operation in Win32 C++ as well. I'm curious to see an example of this, you could be completely right.
______________________________________
The main criticism in the OP's post can be summarized as "C++ lets you do more things to shoot yourself in the foot". I agree, it does.
But OP's list is strange to me. Half of them aren't really advantages or disadvantages, they're just different designs or goals of the different languages. C++ can be just as platform independent as C#, and C# .NET has platform-specific things as well. C++ can wring out every last bit of performance if necessary. "Friend" functions
have nothing to do with security, so I don't understand this point. Not having pointers does make safe-part of C# less complex, sure, but I still don't really consider that a disadvantage.
I agree that not having built-in security can be a disadvantage for some applications. It depends on what you're doing. The concept of "undefined behavior" in C++ can be one of its downsides. If you don't know what you're doing when it comes to security, then don't expect C++ to correct your ignorance.
Here are some thoughts on C# I had, copied from another thread:
C++ is of course much more powerful, but I find C# much quicker to make a variety of programs in than C++, and much easier to spot bugs in. For example, you want a stack trace? In C# it's just Environment.StackTrace. In C++, there is no standard solution, you either need to use a specific compiler, and write your own wrappers, or use an external library like boost or StackWalker.
C++ has so much "gotcha" behavior when you get into the nitty-gritty details. For example, the fact that short-circuiting does not happen when you use an overloaded && or || operation. There's other examples, but in general it's just not intuitive behavior at times. The concept of "undefined behavior" means that your program will never be completely secure unless you provide wrappers around places that may expose undefined behavior, such as preventing integer overflow with checks before you actually perform the addition or multiplication. C#, on the other hand, has a simple "checked" keyword that will throw an exception on overflow, instead of causing your whole program to become illegal.
C# intellisense/compiler errors tend to be very clean. C++ compiler errors are the opposite. Considering that templates in C++ are turing complete, and that the syntax of C++ is just more complicated in general, IntelliSense tends to be horrible at diagnosing all the possible problems, and template compiler errors just look horrendous in C++.
And as Thomas1965 noted, C# does have operator overloading, but the degree of freedom that C++ allows in operator overloading can be more of a curse than a blessing, at times. Sure, for many aspects of C++, once you learn about them you can consciously avoid doing them, but, in a nutshell, what I'm saying is that there are so many more ways to do something wrong without knowing it in C++ than in C#.
In C#, I dislike the "using" feature when working with disposable objects. As a user of a class, I shouldn't have to know whether or not something is Disposable and I need to handle it differently, else have some sort of resource leak. This is where C++ destructors are actually really useful, although problems with C++ destructors include knowing that you shouldn't ever throw an exception inside of a destructor, another gotcha.
I also like how C# limits the use of macros.
I admit I have not done multi-platform programming C#, but I thought C# has been pretty stable with support for other platforms for a while now.