2 ms·
Dynamic arrays, hash tables, threads: C++ doesn't have those either as language constructs, they are only implemented in the standard library. Namespaces: pref
by flohofwoe 6y ago
Dynamic arrays, hash tables, threads: C++ doesn't have those either as language constructs, they are only implemented in the standard library.
Namespaces: prefixes work just fine in C and don't require name mangling.
RAII makes no sense with C's concept of "dumb data" instead of C++'s "smart objects".
- maccard 6y agoWhether it's part of the language or the standard library is arguing semantics; Support for type safe dynamic arrays is something that C++ has that C doesn't, is widely used, and poorly reomplemented in C using macros (if you're lucky). >Namespaces: prefixes work just fine in C and don't require name mangling. This is a perfect example of a feature that solves a problem that C has (global namespace pollution). Prefixing is a bandaid, and a nasty one at that. Everyone loves #define NOMINMAX in the windows headers, and prefixing all their code with a faux namespace, dirtying _all_ of the code. > RAII makes no sense with C's concept of "dumb data" instead of C++'s "smart objects". Sure it does. Every call to fopen should be paired with a call to fclose, every malloc with a free. RAII practically eliminates a whole category of issues around resource leaks; in over a decade of writing C++ professionally, almost every instance of a memory leak, stomp or resource leak was someone trying to be "clever" and drop down to more C style code.
- ogoffart 6y agoWhy do namespaces require name mangling? One could imagine just using :: in the symbol name. Anyway, even C has name mangling: For example, on Windows, all C symbols gets prefixed by an underscore https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/name-decoration?redirectedfrom=MSDN&view=msvc-160 https://docs.microsoft.com/en-us/cpp/error-messages/tool-err... And even on macOS there is something about having symbols starting with \1