BartC said:
Using C would be the nearest thing to having a binary (ie.
language-neutral) interface. That's why it's important.
That's such a small part though. C can be used as a wrapper around C++ just
for that binary interface. Indeed, it is used like that a lot. DLLs, of
course. You snipped the rest of my post, but alluded to the merits of
"paltry C" being a boon to temper the zeal of programmers who go wild when
they have a bunch of features at their disposal. (But alas, a lot of C
programmers are Unix programmers and we all know what that means--functions
that are 3 pages long and have more branches than you can shake a stick at
and all the obscene things that can only be done "at the hardware level".
(And that's just the "Hello World!" program!)).
That was rhetorical. It was meant as a statement from someone who is already
using C++ but needs only the level of functionality that C provides. Again,
it's stable and old news--nothing to get excited about.
Suppose you're developing another language (Pascal for example, or
just ASM); making it talk with foreign functions and interfaces
specified in C is trivial, once you've figured out whether 'long' is
32 bits or 64. Dealing with a C++ interface (and all that COM and
DCOM stuff, whatever the hell that's all about) isn't.
The reason MS invented the COM stuff was because they *needed*
cross-language interaction--can't let B. Gates' pet VB die, you know. The
low-level interfacing you are talking about was decidedly at too low of a
level to meet the requirements at a more abstract level. Indeed, aren't all
the new languages these days loaded-up with "metadata" and "attributes" and
such so that the all-important "reflection" capabilities can be had? It
depends on what level of cross-language support you need. If all you need is
the capability to call a C function, fine. That's inter-library and
intra-program stuff. C doesn't have a thing to say about a higher level
cross-language capability. I don't think you want to limit yourself to just
that functionality though and thereby limit all the other possibilities. I
still create DLLs that use the C binary interface. They may be passing back
an interface pointer to a C++ object though! Which begs the question, "Is C
the interface, or the C++ object passed to the program the interface?".
It's a bit like the difference between using TXT format to create a
document (a human-readable format that can be read and written
universally), and having to use DOCX instead (a format so complex,
the specification needs nearly 5000 pages of documentation --
probably in DOCX format itself!).
Bad example, for *plain text* is one of those things that have been and are
still wrongly used. If you don't trust your computer software to make a text
document for you, maybe you should go back to pencil and paper.