4 ms·
The next version of C should redefine C as a strict subset of C++. That is, at any given moment, a particular revision of C should be a subset of a particular
by kasajian 4y ago
The next version of C should redefine C as a strict subset of C++. That is, at any given moment, a particular revision of C should be a subset of a particular revision of C++. Each new version of C++ would then cause a revision of C to be released.
- asveikau 4y agoThat would break pretty much every call to malloc, since C allows implicit cast from void* and C++ does not.
- layer8 4y agoThis wouldn’t be possible in an even remotely compatible fashion, due to C++’s name mangling, among many other reasons.
- optymizer 4y agoAs someone who writes C code and couldn't give a rat's ass about C++, I have to ask: why?
- cryptonector 4y agoCan't be done: it would break backwards compatibility. E.g., `struct foo` and `foo` are the same type in C++ automatically (as if `typedef struct foo foo`), but not in C.
- tsimionescu 4y agoIf anything, C++ could have decided to become a strict superset of C - they wouldn't even have to change too much and could do it without giving up backwards compat. C would have to change significantly to become a proper subset of C++, and pretty much no C program would still compile (because of int* c = malloc(sizeof int);).
- msla 4y agoEven if you're OK with breaking every call to malloc(), as the other poster said, plenty of C code has variables named things that clash with C++ reserved words, such as new, and, while it's possible for programming languages to simply not have reserved words, I think C++ implementation developers and programmers would rather avoid the kinds of things clever C++ programmers would come up with were those guide rails to be taken off. https://softwareengineering.stackexchange.com/questions/189699/what-non-theoretical-practical-programming-language-has-no-reserved-keywords https://softwareengineering.stackexchange.com/questions/1896... No reserved words in PL/I: https://www.ibm.com/docs/en/epfz/5.3?topic=sbcs-identifiers https://www.ibm.com/docs/en/epfz/5.3?topic=sbcs-identifiers > Identifiers can be PL/I keywords or programmer-defined names. Because PL/I can determine from the context if an identifier is a keyword, you can use any identifier as a programmer-defined name. There are no reserved words in PL/I. However, using some keywords, for example, IF or THEN, as variable names might make a program needlessly hard to understand.
- flohofwoe 4y agoPlease let's not bring all the design warts of C++ into C (instead only port the actually good ideas over, after they've been proven to be actually good ideas). It would make more sense if C++ would reverse direction and become a superset of C (like ObjC choose to do from the start), but for C++ it's much too late now.
- pjmlp 4y agoI would rather see C fully replaced by C++, as Microsoft was pushing for and sadly did an 180° turn on that. At least WG21 takes security more seriously.
- optymizer 4y agoJust replacing 'gcc' with 'g++' in my Makefile doubles or triples the compilation time. I wish people took developer experience more seriously.
- pjmlp 4y agoIf you told me that you were making use of templates I would have belived it. By the way, the C projects I used to work on 20 years ago, took an hour to compile, and it wasn't worse thanks to ClearMake sharing of object files. In any case, even if templates make C++ slower to compile, I would rather have slower builds than more opportunities to keep security researchers busy.
- mm007emko 4y agoI write C every now and then and couldn't care less about C++. So the question is why, what would be the benefit? Do you really think that everyone who use C uses C++ as well?