24 Sep 2003 mrorganic   » (Journeyer)

Something deeply weird is going on with Advogato today: I tried to post a diary entry, my browser "went away" for a number of minutes, and them Advogato advises me that the site seems to be broken. I look at the current diary entry list, and my name is there -- but no diary entry!



COM is only "easy" in IDEs like Delphi and VB because an enourmous amount of effort has gone into making wrappers and wizards to take the burden off the programmer. And still the essential defects of COM remain: it's about the poor design of COM.

Think for a moment about the humble BSTR, COM's string structure. It's basically a length-prefixed wide-character array. This was done to make brain-dead clients like Visual Basic happy, but at the expense of breaking C/C++, which considers a "string" to be a vector of characters (narrow or wide) terminated by a NULL. And this picture is further complicated by the fact that the OLECHAR* type in C++ is often used synonymously with the BSTR, when in fact they're very different (OLECHAR* values are not length-prefixed). But the COM APIs (being poorly designed) cannot really tell the difference between an OLECHAR* value and a BSTR.

In C++ especially, you run into all kinds of initialization/assignment issues, as well as heap/stack problems, due to the muddiness of the OLECHAR*/BSTR distinction.

This is a core design flaw in COM. C/C++ are the primary COM languages (through ATL), and yet Microsoft crippled a core data structure to support weaker clients! (And don't even get me started on the horrendously-cruddy SAFEARRAY and related API).

When you say COM is simple, you're only partly correct. In concept, yes, COM is simple. But in practice, it rapidly degrades into the stinking mess you see today because the design flaws are right at the center of what COM is: BSTRs, SAFEARRAYS, and the standard marshaller.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!