C++ vs. C#

A few of my more C++-centric friends and colleagues have sent me pointers to Grumpy Old Programmer's "Has C# lost its point?" grump. While I naturally enjoy seeing VC++ portrayed in a positive light, I think it's a bit silly to suggest that C# has lost the very impetus for its existence simply because CLR has been elegantly folded into the C++ language. It's clear Grumpy Old Programmer is a C++ fan (not unlike many other grumpy old programmers I know), and that's great! However, Grumpy's grump seems to be a classic case of the old "my programming language is better because I like it better" argument that always comes down to the unarguable issue of personal preference. I'd like to pull a few quotes out of the grump because I think it's important to make the point that I truly believe that C++ and C# are and will continue to be useful languages in their own right.

>>The truth is that this new development in C++ seriously undermines the justification for C# as a language. C++ programmers yet to learn C# simply don’t need to now.<<

 

I agree with the latter part of this statement but disagree with the first. If the justification for C# as a language were to simply get C++ developers using .NET, then, yes, the new CLR features in VS 2005 would undermine C#. However, C# isn't about migrating C++ developers to .NET. C# incorporates lessons learned from C++, Java, Delphi, and other languages and focuses them into a very productive, expressive, readable, and manageable language. That said, with VS2005 it's true that if you're a C++ developer today, you need not feel compelled to learn C# simply because you're interested in targeting the .NET platform -- VC++ 2005 enables you to target .NET in a way that feels natural from a C++ standpoint.

 

>>What’s the point? They will find the full productivity of Visual Studio 2005 right there at their fingertips supporting the language they know and love. Why should they move to something that is slower and less feature rich?<<

 

Indeed, C++ developers tend to find C++ productive. :) For C++ developers, there is no need to jump onto the far left side of a new learning curve in order to reach the .NET platform. However, many developers *want* to take the time to learn C#, and that's okay too. In fact, one of the hallmarks of C++ developers is they're generally capable and willing to jump into another language and use it when it suits their needs for a particular task.

 

However, I have trouble buying the argument that C# is slower and less feature rich. It's true that from a runtime performance standpoint, C++ tends to be superior (even for some managed code, due to some optimizations we can perform in the compiler front-end). However, I would argue that C# is speedier in terms of design-time performance, as the faster compiler tends to lend itself toward more productive use of code->compile->debug->repeat cycles. Where changes can be made and tested in smaller increments. And feature rich? Well, it's definitely true that C++ developers have a massive arsenal of language features and libraries at their disposal to attack whatever problem they need to solve. But let's say you want to design a web form in the IDE... well, you can't do that in C++. Rather than trying to claim that one language is more feature rich than the other, I would simply say that each language experience is optimized for a different set of scenarios.

 

>>It will be interesting to see how many ex C++ programmers slip back to C++ now that it is fully .NET enabled.<<

 

Here, Grumpy and I are in agreement. We would love to bring back into the fold, those C++ developers that would prefer to do their .NET coding in C++. Because of the easy mixing of native and CLR bits in C++, .NET can effectively become just one more library among the many that C++ developers already enjoy. But some folks will still prefer to do their .NET coding in C# because it has its own advantages in .NET elegance and productivity, and that's okay too.

 

>>Of course, Microsoft will continue to promote C# as the native .NET language – they simply can’t afford to admit that they have foistered a brand new language on the programming world that is broadly feature-identical to other languages, and cannot pretend to be a replacement for C++. <<

 

Again, C# was never intended to be a "C++ for .NET" -- it's a differnt language with a different different philosophy and a different set of priorities. It's also worth pointing out that there continues to be some real language innovation coming out of the C# team, some of which won't be visible outside of Microsoft for a couple of years. C# is a bit more free to innovate within the language than we are in C++ because compatibility and conformance are major issues for our user base. However, those C# innovations that make sense for C++ will be folded into the language.

 

>>C# acolytes will no doubt be pampered with IDE features that are denied to other developers (for no technical reason)<<

 

We're talking about software here, where everything is possible, so there is rarely a technical reason why some feature or other shows up in one language but not another. More often it's things like scheduling priorities or targeted scenarios. For example, C# has webforms development, whereas C++ does not, because that's important to C# developers. However, C++ allows for transparent mixing of native and CLR modules, which C# does not, because that's important to C++ developers.

 

In summary, C++ and C# are both great languages that fulfill different needs, and the success of one need not come at the expense of the other.