Archive

Archive for February 21, 2012

VS2011: Bummer

February 21, 2012 1 comment

Apart from reading some hype about 2011 focusing on C++, I don’t really see much to be excited about in VS2011 so far. We’re running the game on Ubuntu now, and we’ve migrated development to 11.10, which means GCC 4.6. Even Intel’s C++ compiler has had excellent C++0x/C++11 support for over a year.

VS2011 is lagging horribly behind in C++11 support.

I’m fairly fond of some of the C++11 changes, in particular “enum class”, the use of (if not the name of) “auto” and “range based for”.

I’ll be very pleased when we can use the virtual function decorators, but really, I think code that has


class A {
virtual void foo() ;
};

class B {
void foo() ;
};

should be a compile error. From memory, this is allowed because of multiple-inheritance. If that’s true, fail, that is going to be a bug down the line so the language and compiler should reject it up front.

I’m still seething that C++11 is not going to give us discrete abstract-virtual classes. REMEMBER: Do NOT use the “i” word, it causes the C++ standards people to froth at the mouth or masturbate, I forget which.

It’s true, you can kinda implement interfaces in C++ already


class IWannaBeAnInterface {
void halt() = 0;
void catchFire() = 0;
};

Ooops, I forgot to make them public. Now, should I switch it to a struct or add an extra line?


// Since the point is not to have members, a struct feels weird.
struct IWannaBeAnInterface {
void halt() = 0;
void catchFire() = 0;
};

// Ok, a class feels more accurate, but remember to make stuff public.
class IWannaBeAnInterface {
public:
void halt() = 0 ;
public:
void catchFire() = 0 ;
} ;

// But I can also totally screw up by doing this:
class IWannaBeAnInterface {
private:
void halt() = 0 ;
protected:
void catchFire() = 0 ;
} ;

On the one hand, C++ has the most awesome template meta-programming system. On the other, it has a bunch of not-invented-here retards on the standards committee who won’t accept “interfaces” because Java did them.

Interfaces – pure virtual abstract classes – have countless reasons to exist: clarity of code (“this is an interface, not a struct or a class”), compiler code validation (“you can’t have private members of an interface”), virtual avoidance (“I want to describe an interface to this class hierarchy without having to expose all of the #includes, and without having to do a vtable lookup”), etc.

Well, those aren’t in the C++11 standard, so I can’t fault VS2011 for not including them, but I’m gonna skip 2011 because (a) it’s already 2021, (b) it doesn’t support near enough of C++11.

Follow

Get every new post delivered to your Inbox.

Join 183 other followers