David Greene <greened@eecs.umich.edu> wrote: > > No argument here, but why _wouldn't_ one use an OO language for such > designs? That's what they're there for! Indeed, and if there's an OO language available (even C++), it's preferable to C in most cases. > I've heard this often, but I submit that without the C compatability, C++ > would have failed. And it cleans up C enough to be at least passable. I'm not going to argue that C++ would have been successful without the C compatibility. I think that's a big reason why it has been so successful. But I also think it's one of the biggest (maybe even *the* biggest) shortcomings of the language. > Note that one can avoid this by using abstract base classes, > implementation classes and multiple inheritence. Or one can use > composition to keep a pointer to the implementation object, etc. Yes, these techniques sometimes help, but they increase the complexity of your interfaces substantially, increase maintenance, etc. They're all nasty hacks, just like simulating OO using C. Except harder. :) And in any case, they can *still* be circumvented by obtaining pointers to implementation objects and bypassing the compiler checks on various things. Granted, that's rather difficult, but it's still possible. > I'd rather have that and the zero-overhead rule than something that > forces me to use somebody's idea of the "right" design. The zero overhead rule bugs the crap out of me. How can you call a piece of memory an object, if that piece of memory carries no information about what it really is? It's not really an object, it's just a piece of memory that the compiler knows (at compile time, not run time) to treat like an object. It's not special in any way. -- Sam Couter | Internet Engineer | http://www.topic.com.au/ sam@topic.com.au | tSA Consulting | OpenPGP key available on key servers OpenPGP fingerprint: A46B 9BB5 3148 7BEA 1F05 5BD5 8530 03AE DE89 C75C
Attachment:
pgpFvNRHQQkr6.pgp
Description: PGP signature