Microsoft hates C++

During various Microsoft-centric blogs, the term native renaissance was bounced around outlining the fact that Microsoft is getting back into native (i.e. C++) development in a big way. This was underscored by the fact that newer versions of the Visual Studio C++ compiler is going to track the C++ standard more closely and that the Windows 8 platform will make more use of native code. At least, that's the promise.

Coincidently, I got a chance to test this claim as I'm currently getting back into Microsoft Windows development. It's been awhile (like a decade) since I had to use any Microsoft-specific APIs like MFC, having done all my Windows work in Qt or Java over the last few years. Now I fully immersing myself in all the native C++ APIs as well as doing some C# work. It's good, interesting work as I get to see where Microsoft is going with all of this. One conclusion I've come to is that Microsoft hates C++, and always did.

First, Microsoft is still pushing MFC and ATL even in their latest Visual Studio products. These are terrible APIs birthed in the 90s and written by grumpy C programmers that wanted to use the least amount of C++ as possible. Who needs exceptions when you have HRESULT codes? MACROs are everywhere. C structs? Check! COM interfaces when a proper header file would do? Why not? TCHAR madness combined with something like 3-4 string classes makes basic string manipulation a chore. It's like Microsoft ignores all the features and patterns of modern C++ and stubbornly sticks with their old monsters. This does a huge disservice to C++ as this forms most developers' perception of the language.

What happened? All the love went into C#. This Java-clone (don't get me started on that) of a language got all the developer focus and love at Microsoft. It's a nice language coupled with a full framework. C# is on their what, its second or third GUI toolkit library in a decade while MFC is (and I just checked) twenty years old! Microsoft clearly made a nice, complete object oriented API for C#, wrapping everything you'd want to do in Windows in a nice framework. They're clearly capable of making nice libraries - but simply choose not for C++. They seem to just hate C++.

For example, compare writing to a Microsoft Message Queue (MSMQ) in C# and C++. In C# you get a nice auto-managed class library with a serialization layer and can write a message in two lines of code. With C++ you get a 12 year old C API complete with a few layers of structs (and unions!) that you need to setup. You need about 20 lines of error-prone C code to send a message in C++ and that's without any nice serialization. This is insane. Same story with their Crypto or XML parsing APIs and who knows what else.

There is no reason why Microsoft can't make a nice C++ Windows API, complete with automatic memory management (using smart pointers), one nice unicode string class and a nice object-oriented toolkit (that doesn't use macros for event dispatch). They're clearly capable given the evidence of their .NET framework. In fact, they could just mirror the .NET library, class for class. Otherwise, they could look at Qt for more inspiration - it's a sweet C++ class library. Heck, they could fully embrace and support it's Windows port if they wanted to, perhaps buying it outright.

Please Microsoft, if there really is to be a C++ renaissance then please give a us decent C++ platform library.