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.
24 thoughts on “Remembering COM”
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)
WinRT is the new enhanced COM, and .NET now seems to be on life support.
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.
@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)
A somewhat different, and personal perspective can be found here where I describe a meeting with the COM folks in the early days.
This post reminds me of a classic article by good old Joel Spolsky
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.
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.
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).
COM is what we used to call a jump table, promoted to a “technology” by obfuscation like only Microsoft knows how!
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.
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.
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.
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.
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
WinRT doesn’t replace COM, it is COM (with a face lift).
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
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.
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!
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!
Did COM+ become .NET ?
COM can’t be dead – how else do you interract with Microsoft Office?
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:
* 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 Mozilla uses a variant as well, XPCOM
William Cook wrote:
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.”
Here is how COM (Component Object Model) can be explained to a lame guy .. http://complexiseasy.blogspot.in/
Microsoft with such beautiful technologies failed to reap the actual benefits out of it../