Choosing C# over C++

In a comment, Josh asks “[Why should] a C++ programmer choose to write industrial programs in C#? Of course you needn’t restate the benefits of a 3rd/4th/5th generation language, as much as benefits to someone who is choosing whether or not to port existing C++ code to C#.”

Since it’s my blog, I’m going to ignore his request and quickly restate that the language C# has productivity benefits over C++. Beyond that, the Base Class Library (BCL) definitely has huge productivity benefits, but you can access the BCL through Managed C++ and, soon, C++/CLI.

But porting existing C++ to C#? That’s a tricky one.

Jon Udells NET Report Cardnbspis An Ex

Jon Udell’s .NET Report Card is an excellent article, but I’m going to pick a couple nits:

He gives .NET a B in “Advancing the state of the art of Windows programming.” I’d disagree: for both the state of the art and state of the practice, I’d give .NET an A+. The advanced “art” of Windows programming has received a huge boost from Rotor, the BCL, and the CodeDom: Windows is now legitimately a top platform for programming language development. And for the state of the practice, you can argue that .NET and the BCL are just incremental advances over Java, but as an advance over MFC and as a unifier of the C++ / VB worlds? For the Windows platform, .NET is a huge step forward.

Jon accurately nails COM Interop as being trouble-prone (a given project tends to be either trouble-free or agony). He quotes Greg Reinacker on a problem I wasn’t aware of: if you’re a managed add-in (for Outlook, in the case of Reinacker’s NewsGator), you automatically bind to the version of the CLR that the first managed add-in binds to — a bug in my book.

He enthuses that “.Net’s support for Web services wins universal acclaim….The promise of cross-platform XML messaging has become a reality….As a result, we’re starting to see the kinds of network effects that justify all the early excitement about Web services,” and gives .NET an A in that subject.

To battle grade inflation, I would agree with Jon’s criticism on areas like interop (especially because I think that additional tools could have been provided by now), versioning and security. I’d probably also throw in the clear-in-retrospect realization that .NET is not inviting to newcomers, that the benefits of a managed, object-oriented platform are not immediately apparent to many programmers.