4 ms·
C++ is my favourite programming language precisely because one of its main designers is so sensible.
by zabzonk 3y ago
C++ is my favourite programming language precisely because one of its main designers is so sensible.
- IshKebab 3y agoYeah mine too until Rust. But part of that sensibleness was making it backwards compatible with C, which entails a mountain of inherited design mistakes. I wonder what his blank slate language would have looked like.
- koolba 3y agoC++ is not backwards compatible with C. It’s mostly compatible, but it’s not completely compatible like say Objective C which is a strict superset of C.
- PH95VuimJjqBqy 3y agohonestly, no one cares about splitting that hair. Most valid C programs will compile in C++ and believe it or not, binary logic is not the only logic humans are capable of.
- zabzonk 3y agoactually, i reckon that most, if any, c programs will not compile with c++, without at least some (possibly not difficult) modifications
- latency-guy2 3y agoMy only qualms is the number of genuine C only compilers in use, vs number of embedded system companies/projects/codebases in the world. The subset of C features that are incompatible with C++ is quite small, and most of the features are a little out of the way IMO. Of the regular suspects (GCC, MSVC, Clang), your C codebase is probably entirely compatible with C++ as each of these has varying levels of compliance with the C and C++ standard.
- PH95VuimJjqBqy 3y ago> Of the regular suspects (GCC, MSVC, Clang), your C codebase is probably entirely compatible with C++ as each of these has varying levels of compliance with the C and C++ standard. yep, leave it up to the technical crowd to try and split hairs too fine.
- tsimionescu 3y agoAlmost every C program does `int *c = malloc(sizeof(int) *10)` or similar, which has always been invalid C++.
- fluoridation 3y agoI believe most compilers have switches to allow this. The real issue you might run into that can't be worked around easily is if the C source uses a C++ keyword as an identifier.
- kragen 3y ago#define new new_
- IshKebab 3y agoThey have diverged slightly in the years since C++ was introduced. But at the time the incompatibilities were extremely small. Even today they are pretty small and GCC/Clang will happily compile C constructs (e.g. designated initialisers, VLAs) with just a warning. Actually you need `-Wpedantic` to even get a warning for both of those. (And `-std=c++17` since designated initialisers are actually in C++20.)
- owlbite 3y ago...at least as long as you don't go anywhere near the atomic mess.
- deleted 3y ago[deleted]
- ordu 3y ago> C++ is not backwards compatible with C. Yeah, it is really ironic. C++ got all the warts of C to be compatible with it and then C++ had lost its compatibility with C but not warts.
- pjmlp 3y agoUntil C++98 came to be, nowadays, regardless of how sensible Bjarne Stroustoup happens to be, his opinion is a vote among 300 or so. Remember the Vasa paper happened for a reason.
- zabzonk 3y agoof course, but he is still very influential. better than languages that have no standard at all.