Things I like about native development with C++/CX

Visual Studio 11 brings many new things for native development, including support for new features from C++11 (unfortunately not all), or ability to write Metro apps with C++/CX including modeling the UI with XAML. In this post I will talk a bit about three favorite features that I noticed immediately after trying VS11 from Windows 8 Developer Preview.

Use of namespaces
Finally, I see namespaces promoted in native code. Yes, it’s C++/CX and they were probably forced to use namespaces for a consistent experience from the various languages that target the Windows Runtime, but it’s a very nice change to the default templates for C++ projects where everything is put in the global namespace. I can only hope they will improve that in this version or the next for standard C++ applications (whether Win32 console apps or MFC apps).

UPDATE: looks like I wasn’t clear enough, I’m not saying namespaces is a new C++ feature (duh), I’m saying Visual Studio templates for C++ don’t promote that. Create a Win32 project, an MFC project, and ATL project, there are no namespaces. You’d have to code everything manually, but if you do it, you mess the wizards. So, what I’m saying is that I hope we can see namespaces promoted for other project and item templates too.

Partial classes
I already wrote about partial classes, but I want to reiterate this feature. Partial classes gives you the ability to define a class in several files. This is great because developers and code generator tools such as designers can edit different parts of the same class without interfering one with the other. This feature made it possible for supporting XAML user interfaces in C++/CX Metro applications.

I’m actually wondering why isn’t this already part of standard C++ and I can only wish that the next version (which hopefully will not take another decade to conclude) will include this feature.

Better Syntax Highlighting
Below is a comparison for the same piece of code highlighted by Visual Studio 2010 on the left, and Visual Studio.vNext (11) on the right.

There is hardly any formatting in VS10. However, on the other hand, the highlighting in VS11 is beautiful. User defined types (including library types) are displayed with another color than the built-in types (such as int), including in their definition. STL types (string, vector, etc.) are finally identified as types and displayed with the appropriate color. Also the name of parameters is displayed in italics which makes them easily identifiable. There are other things about the highlighting, but these striking changes.

4 Replies to “Things I like about native development with C++/CX”

  1. Why do you say that namespaces are a novelty in C++? I’ve used namespaces in the past while writting C++ code.

  2. I should be from another planet to say namespaces are new to C++. I’m saying Visual Studio’s templates don’t promote namespaces. When you create a project or add a new class, it’s always in the global namespace. And they shouldn’t. They should use namespaces.

  3. There are addins that have been doing “smart” highlighting for years now. It was about time they included it in Visual Studio

  4. Personally I don’t like the italics that much, and after more than 10 years coding C++ I seem to find them to be really distracting (weird, I know).

    Anyways, installation of VS11 completely trashed my Intel Parallel Studio install (couldn’t even roll back), which is annoying. I hope the next drop will be a bit better.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.