C++ Isn’t Cool II August 13, 2006Posted by gordonwatts in computers.
Microsoft’s latest release of its development environment and libraries contains some very cool new features for C++. One that I really like is a self-checking version of the standard library. This code will watch your code and if you do something illegal it will attempt to flag it right away. The effort grew out of, I think, the whole secure computing drive that Microsoft and the rest of the field has been going through.
When you have to deal with very complex code that makes heavy use of the standard library this sort of thing can be a huge help in tracking down bugs. Heck, why waste time tracking down a bug when the computer can track it down for you, right!?
I discovered a nasty side-effect, however. In order to implement these checks Microsoft altered some basic things in the library. This is fine… except they turn off these alterations for optimized code. This makes sense: once you have debugged your code you don’t want to slow it down making all these cross checks. But this also means you can’t mix optimized an unoptimized code any longer. I found this out the hard way (thanks Axel).
It is times like this that I wish we’d moved towards one of the common garbage collected & interpreted languages – like Java or C# or similar – rather than C++. These languages have ways of adding attributes and other features to objects that will allow you to accomplish the same sort of checking without modifying the underlying object layout: the objects are extensible on the fly.
I was one of the people pushing for C++ when the field converted, but watching new people join our ranks I can’t help but wonder if that was a mistake – though back then I suspect it was the right choice.