# Sunday, June 29, 2008

Lately some people I know have been revisiting the "why are so many Microsoft samples in C#" question. They are VB programmers, and they're just not feeling the love. Man, I know how that feels :-). Several recommendations of Instant VB reminded me that I had been meaning to try Instant C++. This is a $139 product that converts C# to C++/CLI (there is also a version to convert VB to C++.) There's a demo available, and it serves as an excellent example of what is both good and bad about code converters. Here's a comparison of the source and converted code for a demo I use to illustrate UAC in Vista programming:

Sure, it's boring as all get-out to change string to System::String^, though I would probably have done a using for the namespace and just said String^. (In fact, there's a using namespace System; in there already, but the converter doesn't seem to take advantage of it by omitting namespaces.) But there is so much here I don't like. First, I'm a String^ s person, not a String ^s person. Then there's how it handles the using. Hello? Stack semantics anyone? No? And where's my project file? I pointed this at a .csproj file, but I don't seem to get a .vcproj file in return, so I'll need to create a project and add the converted code into it. That's probably ok if I just want to convert sample code to paste into my real project, slightly less ok if I wanted to convert the sample project and test it.

Still, if you're using a relatively new technology, and you need to get to it from C++/CLI because you're writing a wrapper for legacy code or the like, and you get SOOOOO BOOOORED going through samples changing . to :: and new to gcnew and adding ^, then this is a cool tool to save you hours of that kind of thing. Just don't skip the step where you actually make it read like proper C++ code.



Sunday, June 29, 2008 9:38:12 AM (Eastern Daylight Time, UTC-04:00)  #