Remembering COM

In the late ’90s I thought COM (Microsoft’s Component Object Model) was the way of the future. The whole architecture starting with the IUnknown interface was very elegant. And to hear Don Box explain it, COM was almost inevitable.

I was reminded of COM when I saw the slides for Kevlin Henney’s presentation Worse is better, for better or for worse. Henney quotes William Cook’s paper that has this to say about COM:

To me, the prohibition of inspecting the representation of other objects is one of the defining characteristics of object oriented programming.  …

One of the most pure object-oriented programming models yet defined is the Component Object Model (COM). It enforces all of these principles rigorously. Programming in COM is very flexible and powerful as a result.

And yet programming COM was painful. I wondered at the time why something so elegant in theory was so difficult in practice.  I have some ideas on this, but I haven’t thought through them enough to write them down.

Just as I was starting to grok COM, someone from Microsoft told me “COM is dead” and hinted at a whole new approach to software development that would be coming out of Microsoft, what we now call .NET.

COM had some good ideas, and some of these ideas have been reborn in WinRT. I’ve toyed with the idea of a blog post like “Lessons from COM,” but I doubt I’ll ever write that. This post is probably as close as I’ll get.

By the way, this post speaks of COM in the past tense as is conventional: we speak of technologies in the past tense, not when they disappear, but when they become unfashionable. Countless COM objects are running on countless machines, including on Mac and Unix systems, but COM has definitely fallen out of fashion.

More tech posts

24 thoughts on “Remembering COM

  1. I share your sentiment. The first time I thought I’ve understood OOP was when reading Don Box’s COM book. However, I never managed to get anything done productively with COM (partly because it was hard to get good information about deep technical topics, especially as a teenager without funds to buy expensive english books in germany)

  2. From a user point of view, COM gave us a huge loss of abstraction.

    I can think of all sorts of reasons why things worked out this way, but COM wound up being the sort of undocumented complexity that makes computer systems hard to use.

  3. @Josh Certainly the ASP.NET stack is very much alive and kicking. I agree that for the desktop the picture is confused at best (not least because MS seems unable to decide for more than a couple of years at a time which technology to back)

  4. A somewhat different, and personal perspective can be found here where I describe a meeting with the COM folks in the early days.

  5. I didn’t do very much COM programming, but I always got the impression was that the problem wasn’t COM, it was the half-baked interface hierarchies which people built on top of it, like ActiveX.

  6. The quote about COM that enforces all the principles is very bad. After all the COM bashing done by Microsoft when .NET was introduced everybody knows COM is not OOP thanks to the lack of inheritance.

  7. With Object Oriented Methods if you have to look past the operational signature of an object’s methods the design has failed on a number of counts.

    Nothing wrong with you OO programmers out there, COM is just a mediocre design (where design also includes publishing that which needs to be known to take the design through to implementation I.e. usable documention).

  8. COM is what we used to call a jump table, promoted to a “technology” by obfuscation like only Microsoft knows how!

  9. Peter E. C. Dashwood

    I have used COM for nearly 20years. I’ve used it from Javascript, from VB, from COBOL, and now from C#. I don’t see it as “complex”; I see it as a very elegant way to build component based systems.

    Personally, I really don’t care what’s fashionable, I care about what is useful and what works. COM components (in a number of different languages) all play nicely together on .NET and I’m in no rush to replace this technology. I have C# COM components that get called from COBOL and I have COBOL COM components that get called from C# and ASP.NET. Everything works because there is a consistent interface and the properties and methods are also implemented with consistency.

    I LOVE the ability to reuse components across platforms.

    Much of the so-called “complexity” can be abstracted by using templates and there is nothing difficult about writing COM components in most high level languages.

    I also heard the rumour that COM would be killed by .NET.

    I ignored it and I’m glad I did.


  10. Not only biological entities are subject to evolutional forces, so are technologies. No doubt COM will be extinct someday, since its model adds little. Its has week meta information, it is to closed and to complex. I like simple things like “POCO” or “plain old C functions” without all this new garbage.

  11. Not really true: if you want to write .Net code that interfaces with Office for example you are using COM to access it. Also lots of win API calls go through COM so if you want to do something that never made its way into .Net (at least yet) you’ll likely end up using COM.

  12. Com is great, I’ve been writing all my hardware interfaces (services and dlls) for years in ATL and MFC. Maybe i’m old school but Com is really the only reliable tool I’ve found for automation in MS environments.

  13. I think COM lost out to .NET, because of features that weren’t
    done well, and that .NET succeeded at in a better easier way.
    For example, take garbage collection, with .NET the garbage
    collection was all done for you, and things were all so easy. There was
    an expression, ah all have heard that garbage collection is so important, (I forget exactly) but take it from the programmer, give it to some sophisticated algorithm and better world arose. With .NET the namespace libraries rose up something easy to surf, COM typelibrary were cold and static in comparison. What’s up WinRT? It works all right and nicely at that but it’s distant for sure. Javascript works as well as as .NET, and is jitted away at compiler speeds, it’s changed like COM and .NET the newer algorithmic code arrived.

  14. WinRT doesn’t replace COM, it is COM (with a face lift).

    Javascript/CSS/HTML5 is the replacement for COM and everything else that was windows only.

    I have tons of code that uses COM and it will be maintained for a while. I’m writing new stuff with J/C/H

  15. The fact that you need 4.5 versions of .Net installed on your system to support C# in an effort to kill off C++ and COM speaks for itself. I think of Windows as a house built of COM Objects, all exposed to the development environment via Intellisense. I still code initially in VS6 and recompile the project in VS2012, especially services and COM objects, largely for the ATL support and the much better help systems.

  16. I still remember being on a customer’s site at 3am with a COM-based application failing with the legendary “Method ~ of object ~ Failed” or “ActiveX Component Can’t Create Object”.

    It did at least force me to become very familiar with SysInternals tools like RegMon!

  17. The notion that COM is dead is exactly that, a notion. COM, or more specifically IKnown is the root of ALL .Net objects, each and every one of them implements the IKnown vtable, which is why they all can be exposed to other languages as COM objects. As long as there is Microsoft Windows, there will be COM. Those that really understand COM, will be able to achieve what appears to be the impossible to those that don’t know COM. All in all, COM isn’t all that bad, just takes some time to learn how it really works. We are very blessed to have ATL/WTL, that is for sure!

  18. Hi everybody, I wrote the essay that was the original motivation for Kevlin’s talk. I always enjoy reading discussion about this stuff. Some points:
    * Object-oriented programming does NOT require inheritance. This is one of the big mistakes of early descriptions of OO. Inheritance is useful, but not essential. Just look at JavaScript and Go.
    * COM is very difficult to learn, but it is an amazing technology once you understand it. Large parts of Windows are (still) based on it. I haven’t studied RT but I have heard that it is based on the COM model.
    * Note that COM supports cross-language integration. This is one of the benefits of its high degree of abstraction. The fact that C, .NET, C++, VB and JavaScript can all interoperate is very useful.
    * Note that Mozilla uses a variant as well, XPCOM

  19. William Cook wrote:

    * Object-oriented programming does NOT require inheritance. This is one of the big mistakes of early descriptions of OO. Inheritance is useful, but not essential.

    Absolutely, I would add that there is a lot of confusion out there about the differences between inheritance of implementation vs. type definition by inheritance.

    Smalltalk started with no inheritance. and then added implementation inheritance.
    It also uses class inheritance strictly as an implementation sharing mechanism, with methods like should_not_implement used in a hierarchy which clearly contradicts the notion of class hierarchy as type hierarchy.

    Of course your PhD advisor probably did more than most in propagating that “big mistake.”

Comments are closed.