COM

Started by
3 comments, last by freddyscoming4you 12 years, 8 months ago
Does anyone know of any good resources that explain COM and how it is used today? I gather that .NET does a much better job of what COM was designed to do (making code reusable, as well as language independent), but I also notice that .net itself uses a lot of existing COM interfaces. Is this because

a) The code is written in C/C++ and is generally going to be faster?
b) The code already exists, why re-write?
c) a mix of both?

What are the downsides of COM?

From some brief reading, the idea of COM is that you can leverage on existing code bases to perform some task in a multitude of COM conformant languages (as they have to have the necessary interop code to convert data to and from COM, to something the language itself can read a result from). Which is the same idea as non .net languages having a .net port?

There are a few books on Amazon, from the 90's, are they still worth picking up? Im interested in how COM is implemented under the hood, and how other languages would adopt the functionality of being able to use COM objects.



Advertisement
Two books you may interesting in,

Essential COM
Inside COM

Even if you never program on Windows and COM, learning some COM knowledge is quite useful if you want to develop binary compatible APIs in C++.
One fact in COM I really like is the pure interface communication, which is binary compatible and highly abstraction.

https://www.kbasm.com -- My personal website

https://github.com/wqking/eventpp  eventpp -- C++ library for event dispatcher and callback list

https://github.com/cpgf/cpgf  cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.


Does anyone know of any good resources that explain COM and how it is used today? I gather that .NET does a much better job of what COM was designed to do (making code reusable, as well as language independent), but I also notice that .net itself uses a lot of existing COM interfaces. Is this because

a) The code is written in C/C++ and is generally going to be faster?
b) The code already exists, why re-write?
c) a mix of both?

What are the downsides of COM?

From some brief reading, the idea of COM is that you can leverage on existing code bases to perform some task in a multitude of COM conformant languages (as they have to have the necessary interop code to convert data to and from COM, to something the language itself can read a result from). Which is the same idea as non .net languages having a .net port?

There are a few books on Amazon, from the 90's, are they still worth picking up? Im interested in how COM is implemented under the hood, and how other languages would adopt the functionality of being able to use COM objects.


One reason .NET uses existing COM objects is that .NET itself is managed and can't talk directly to hardware. Also, the decision to tie .NET to COM is that it was meant to make Windows development quicker and easier and it's just natural to use the existing Windows COM environment rather than rewriting code to interact with the Windows environment. So, to answer your question it's a mix of both. The main downside to COM is what's called DLL hell. With all the interconnectedness of the COM environment it can be hard to debug issues as the problem might not lie within any of your code. That said COM is excellent as it makes combining and mixing functionality very easy. COM itself is very easy to use though it can be somewhat interesting to implement given your language. Thankfully in .NET you can just tag a method as belonging to a DLL and the CLR takes care of the rest.

Is there a more specific answer you're looking for?
#2 is the majority reason. Many things already exist as COM components and are well tested. Many of them are also very old in computing terms (so nobody's around to work on them).


What are the downsides of COM?


Other than it sucks?

It suffers from many of the issues you'd find in a dynamic language, if that language didn't have any of the safeguards or utilities to make it usable. You get some random unknown object, get to jump through some hoops, and assuming all of the stars align (and the API writer wasn't purposefully trying to exploit your machine) then you can dynamically do stuff.


.NET was designed with lessons learned, and basically supports the same behavior in a cleaner, typesafe, enforceable manner.
I wouldn't say it sucks. COM itself is fine but people who write COM objects don't always have a large team or QA processes to ensure they do things right so individual DLLs can be a bit wonky.

This topic is closed to new replies.

Advertisement