Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

From what I can understand, C# is the defacto language when coding .NET apps. Is it recommendable to program .NET apps [let that be ASP.NET, WinPhone 7, GUI, etc] in C++? What are the pitfalls and the drawbacks if we choose to go down this path?

Thanks for sharing.

share|improve this question
2  
C++/CLI is different from the rest of the .NET languages, as it produces mixed mode assemblies (which restricts its possible uses severely). It is a good idea to use CLI-compliant languages only, unless you really want to have a complicated interoperability with an unmanaged C++ codebase. –  SK-logic Apr 19 '11 at 12:41
add comment

3 Answers

up vote 14 down vote accepted

As a long time programmer who used C++ until I moved to C#/.Net my advice is not to use C++ for .Net development. Actually you cannot use real C++ to program in .Net but a microsoft abomination called C++/CLI with an ugliness not found in ISO C++. I would say just from readability point of view C++/CLI should not be considered at all. Do you want to use _gc, gcnew etc.
Also for practical purpose you will not find many code samples, tutorial, blogs etc. using C++/CLI, nor will you find programmers knowing or willing to work in C++/CLI. It is not a natural language for .Net development. C#/VB.Net/F# will continue to be much more rapidly changing with new features compared to C++/CLI.

share|improve this answer
    
C++ with managed classes was pathetic but C++/CLI is a whole lot better. I dont buy the "natural language" bit becuase it really is not that hard for a C++ programmer to learn C++/CLI. At least it wasnt for me. Not unless you are heavily dependent on code samples for coding. And Microsoft never meant for the C++/CLI standard to be a competitor to the new C++0x standard. They are meant for two different things. Given that C++/CLI has been around for 3-4 years now and the new ISO standard is just ready for release now, I think it was a reasonable thing for MS to do. –  DPD Apr 19 '11 at 10:46
1  
C++/CLI serves its purpose well. It is designed for tiny interop layers between the managed and unmanaged worlds. It is not wise to use it for anything besides that. –  SK-logic Apr 19 '11 at 12:43
    
Well I am currently using it for a new project. Not for interoperability , not to wrap native libraries, from scratch. The only problem I had was the initial time needed to get familiar with C++/CLI syntax and the Dot Net framework, which I believe, was much less than the time it would take to get familiar with C# anyway. Well everyone has his.her own experience so to each his own :-) –  DPD Apr 19 '11 at 16:29
1  
@DPD - I don't see a C++/CLI project type for ASP.NET (MVC),LINQ, EF, ODATA etc. in Visual Studio 2010. So even if it possible to do the above it would be difficult with no tooling support, lack of documentation etc. So I stick to my opinion that C++/CLI is not a first class citizen in .Net world. –  Pratik Apr 19 '11 at 21:25
add comment

The very idea of .Net is that you can use whatever language you are already comfortable with and use the DotNet platform without having to learn a new language all over again. One way of looking at it is as an inversion of the Java pyramid. Java can be explained as "single language-single executable(IL)-many OS". dot net is "many languages-one executable-one OS"(of course the one-OS bit is incorrect since we have Mono but I don't think that was what Microsoft had in mind :-P).

Yes C# was meant to be THE language for DotNet, but not "THE ONLY". Microsoft had probably hoped to get C++ programers to migrate to C# in the long run, if not immediately. But that doesnt seem to be happening. C++ is still the third most popular language. Faimiliarity with a language and the effort needed to port an aplication from C++ to C# has made most developers reluctant. After all , why fix something that is not broken? That is why Microsoft came up with C++/CLI. It is a wonderful way to get C++ programers on the the DotNet wagon without having to learn a new language. It took me very little time to get used to C++/CLI. The only drawback I saw was the new pointer notation for managed classes can confuse those who have a weak understanding of pointers in C++. Didn't affect me though.

share|improve this answer
1  
The main drawback to C++/CLI is that it differs considerably from standard C++, since some C++ constructs just don't transfer to CLI at all well. SK-logic also claims that it doesn't work seamlessly with .NET, so I'd suggest avoiding it. –  David Thornley Apr 19 '11 at 14:04
add comment

I don't see what the benefit is. C++'s main benefit is performance-critical, low-level, self-contained/native code. Once you're using a managed environment and all the baggage that brings, I can't see why you'd not want a more modern language that's designed for managed environments.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.