9

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.

3 Answers3

16

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.

softveda
  • 2,679
12

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.

DPD
  • 3,527
9

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.

dsimcha
  • 17,284