Monday, December 06, 2010

“The new C++ for the new Windows” by Kenny Kerr

Kenny Kerr is a software developer and entrepreneur. He is passionate about software and getting it done right. His new company recently launched Window Clippings 3, a screen capture tool designed to produce the highest quality screenshots.

This is the start of a new series of articles that I’m writing about C++ for Windows. I took some time off from my regular writing schedule to evaluate my approach to Windows programming and gain some actual production experience using the latest iteration of C++ in my new Micro ISV (check out Window Clippings).  What I will be presenting here is not the C++ you’ll find in most of the sample code currently found on MSDN. This is not about MFC. This is not even about ATL and WTL that I’ve recommended for years. This is a fresh new approach to Windows programming with C++. I don’t claim that my ideas are unique but I have found in my experience that the techniques that I’ve adopted help improve my productivity and produce better quality code, code that is easier to maintain, more reliable, and helps to enable excellent performance.

With the introduction of Visual C++ 2010 back in April of this year there was an opportunity for me to reconsider the way I develop applications for Windows. One of the unique aspects of C++ is that it is a multi-paradigm programming language. Other programming languages require you to write all your code as classes, or all of it using only functions. They might provide a handful of container types that you’re practically forced to use. Alternatively they might not provide any and force you to write your own. C++ however places no such constraints on its users. Bjarne Stroustrup sums it up nicely:

C++ was designed to support data abstraction, object-oriented programming, and generic programming in addition to traditional C programming techniques … It was not meant to force one particular programming style upon all users.

As the C++ language and the compilers that implement it have evolved and improved over the years different approaches have been popularized for writing Windows programs. To better appreciate these different approaches it is useful to consider the difference between libraries and frameworks.

Read more: Canadian Developer Connection