Re: variants of oo: why!?!? you can do better with less effort with C++, and even if you don't like anything C++ can offer, you can still better do what you're suggesting, manually with C++, than with C. C is simply not equipped enough, why torture oneself?
Re: organization, letter "C" is completely superfluous there and can be substituted by some other word, even Java.
c is perfectly well equipped. try it one day. and why? 900,000 lines of code already were in c... and MOVING to C++ not only would have pissed off a lot of devs, it would enforce an API and ABI change that requires c++ and for libraries that required portability and ABI stability, that would be a poor choice. not to mention that C++ does NOT offer what we want. that means removal of direct pointer access at all and moving the ABI to use indirect ID's, lookups in tables and then minimizing the lookup overhead with batching (so you do 1 lookup for 5 calls rather than 1 lookup per method). in C++ we'd simply implement the same tiny api, override object typed to be void * anyway (and for compatibility we effectively deal with the types as void * anyway as the oo api/abi is being slid underneath an existing C api that has grown over the years across a dozen shared libraries etc.)
I work with C code day in day out, don't you worry.
and MOVING to C++ ... would enforce (emphasis mine) an API and ABI change that requires c++ and for libraries that required portability and ABI stability, that would be a poor choice.
That's a lie. First of, there's no portability whatsoever in C language itself. What you call portability here is cooperation between C language implementations on a given platform.
Second, moving to C++ in no way must enforce changes. If you actually think it does (and are not exaggerating to make a point), you have no idea what you're talking about, and if you're exaggerating, then
exaggeration is a poor argument anyhow
I am doing C++ code that only offers C interface for C-only code. Works a treat, and I am not alone
The rest of your post doesn't make enough sense without further explanation, but I can tell you that I know, in advance, that you're wrong with where you're going there.
if you want t split hairs about c vs the platform abi it is bound to then go right ahead. 99.9% of the world doesn't care about the hair splitting. the platform abi implementation and c are bound to effectively be one and the same. the calling conventions are the same.
if you move to c++ without using it at the api level... then there just is no point, so using c++ and then... not using it is just a nice way to obfuscate your build process and slow it down. the USEFUL bit for c++ would be at the api level... not just internally.
i can tell you in advance.. that i know the code in question, and you do not. i know its usage patterns and you do not. i know that c++ would not be as nice and useful as what we have rolled in c, and if you rolled something similar in c++ you'd just implment the same thing "with classes" and at that point... it's pointless as its just a c++ syntax version o the c, now with slower compile times. yay!
a host of other languages call into your "C platform ABI" without ever mentioning any C. People have been doing this for years, and are still doing it. Letter "C" there is practical, but ultimately incidental. You can call this splitting hairs, but that's one pretty hefty hair there.
if you move to c++ without using it at the api level... then there just is no point
I presume you mean "public API"... Point exists, it's just that you fail to see it.
i know the code in question, and you do not. i know its usage patterns and you do not. i know that c++ would not be as nice and useful as what we have rolled in c
And I can tell you that I could take your code and rewrite in C++, without changing it's API, without impacting it's performance or memory consumption and even without significantly impacting compile times. I've done it before, I could do it with your code.
I don't care that you now think I am an uptight ass. I know what I am doing, and if judging your argument here is representative of your actual knowledge, I know these things better than you do.
the c api means you expose the symbols and calling conventions the platform way. if you are declaring apis with a c wrapper - then it its not a c++ api. (eg to avoid mangling). so the platform and c abu are the same thing for anyone that cares. you may prefix with cdecl or with stdcall on platform i dont care about, but the ones i do, there is no need to do this. it "just works".
as for public api moving to c++ - pointless as it'd be a single class with an insanely few # of methods... so if ALL we did was make the object core c++ then we'd pay the overhead of a c++ compile time just do have an insanely simple c like set of methods, since our actual methods are more protocol dispatch done by a single "do" method. this allows us to remove the pointer entirely as a pointer and indirect it safely and nicely without breaking api or abi as the older c apis are just a wrapper on to of this, and you can drop right down to it without any casting or compiler unhapiness.
and wait... REWRITE the libraries in c++? you REALLY dont know what you are talking about. didn't you read that there's something not far shy of a million lines of code there? you are nuts if u think it makes sense to rewrite it in c++. not to mention that it would only end up recycling the minimal single class and so method thing... so its pointless, you'd take our compile times from 5 mins to more like 30, and for what benefit? all the effort to retool the build system, change language, compiler, add extra language complexity just to do what is already a very simple thing to do in c? if you want to rewrite it all for us for free then go for it, be our guest, but you're nuts if you think we are going to go to all that effort for zero gain.
what you are is beating your c++ drum where it just is not a valid solution. that has been the whole point of this. c++ is not always the best solution. sure for a c++ fan it may be, but believe it or not, i know what i'm doing too, and the only thing c++ would do is add to our build times and create maintenance and suport issues (libstdc++... yay extra happy fun times).
the c api means you expose the symbols and calling conventions the platform way. if you are declaring apis with a c wrapper - then it its not a c++ api.
OK, but where did I say that I want a C++ API for anything? You're arguing with your poor understanding of what I am trying to say here.
as for public api moving to c++ - pointless as it'd be a single class with an insanely few # of methods...
So your C api is one big blob of functions!? No internal structure to them, however informal!? That never happens. Show me any significant C API, and I'll show you internal structure. Case in point: is the CRT one big blob of functions? Not in the slightest. E.g. fopen, fread, fwrite, fclose go togeteher. FILE* and it's operations are "a class", if you will.
and wait... REWRITE the libraries in c++?...
I didn't say that I want to do it, and I didn't say that this is a good idea in your (or any other case). I did say, however, that I could do it (and further, that I could do better than what you currently have, merely through judicious use of a superior language facilities). And that, based on previous experience.
1
u/Gotebe Feb 27 '13
Re: variants of oo: why!?!? you can do better with less effort with C++, and even if you don't like anything C++ can offer, you can still better do what you're suggesting, manually with C++, than with C. C is simply not equipped enough, why torture oneself?
Re: organization, letter "C" is completely superfluous there and can be substituted by some other word, even Java.