What COM(component object model) aimed at?

I sometimes think about what windows c++ library technique, COM(component object model), designed and implemented for?

Of course, I understand its importance. My question is, "Was it enough to use simple C++ class API which is turned into shared library(dll) rather than COM?".

COM is complex in that they is identified by GUID, or construction mechanism, etc.
(1) are these specifications necessary to utilize the library in different languages(VBA etc)?
(2) their design (construction,polymorphism) seems so similar to something in design patterns in GoF. Is COM simply a standard of object oriented programming?
Last edited on
Was it enough to use simple C++ class API which is turned into shared library(dll) rather than COM?
No.

COM is the underlying technology used in a method of getting Windows Apps to share. "Share what?", I hear you ask? The whole app.

Back in the early 90s Bill Gates famously demonstrated Word and Excel sharing content. The company eventually completed an implementation of that demo using, what they called, Object Linking and Embedding.

Sharing data was done; DDE. What they wanted was to put an application object into another application and have both run simultaneously on a non-preemptive OS (WIN16). Bonkers right? But they kinda did it.

COM fell out of that as an underlying technology, and was only visible when it turned out that OLE2 wasn't going anywhere. It was way too complex for mortals. So COM became the packaging technology, not Apps with menus and all that crap.

C++ was in its infancy, and Microsoft were very late to implement a usable C++ compiler. In fact, they never produced a C++ compiler for WIN16 or DOS that supported templates.

are these specifications necessary to utilize the library in different languages(VBA etc)?
Yes. A Globally Unique Identifier is essential, however it's constructed/formatted.

their design (construction,polymorphism) seems so similar to something in design patterns in GoF. Is COM simply a standard of object oriented programming?
No. COM uses a constrained object model based on composition; polymorphism isn't supported.

Finally, COM is a the basic technology for packaging reusable objects. A comparable technology is CORBA.
Last edited on
"Was it enough to use simple C++ class API which is turned into shared library(dll) rather than COM?"

You got the answer from kbw, but I just want to add some fundamentals in line with your question, in simple terms, that C++ programming for windows is impossible without COM.
for example a lot of DirectX, WIC, Direct Write and similar API's are based on COM.

So saying to program for windows with only C++ (or C) isn't impossible, but you would be very limited on what you can actually do.

COM is language neutral, that is not tied to specific language, it can be (re) used by VB, .NET, C++ etc..

Think of a COM as of some library like boost or standard library, without which you are limited on what you can do by just using C++.

except that unlike boost or std which is cross platform library, COM is cross language "library".

Is COM simply a standard of object oriented programming?
Not really, but you can derive your C++ classes from classes/structs based on COM.
Which means you'll get full polymorphism.

But the COM it self doesn't support polymorphism since behavior of polymorphism is private to each language, each language defines polymorphism differently, otherwise COM wouldn't be cross language.
Last edited on
Dear kbw & malibor

Thank you so much for your detailed & historical explanations.

I a bit understand that COM is the fundamental in Windows programming, and general application binary interface(ABI) in interoperation between various languages & applications.

Here, I wonder if some related questions come about, if you know, I would appreciate it if you could teach me.

(1) How is the object shared?
Different applications belong to different processes, which indicates they have different memory spaces. The instance of COM is how to be allocated and shared? (The first application(process) which created COM object? or file/storage? or, some shared memory space?)

(2) Is there arbitrary-OS libraries similar to COM?
The functionality of COM seems very suitable to Windows programming which is recommended to use interoperations between various languages(VB, C#, C++ etc).
However, I suppose that such a functionality is also needed in other OS (Linux etc). I have ever not seen such a library.
Is there similar library, or is it difficult to construct OS-independent library?

Kind regards

Last edited on
(1) How is the object shared?
Think of these distinct cases of calling a function.
1. The code is in a DLL.
You have to load the library, find the function's address, pass the parameters, make the call, pass the return values back.

2. The code is in another process.
You have to find the process, find the function you want call, send the parameters, execute the call, pass the return values back.

3. The code is in another process on another computer.
You have to find the computer, connect to it, then do all the stuff for scenario 2.

The COM interface is general enough (and complicated enough) to provide a single mechanism for doing all 3, the latter being called DCOM.

The object is accessed thru methods, only. So whether it's actually in process, or external, or remote is transparent. But, COM allows either.

(2) Is there arbitrary-OS libraries similar to COM?
Yes. As I said earlier, CORBA.

Well, COM is Microsoft's baby. (Happily) no one else cares. CORBA was born on Unix and used in modern times in Java environments.

Both of these technologies are based on RPC (DEC's Remote Procedure Call). In the age of the internet, we can do better.

Have you ever wondered why Windows computers are always more highly specified (more memory, faster disks) than the equivalent Linux ones for doing the same job, even though ALL PC hardware is designed to run under Windows? Similarly, the equivalent Macs always have less memory for the same performance.
Last edited on
Dear kbw,

Thank you for your always detailed reply.
I got a point.


>>Have you ever wondered why Windows computers are always more highly specified (more memory, faster disks) than the equivalent Linux ones for doing the same job, even though ALL PC hardware is designed to run under Windows? Similarly, the equivalent Macs always have less memory for the same performance.

I sometimes wonder what you pointed out. Is the reason because COM objects work badly in background, as I guessed in your context?

Previously, I had no other choice to use C++/CX, which is new Windows C++ specification language for WinRT. This language explicitly handles COM objects. In that time, I understood that rapid application (real-time speed necessary Mobile Apps in Windows Tablet etc) must use COM objects efficiently. Is it not the reason utilization of COM is rapid application? Just for use of various fundamental functions in Windows system?
Last edited on
Performance isn't specifically caused by COM, but COM is a product of thinking that's led to this problem.
Topic archived. No new replies allowed.