Towards a New Paradigm for C++ Program Development

about | archive


[ 2003-November-24 12:25 ]

This article on Advogato about changing the C++ development environment to make it nicer for the developer is interesting, if a little naive about compiler implementation details. However, the one idea which does make sense is to avoid recompilation when changing object interfaces. Right now, with C++, any time you change an object's members, all files which use that object must be recompiled. This is mostly because C++ implements low overhead objects, and each file must see the entire definition. However, I think a workaround is possible.

What if instead of including the header file, you imported the type? When you import a type, the compiler would automatically create a "pimpl", or a compiler firewall, proxy object. This object contains a pointer to the object, creates it in the constructor and frees it in the destructor. This proxy object would expose only the parts of the object's interface that is actually used in the file. This way, only the proxy object file would have to be recompiled each time the object changes. That would still be a lot of recompiling, as each proxy for each C++ file that imports the type would need to be recompiled, but each of these proxies would have a pretty simple representation.