3 ms·
> There is a good language buried underneath C++ somewhere Well.. "C".. though I wouldn't go so far as to call that a good language, either.
by HappMacDonald 2mo ago
> There is a good language buried underneath C++ somewhere
Well.. "C".. though I wouldn't go so far as to call that a good language, either.
- badpun 2mo agoLack of support for type-safe containers (need to be hack toghether via macros) and overreliance on macros in general (which are not IDE and debugger friendly) are two aspects of C that are off-putting for majority of people in 2026. That's even assuming you're willing to forego pointer/memory safety.
- flohofwoe 2mo agoIndeed, picking C doesn't make sense when you actually want to write C++ code in C ;)
- wasmperson 2mo ago> Lack of support for type-safe containers (need to be hack toghether via macros) Are templates really so much better than macros that the latter deserve to be called a "hack"? The following two examples are both type-safe and have roughly the same semantics and #LoC: Macros: // pair.h struct id(pair) { T a, b; }; static inline struct id(pair) id(make_pair)(T a, T b){ return (struct id(pair)){ .a = a, .b = b }; } #undef id #undef T // main.c #include <stdio.h> #define T int #define id(n) n ## _int #include "pair.h" int main(void){ struct pair_int p = make_pair_int(12, 13); printf("%d %d\n", p.a, p.b); } Templates: //pair.h template<typename T> struct pair { T a, b; }; template<typename T> pair<T> make_pair(T a, T b){ return (pair<T>){ .a = a, .b = b }; } //main.cpp #include <stdio.h> #include "pair.h" int main(void){ pair<int> p = make_pair(12, 13); printf("%d %d\n", p.a, p.b); }
- YuechenLi 2mo agoWell, Carbon would have been better off if they just made "C with `match` and sane error handling" instead of whatever it is they are building there over at Google. But still, I think C and C++ are honestly very different languages at this point and that you can't really call C++ a superset of C at all really.
- aw1621107 2mo ago> Well, Carbon would have been better off if they just made "C with `match` and sane error handling" instead of whatever it is they are building there over at Google. Perhaps that might be a better language in a different context, but I don't think that language would have have been better for Google given their goals (e.g., bidirectional interop with C++, incremental automated migration, memory safety, etc.)
- neutronicus 2mo agoC++ at least rescues you from defining a million callbacks with a void* context argument that you then cast into whatever you know it actually is