logoalt Hacker News

Dwedityesterday at 2:29 PM6 repliesview on HN

C++ ABIs are why Win32 settled on things like COM to do cross-module passing of objects. Because nobody could agree on a standard, the COM standard enforced a very specific calling convention, and a very specific vtable layout for COM objects.


Replies

pjmlpyesterday at 2:49 PM

Not only, there is also XPC and IO/DriverKit on Apple, Android IPC, D-BUS, FIDL on Fucshia,....

Also C ABI also does not exist, people keep mistaking the ABI of their favourite C compiler with the OS ABI, which only overlap if the OS was written in C to start with.

For example on mainframes and micros, naturally not written in C, it is either a bytecode based ABI like TIMI on IBM i, or language environments like on z/OS, ClearPath MCP, OS 2200 and so forth.

And as a reminder, from a famous WG14 and WG21 member, and former Rust contributor,

"To Save C, We Must Save ABI"

https://thephd.dev/to-save-c-we-must-save-abi-fixing-c-funct...

show 2 replies
vintagedaveyesterday at 4:24 PM

And Delphi came along and used the same layout, so an interfaced Delphi object has beautiful COM interop.

show 1 reply
WalterBrightyesterday at 4:22 PM

> and a very specific vtable layout for COM objects

Fun fact: Microsoft developed COM based on how Zortech C++ virtual functions worked. (It predated Microsoft C++ by years.)

show 1 reply
quotemstryesterday at 3:39 PM

And COM enforces lifecycle rules, transparent remoting, uniform activation (constructors basically), security primitives, marshalling, transparent async calls (yes, you can call any method asynchronously), and a ton of other things. It's actually very good and it's a shame most don't know about it and most of the rest sneer at it.

show 3 replies
rramadassyesterday at 3:32 PM

COM designers were inspired by C++ but their goals were different. They were designing a language-neutral binary standard (aka ABI) and hence took C++'s approach and tweaked it for their specification.

Here is an earlier comment of mine with some details - https://news.ycombinator.com/item?id=49142987

mohamedkoubaayesterday at 3:12 PM

Given OOP, the only ABI for an object is a vtable and that is left unspecified (for good reason) by the C++ standard.

COM said, "objects are cool and modules are cool so we need an ABI for objects" and specified a vtable. It isn't the only programming model which continued from the same observation: Python did too with its absolutely abysmal leaky PyObject ABI

show 1 reply