On Tuesday, 21 August 2012 at 15:15:02 UTC, David Piepgrass wrote:
On Monday, 20 August 2012 at 18:37:00 UTC, R Grocott wrote:
On Monday, 20 August 2012 at 15:26:48 UTC, Kagamin wrote:
What you ask for sounds quite similar to COM composition with
delegation.
Would anybody mind linking to resources which describe COM
composition with delegation? It's been suggested twice in this
thread as an alternative way to develop a non-fragile API, but
anything related to COM is almost invisible to search engines
(even moreso than D itself).
There's nothing novel about COM except aggregation, and
aggregation is just an implementation detail where a class
pretends that it implements an interface but the calls to that
interface go to another object, conceptually it's like "alias
this" except that a dynamic cast (i.e. QueryInterface) is
required to reach the second object:
http://msdn.microsoft.com/en-us/library/ms686558(v=vs.85)
For the most part COM sucks really bad: it is a very ordinary
object-oriented ABI but without numerous features that we
otherwise take for granted:
- In COM, you can't define static methods
- In COM, you can't overload functions
- In COM, constructors can't have arguments
- In COM, there are no fields, only properties
- In COM, class inheritance is not allowed (an interface IB can
inherit from IA, but if you implement a class A that implements
IA, you can't write a class B that derives from A and
implements IB. In C++/ATL a template-based workaround is
possible if A and B are in the same DLL.)
Moreover COM ABIs are fragile, in that there is almost zero
support for adding or removing methods without either breaking
everything or creating a new, independent, incompatible version
(the only exception: you can safely add a method at the end of
an interface, if you can be certain that no other interface
inherits from it.)
Finally, it's Windows-only (although it has been reimplemented
on Linux, e.g. for WINE) and modules must be registered in the
Windows Registry.
I think the only reason we still use COM today is that, sadly,
there is no other OO standard interoperable with all languages.
C++ vtables are the closest competitor; I guess their fatal
flaw is that there is no standard for memory management across
C++ DLLs.
Even .NET with his goal of supporting multiple languages has the
CLS as the common set of datatypes and OO concepts to support
across .NET
languages.
Given that OO has so many types of possible implementations, it is
hard to implement an ABI that works across multiple languages.
Lets see how the improved COM (WinRT) turns out to be.
--
Paulo