# Friday, 17 December 2010
It's over 200 pages long, and over four years old, but I just heard about it recently. A long, dense discussion of whether certain C++ features (templates, namespaces, RTTI, etc) have a performance cost, and how to write code that incurs as little performance cost as possible. Its official name: ISO/IEC TR 18015:2006(E)  Technical Report on C++ Performance. In addition to runtime performance, it also touches on compile slowness, the "brittle base class" problem, and the different performance characteristics of various STL collections and algorithms. If you care about the speed of your C++ code, you should read this, even if some of it is already familiar to you.

I'd like to give some kind of "Restrained Understatement" award to this sentence:

Template meta-programming  and  expression  templates  are  not  techniques  for novice programmers, but an advanced practitioner can use them to good effect.
To be clear about where these authors are placing the "advanced" bar, I don't use meta-programming, I consider it too advanced for me. And I have 20+ years of C++!

The whole report is platform independent (though embedded systems are discussed separately) and compiler independent, too. I wish it were updated for C++0x, but I guess that will have to wait until C++0x is settled :-). There's a 14 page bibliography, and you would do well to read many of them, though my source for the link winkily pointed out another possible paper. That one is old enough to get a driver's license, but I think you might enjoy reading it anyway. As the introduction begins:

It is important to understand how your programming language is implemented. Such knowledge dispels the fear and wonder of “What on earth is the compiler doing here?”; imparts confidence to use the new features; and provides insight when debugging and learning other language features. It also gives a feel for the relative costs of different coding choices that is necessary to write the most efficient code day to day.
It's only 23 pages long, and concludes:
... we have considered many of the significant C++ run-time implementation issues. We see that some wonderful language features are almost free, and others can incur significant overhead. These implementation mechanisms are applied quietly for you, behind the curtains, so to speak, and it is often hard to tell what a piece of code costs when looking at it in isolation. The frugal coder is well advised to study the generated native code from time to time and question whether use of this or that particularly cool language feature is worth its overhead.
Good advice, in 1994 or 2010.

Kate

Friday, 17 December 2010 11:34:31 (Eastern Standard Time, UTC-05:00)  #    
# Wednesday, 15 December 2010
Those hardworking elves at the All in One Code Framework keep releasing more samples. They've added some ASP.NET samples (including a very interesting "get location from IP address" one) and some Windows 7 shell extensions, specifically a preview handler. Ah, the good old .recipe file type - an old friend of mine. But as always the samples are going to save you hours and hours of time.

Here's an index to all the samples for you to explore. You might be a little astonished if you haven't checked it out before, they have:
Slowly but surely the samples are accumulating to live up to the name. This should be the first place you look when you want to take on a new task. Generally speaking, everything is available in native C++, C#, and VB (the exceptions are things you can't do in native C++, like ASP.NET) with the language included in the sample name (look at CppWin7TriggerStartService, CSWin7TriggerStartService, and VBWin7TriggerStartService for example.) And remember, if you don't see what you want - you can ask for it!

Kate

Wednesday, 15 December 2010 10:57:52 (Eastern Standard Time, UTC-05:00)  #    
# Monday, 13 December 2010
At the moment these are announced in the USA only. A full day of client development training for Windows 7, including IE9 and SL OOB. They say:

We will look at application compatibility and transitioning your applications to Windows 7, integrating with the Windows taskbar, developing for IE9, utilizing the cool functionality in the Sensors and Location Platform so that your application better responds to its current environment, leveraging the multitouch capabilities (especially in kiosk scenarios), and creating Silverlight 4 out of browser applications. This event is a unique opportunity, partnering classroom learning with hands-on-labs and leveraging experts to advise you so we can help you “win” with Windows 7.

You bring your own laptop with VS 2010, the Code Pack, the Windows 7 Training Kit, IE9, and Silverlight 4 installed (there are links on the bootcamp page) and do the labs as you go. The training is all free and you'll get hands on experience right while you're there. (It doesn't say so, but my guess is this is all managed code and that the labs are in both C# and VB.)

And if there isn't one near you, you can help arrange one! It's all packaged as an event-in-a-box so all you need is a trainer who'll agree to deliver it and a room to hold it in. But check the dates and locations first -- there are over a dozen sessions scheduled already, so perhaps there's one near you.

Kate

Monday, 13 December 2010 10:40:52 (Eastern Standard Time, UTC-05:00)  #    
# Saturday, 11 December 2010
Back on December 7th, Jason Zander announced the beta of Service Pack 1 for Visual Studio 2010. December announcements can often go un-noticed, but you should pay attention to this one. You can get the beta and start using it in production immediately.

What's in it, and why does a service pack matter, anyway? Well this one brings Silverlight 4 Tools for Visual Studio "into the box", updates some MFC capabilities, and fixes things people raised on Connect. (Remember, complaining about missing features or bugs to your cubicle mates may make you feel better, but raising them on Connect gets them fixed. I should know, I submit things there and they get fixed.) STL has a comment on the VCBlog post that spells out many of the fixes in detail.

Take a few minutes and update your Visual Studio, especially if you're a C++ developer, whether MFC or C++0x (or both, of course.)

Kate

Saturday, 11 December 2010 10:17:49 (Eastern Standard Time, UTC-05:00)  #    
# Thursday, 09 December 2010

Herb Sutter has blogged a "trip report" (except he didn't travel, but anyway) about the November meeting of the C++ Standards Committee. In it, he tells us:

Things are going well and we are on track to complete the Final Draft International Standard (FDIS) for the C++0x standard after the Madrid meeting in March. If that happens and that ballot succeeds, the C++0x standard will be published in 2011.

There are still decisions being made, and I have to say I like the way they're going. I think contextual keywords are wicked smart, and that if compilers can understand them, developers sure can. Compare Herb's two examples:


class [[base_check]] Derived : public Base {
public:
virtual void f [[override]] ();
virtual double g [[final]] ( int );
virtual void h [[hiding]] ();
};
class Derived explicit : public Base {
public:
virtual void f () override;
virtual double g( int ) final;
virtual void h() new;
};

Contextual keywords make the second option possible, and I think it's much better. You can also read about noexcept and the whole exception-checking backstory, as well as rules for generating move constructors and move assignment operators. It's all good.

Kate

Thursday, 09 December 2010 13:24:29 (Eastern Standard Time, UTC-05:00)  #    
# Tuesday, 07 December 2010
Windows 7 developers have tons of cool stuff at their (our) fingertips. There's taskbar integration, the new sensors and location platform, access to devices, and more. Silverlight developers, on the other hand, have so far not been able to get to all of that. Well, now you can! The Native Extensions for Microsoft Silverlight leverages the ability of Silverlight to do COM integration, and puts COM Automation around a collection of Windows 7 functionality so that Silverlight developers can use it. How cool is that?

Because it's on the Code Gallery, you know it's from Microsoft. The first release, Dec 2nd, covers:
  • Windows Sensor API - Integrate sensors:  Accelerometers, Light sensors, compasses, gyroscopes etc. 
  • Microsoft Speech API - Text to Speech (Speech Synthesis) and Speech to Text (Speech Recognition) 
  • Windows Portable Devices API - Enumerate and access content from connected portable devices (cameras, phones, music players, scanners etc.) 
  • Windows 7 Taskbar Integration - Jump lists, overlay icons, overlay progress display, Thumbnail toolbars etc. 
  • Webcam Local Encoding and Window Capture - Encode webcam capture into mp4 (H.264/AAC-LC) media - Capture user interface interaction as video 
  • Window Message Interception - Intercept and act on Window messages sent to the Silverlight OOB host window

This certainly gives Silverlight developers some interesting options! There are some samples that come with the library to show you what you can do, too. You might also be interested in Maor David's blog entry about the library.

Tuesday, 07 December 2010 12:33:24 (Eastern Standard Time, UTC-05:00)  #    
# Sunday, 05 December 2010
I finally caught up some of my PDC-watching and really enjoyed this Herb Sutter talk on C++0x lambdas. I'm well known to be a huge lambda fan. Herb made this talk enjoyable for me by bringing his personality to the table. He showed aspects of C++ that are not exactly elegant, and how using lambdas can make some much neater code possible. Sure, lambdas are "just" syntactic sugar, but they add up to a new way of thinking about writing applications in C++. Well worth watching.

One warning though - I generally download videos and watch them at 1.5 or double speed. I highly doubt you want to do that with this talk - it's dense!

Kate

Sunday, 05 December 2010 11:59:12 (Eastern Standard Time, UTC-05:00)  #    
# Friday, 03 December 2010
Kenny Kerr is back in Canada and back writing about C++. Like a lot of us these days, he's looking at a stripped-down, more modern way to write Windows applications in C++ - no MFC, no ATL, no WTL. Plenty of STL and new C++0x features. I like it! Here's the first installment - stay tuned for the rest of them!

Kate

Friday, 03 December 2010 11:53:59 (Eastern Standard Time, UTC-05:00)  #