4 ms·
That’s your choice of C++ subset, but the problem with these huge languages is that everyone chooses a different subset to use. Sticking to plain C has the adv
by pansa2 6y ago
That’s your choice of C++ subset, but the problem with these huge languages is that everyone chooses a different subset to use.
Sticking to plain C has the advantage of probably being the subset of C++ (I know, it’s not technically a subset) that’s in widest use.
- krychu 6y agoI’d add that deciding on the subset is a high cost operation. Design of such a smaller subset-language will likely not be on par with language that is small by design.
- taneq 6y ago> (I know, it’s not technically a subset) Is it not? I thought C++ was explicitly a strict superset of C?
- einpoklum 6y agoSyntactically, it almost was; and even this is no longer true today with C11 and later, More importantly, though - the syntax is not what matters. The languages are very very different in idiomatic use. You just don't write programs the same way with C and with C++. And the gulf between the two only expands with time. A decent C program is almost certainly a poor C++ program, in terms of idioms, utilization of library facilities, and sometimes even in terms of performance (!).
- janoc 6y agoIt is not and never was. Look at for ex. what const means in each, or auto. Or variable length arrays (feature that doesn't exit in C++). Or designated initializers that C++ didn't have for a long time. Here is a good list of differences: https://mcla.ug/blog/cpp-is-not-a-superset-of-c.html https://mcla.ug/blog/cpp-is-not-a-superset-of-c.html
- gmueckl 6y agoC++ is almost a perfect superset of old C before C99. There are odd corner cases where prograns are parsed differently, but these are quite contrived. The 3rd edition of The C++ Programming language lists a few cases. Since then, C has had may additions to the language that made it diverge from C++. Your linked article is almost entirely about these new C additions.
- janoc 6y agoEven for the old C it wasn't a superset. There are plenty of legal C programs that aren't legal C++ - if for nothing else, then because C++ has more reserved keywords which are perfectly legal identifier names in C. E.g. this is legal C but not legal C++: int template = 10;
- gus_massa 6y ago> everyone chooses a different subset to use I prefer using C++ like "C but with cin and cout" and I informally call it C+ :)