Cook Computing

Code Shock

October 8, 2004 Written by Charles Cook

Matt Warren has a good post on his journey from being an unmanaged to managed code developer. His description of looking back into the unmanaged world describes my feelings exactly:

Years later, with lots of experience working in managed environments, Java and .Net, I've grown accustom to all those services and practices that at one time seemed not only alien, but flat out wrong. Now, I find myself completely on the other side of the fence. I find myself now looking at C code, unmanaged, raw, savage, and I cringe. Not because the code is poor or violates any rules, it's just running without the safety net. Whenever I see a fixed sized buffer on the stack, a flurry of asterisks or even an innocent looking 'new', I get a bit nervous. I start to wonder if the code was written correctly, if all the cases were handled, and if some errant state in a far off function will suddenly go astray, launching the processor into a tantrum, wreaking havoc across the codescape, a whirlwind of destruction that will quickly lay waste to even the cleanest lines of logic.

This does have the benefit that whenever I do C++ work now I'm much more careful. The metaphor that comes to mind is driving on an icy road: you know that any moment you may find yourself in the ditch. If you only ever work in C++ its easy to become complacent about the risks of implementing bad code. But I'm also more aware that the extra demands of C++ result in a very low productivity compared to C#.