Unhinged Ramblings.

The Description. It describes. A blog. My blog. I blog. Here.

Wednesday, June 27, 2007

Things I wish c++ could do.

I feel that the new c++ spec was largley a waste of time. When it was released I was filled with hope. The interveneing 10 years have made me bitter, very bitter. Instead of wasting their time on the acedemic improvement of the language, they could have spent some time giving use "useful" features.

1. functions as variables. Scripting languages like lua have it made. functions are treated as first class variables and can be freely reassigned and passed around. c++ has function pointers, but you just cant do the kind of stuff that you can when all function names are implicitly function pointers!

2. The ability to assign 'this'
this = (CMySelf*)pvParam;
Good grief. Static class members are one thing, but please let us actually assign the this pointer when we figure it out, and subsequently access class members.

3. forward inheritance of pure virtual methods.
Templates were an ok idea I guess and allow some neat generic ADT classes to be built. I dont belive they are the right solution for the problem of how to provide a base class that implements IUnknown.

All I want is a nice, non template based syntax, that lets me say

class CUnknownImpl : public IUnknown;
class CDispatchImpl : public CUnknownImpl, public IDispatch;

without the compiler getting all snarky about IDispatches' IUnknown methods being pure virtual when I clearly have provided #*%&ing implementation!

4. Writable vtables.
Why are vtables the only unwritable members of a class? This goes hand in hand with point #1. Virtual functions should be first class variables. Do all the method signature checking needed, but the ability to directly manipulate which implementation a particular vtable member points to at runtime would be damn sweet and save a lot of redundant framework effort.

5. Who screwed up void**?
In C, a pointer to a pointer to something can implicitly be converted to a void**. In c++ we have to have an explicit cast. What safety has been added by this requirement? Now, every call to QueryInterface needs a (void**)&pInterface. C has the type safety advantage here as it can at least check you have the correct level of indirection.

I am a fossil.

Once, long ago, I was into new stuff. I always made sure to have the latest and greatest of whatever Microsoft was releasing as soon as it hit pre-alpha. Via whatever nefarious means I could. Hell - I was a student. Lets not pretend I ever paid for anything.

Now, I find myself avoiding .NET, avoiding C#, avoiding XML. Screw it, I am avoiding C++ and thats what I do. The new c++ that is. The one with the templates and new fangled casts and far too many <>'s. C++ in my mind is not meand to have <>'s. Anywhere. Ever. That kind of crap is for XML, and I avoid that like the plague.

Labels: ,