
The other C++
February 26, 2008I’m tinkering with a new spin on our auth/launcher application, wanting to make it a little more user friendly. I’d already done a quick mockup with the old Playgate source code, and decided it would be a neat project to dabble my toes in the Windows pool again.
Being a little clueless about exactly what Windows Forms are, I decided to create a C++ Windows Forms project. I love working in Visual Studio, I’ve been a big fan of VS for years now.
So I spent a few minutes setting up my form to my liking and then went to look at the code.
// Launcher.cpp : main project file.
#include "stdafx.h"
#include "Form1.h"
using namespace Launcher;
[STAThreadAttribute]
int main(array ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
This is supposed to be C++?
-
“[STAThreadAttribute]” HUH?
-
“array ^args” QUE?
-
“gcnew Form1()” Dios!
What the hell? Did someone decide that the best interests of good coding were served by ignoring prior conventions for introducing new language adaptations and re-using existing language symbols in new and strange ways?
I mean, what the hell is “^”? That’s traditionally the symbol for Logical XOR. And square brackets are array delimiters.
You couldn’t have used something like SQL’s hints, e.g. /*[SQLThreadAttribute]*/?
Conspiracy nuts are no doubt having a field day with this seeming abandonment of C++. I’m guessing its some form of managed C++, but really its “C#–”. After VS2005 took the ISO standard route instead of ANSI, pushing you to write platform specific versions of the standard library names (like “_open” instead of “open”), this must be giving the conspiracy nut folk a lot of material to play with.
BTW – I realize Windows Forms isn’t actually what I want for this project, but it was interesting to experiment with.
FYI:
“^” means “object on the heap reference”. Basically they’re doing a managed/garbage collected heap allocator that results in objects that have mutable locations, the type of object that gets created by using “gcnew”.
’scuse me for being an old fart but I can’t help thinking “woot! for 2 more layers of abstraction and degradation of performance all round!”
That’s Microsoft for you…
P.S. Have you seen thread 210445 in the Barracks? Interesting observations there.
I like the C# environment, the code is a lot tidier than vb.net and easy to follow and pick up.
That looks like Managed C++, which VS2005 probably does by default if you do a Windows Form project. It’s not that far from C#. BTW, you can do a lot of wicked cool stuff with the [Attribute] tags in C#, particularly in conjunction with reflection.
@sres:
C# is bastardized java.
The whole point to java is that it’s scupulously clean, so there are a lot of constructs that aren’t in it because they are considered a dangerous practise.
So MS decides to do their own java, only better. They do it like they usually do: they somehow adopt the language, changing some things, adding a lot. In fact, adding exactly that lot that wasn’t in java for good reason, completely missing the point.
IronPython could be interesting.