Non-fragile ABI in D?

One shortcoming of the D programming language comes from its C++ roots. In C++, whenever you add, change or remove a virtual method or a variable as a member of a class or struct, you’re probably breaking binary compatibility and must recompile everything depending on that. That makes C++ a bad choice for publishing public APIs when you expect binary compatibility.

The fragile binary interface problem (as Wikipedia calls it) is not new. As a OS written entirely in C++, BeOS has been “bitten” by it in the last decade and suggests some guidelines to alleviate that problem. But following those guidelines adds clutter in the code, forces you to be extra careful when changing a class, and some suggestions are downright impossible in D: for instance, you can’t have private virtual functions in D (something I disagree with, but that’s another subject).

As the Wikipedia entry suggests, a better approach is to use a language that does not have the problem. Or, I should say, change an existing language so it does no longer have that problem.

I’d certainly like to see D gain a non-fragile ABI for classes. I’ll explore this and other subjects in a couple of posts about the D language I’m preparing.

  • © 2003–2019 Michel Fortin.