Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
3.67/5 (3 votes)
See more:
Hi,
In my opinion, and it is only my opinion C++/CLI only adds in complexity of C++. I just wanted to confirm weather I am write or wrong. That is why I have posted this question here.

I am thinking this because, C++/CLI can use .Net CLR like other .Net languages. C#/VB.Net are comparatively easy to use than C++. Then why should one make project in C++/CLI. If you want to use Unmanaged code, anyway you can create dll and use it in C#.

If we are using C++/CLI, then we are inviting lots of libraries implicitly like, MFC,STL,Standard C and CLR. And huge Unmanaged of managed and Unmanaged code.

If you want to use Unmanaged code, MFC could be the best option.

Regards
Posted
Comments
Sergey Alexandrovich Kryukov 9-Nov-11 13:26pm    
Not really a question. It's just a polemic post, not really belongs here. Could be posted on forum (where I really don't participate, ha-ha). I expressed my opinion but not interested in long arguments over the topic...
--SA

If you want to use the features of .NET then C# is much the better choice. And even if you need some managed code for speed or efficiency then you can always include a C++ based DLL.
 
Share this answer
 
[Answering the follow-up question:]

Pranit Kothari wrote:

Hi Sir, Thanks for your answer. But here my question is why one should prefer C++/CLI over C# or VB.Net. Will C++/CLI also score more on performance than C#.


Good question. I would estimate the relative values like this:

VB.NET: Honestly, forget it. Yes, it's a decent language right now, but the social structure around it looks like this: it has never been a standard and I'm almost sure it will never be, in contrast to C# and C++/CLI. Main role of it is: to former keep VB users at work and keep sales of .NET due to having established market driven by VB users, no more. Also, the real-life attitude of professionals to VB.NET programmers is usually very arrogant, like VB people are not true. Even if such attitude can be considered wrong, it's a big negative factor to the people selecting the language. In real life, when you are looking, for the help in .NET, most likely the good solution will be C#. If you look for developers, you can find VB.NET people much easier, but when you need quality, the situation is directly opposite. VB.NET developer, please don't get offended, it has nothing to do with your personal skills, but on average this is just a medical fact, by all observation. Even Microsoft is not so serious about VB.NET — some features always go behind C#.

C#: Maybe the best and most effective language from all the standard languages of .NET. It has some inherent problems though. For example, I feel devastating about lack of inheritance or simple type definition for primitive types. At least C++ has typedef. The idea of inheritance of primitive types is very well-proven (thing Ada), but C++ legacy cut out the approach. But with C# it's worse: if I need to delay the decision of concrete primitive type and make it changeable, I can only declare alias in using clause, which I have to repeat in all files involved — so ugly. Most of other problems are problems of .NET, and there are very few of them. And of course, compromised readability of code inherited from C, like curly brackets barely different from round brackets would be a curse (fans of C-like language, please keep silence: we do understand you, but it's just your imprinting), but Intellisense and other, folding editors and other things compensate for such problems very well. However, C# has some limitations which can be removed by using of C++/CLI. Or IL, for that matter :-). The language is standardized under ECMA and ISO.

C++/CLI: So, what limitation of C#, etc., can be overcame? C++/CLI is the unique language (not counting IL) where even so called reference type can use value semantic. So, the instances of classes can be placed totally on stack, or memory usage can be combined: the instance of the class on stack, one member is on heap, another on stack, and so on. This is very important feature! It may safe some memory, but this is not the most important thing. For example, stack is much easier and safer with multithreading as all threads have separate stacks. Another powerful thing very practical in real-life situation: mixed mode. The ability to mix managed and unmanaged code is amazing, compared to legacy "managed C++". This is a way to avoid massive P/Invoke. C++ has better performance. In Microsoft implementation, this is the only .NET language I know which uses its own more advances optimizer, not just generic .NET optimizer. However, the real-life performance improvement will heavily depend on application.
At the same time C++ has some impossibly outdated features, such as "include". I really do not understand how it's possible to keep such archaic and non-robust technique in XXI century. Compatibility with the legacy, one would answer. Well…
Also, it's generally considerably more difficult to code using C++/CLI compared to C#. Visual Studio Intellisense, refactoring (is there any?) are well behind that of C# projects.
The language is standardized under ECMA and ISO, so major C# and C++ codes alike can really run on many platforms, not just C++

IL: Most powerful thing in .NET, ever. Best thing: fully standardized under ECMA and ISO. The major problem is: lack of good documentation except the standard, not easy to use.

I only pointed out what I find most important myself. As to comprehensively correct and objective comparison, not only this is very difficult, but theoretically impossible. Please consider this as my personal notes.

—SA
 
Share this answer
 
v2
Comments
[no name] 9-Nov-11 14:13pm    
Thanks. 5! again.
Sergey Alexandrovich Kryukov 9-Nov-11 14:20pm    
My pleasure!
Good luck, call again.
--SA
Sergey Alexandrovich Kryukov 9-Nov-11 14:26pm    
Just added an edit on C++/CLI: "However, the real-life performance improvement will heavily depend on application." Well, naturally.

Thank you.
--SA
Of course C++/CLI is much, much simpler in use than "original" C++. Just working on the platform with Garbage Collection (GC) saves you from major C++ headache (a word of warning: but not 100% guarantee from memory leaks which could be created by design).

The libraries, too. All C++ libraries, mostly non-standard (come on, there are no standards on MFC, STL, etc.) are, frankly, almost nothing compared to powerful .NET library. In contrast, major part of .NET is standardized under ECMA and ISO. Thanks to that — in part — major part of you C++/CLI code, if written accurately, can run under many other platforms, not just Windows, and, in contrast to C++, without a single preprocessor "IF" or "IFDEF".

The only reason to prefer C++ is performance, no arguments here. Another reason is your preoccupation with C++, so typical. But my idea is: can you use you dignity of being a real rational human being, not just an animal (yes, I call all of us animals because this is what we are), so, not just an animal driven by (relatively) primitive instincts?


Pranit Kothari wrote:
If you want to use Unmanaged code, MFC could be the best option.

And this is a typical judgment of a person who almost never tried any UI libraries. Am I right? :-)

Cheers,
—SA
 
Share this answer
 
v2
Comments
[no name] 9-Nov-11 13:26pm    
Hi Sir,
Thanks for your answer. But here my question is why one should prefer C++/CLI over C# or VB.Net. Will C++/CLI also score more on performance than C#.
Sergey Alexandrovich Kryukov 9-Nov-11 14:03pm    
You are very welcome and thank you. After all, I've written a whole overview as a separate solution. Please see. Hope you will find it interesting.
--SA
Menon Santosh 9-Nov-11 13:28pm    
Nice Explanation :)
Sergey Alexandrovich Kryukov 9-Nov-11 14:04pm    
Thank you, Menon.
--SA
[no name] 9-Nov-11 13:30pm    
5!
C++/CLI is meant to be a bridge from native code to managed code. It's not meant to be a language for developing full managed applications (C# is already there for that). That's why you don't get any of the rich development environment features in the IDE that you do with the .NET languages.

I was a long long time C++ developer when I started wanting to use features of the .NET framework so I really wanted C++/CLI to be a full-fledged language, but really by the time you make it that, for the most part you just have C# with alot of uglier syntaxes.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900