July 2011

Volume 26 Number 07

Editor’s Note - Why C++ Still Matters

By Keith Ward | July 2011

Keith WardOne of our goals after taking the wheel at MSDN Magazine was to bring it closer to readers. And one of the things you’ve consistently told us is that we need to not treat C++ like the crazy uncle in the attic.

We heard you, and this is the result. This month sees the return of one of our most popular columns, Kenny Kerr’s Windows with C++. Kerr wrote this column for years, and we’re delighted to welcome back the Yoda of C++ development. To kick it off right, I asked Kerr some questions that put C++ in the context of today’s development environment. Here’s what he had to say.

What advantages does C++ hold over C#? Kenny Kerr: There are cases where C++ makes more sense. Why did Microsoft develop the native Windows Web Services [WWS] API long after Windows Communication Foundation [WCF] was well established as the premiere Web services stack? Surely, the .NET Framework is ideally suited to crunching XML and handling HTTP requests. Well, it turns out that C++ can still produce dramatically better throughput while using far less memory (bit.ly/czhaLd).

Does this really matter? If you’re an investment bank with enough capital to build large computing grids, perhaps not. However, if your customer is developing netbooks and tablets or smartphones, or is concerned about the startup time or battery usage for laptops, or needs to scale their Web server to handle a hundred million video requests without requiring a hundred Web servers, then it begins to matter very much.

How does C++ fit in with the Web and associated technologies? All of the major Web browsers and Web servers are written in C++. The operating systems these applications run on are also written in C++. Whether many developers think about it or not, C++ clearly plays a critical role in making the Web a fast and rich environment for users and developers alike. Of course, when some developers think about programming languages, they’re actually thinking about how they can use them to develop applications on top of these Web browsers and servers. That’s where domain-specific languages can play a critical role.

JavaScript is the obvious choice for developing applications for the browser. Many domain-specific languages play key roles in building server applications, from SQL for manipulating data, to Razor for producing markup. There is, of course, nothing stopping you from writing Web server applications in C++. Many domain-specific languages require various runtimes that may not be appropriate for some scenarios—shrink-wrapped server applications and embedded devices come to mind. IIS also has a great C++ API for handling performance-critical aspects of a Web application, such as handling I/O or rendering graphical charts.

What are some of the biggest changes in C++ with the latest version? Rather than thinking in terms of changes, you should think in terms of what C++ does well and how those things can be made better. C++ didn’t change much, but it has been improved in many ways to make it easier to do the things that C++ has traditionally been good at doing.

For example, C++ has a lot to say about power and performance, but is not always as simple as it could be. C++0x goes a long way toward making it both simpler for the application developer and more expressive for the library developer to build more powerful abstractions that are even more efficient, yet in a simpler and more intuitive way. Move semantics, for example, takes something that was quite difficult to do before and makes it not only efficient, but also simple for both library and application developers. Lambdas are another great example of C++0x making C++ more expressive while reducing the need to create function objects that fragment the structure of an application unnecessarily.

What are your main goals with your new column? I believe that C++ and Windows together make a powerful combination for producing great applications. Many developers have lost sight of this, driven to a large degree by Microsoft’s emphasis on the .NET Framework. I hope to show developers that it’s feasible—and even enjoyable—to write applications for Windows with C++ using the Windows API. Much like the .NET Framework, the Windows API continues to expand to offer more capabilities. You only have to look at applications like Internet Explorer 9 to realize the potential of C++ on Windows 7. I also think that Windows 8 and beyond is going to usher in even more capabilities specifically for C++ developers.