3 ms·
Why C as opposed to C++? I'd love to know because my current understanding is that C++ has the same performance as C, but includes the STL which prevents you f
by fossuser 14y ago
Why C as opposed to C++?
I'd love to know because my current understanding is that C++ has the same performance as C, but includes the STL which prevents you from having to reimplement more convenient data structures that handle memory nicely (like vectors) yourself.
The ability to create classes/objects is nice too and the language doesn't take away any of the freedom you're given in C either.
Am I missing something about it? Is it just more familiarity with the older language that makes it more comfortable?
- wglb 14y agoFor the same code, C++ is generally measurably slower. One reason is how exceptions, which are not optional, are handled at run time. Having written some seriously high-throughput low-latency code in C++, you have to turn on bunches of compile flags (e.g., ignore exceptions) to get the best out of it.
- ibisum 14y ago""Am I missing something about it? Is it just more familiarity with the older language that makes it more comfortable?"" Yes, I would say - you did miss something. C++ does come with the STL, and "saves you" from having to bring-your-own/be responsible for a package of well-tested basics, it is true. But, then again, if you have been coding C long enough, probably there is a lot of code you've got in your suite that represents powers beyond the STL. I've got a small hashlib/assoc-array header or two which, fundamentally, has been all I've needed to write performant code on whatever subject my applications are addressing. I agree that there should be a 'layer' by which programmers are protected from systems-level thinking, but then again I think in this day and age, it is a good thing to delete cruft, effective C management (i.e. you know your libs because you also wrote them, and so on..) allows for very nicely maintainable code. Even in this day and age of "point phone at t-shirt to install web 2.x.x" style deployment, I am glad to have good C chops. Still.