4 ms·
If C++ had just treated C from the start, it would have been much cleaner, and nobody would have used it. Humans are stupid, short-sighted creatures, and progr
by loup-vaillant 5y ago
If C++ had just treated C from the start, it would have been much cleaner, and nobody would have used it.
Humans are stupid, short-sighted creatures, and programmers are no exception. The only way to get C programmers to use C++ was to make C-with-classes a drop-in replacement for C. Replace "cc" by "CC" in your build system, and you magically get new features, without breaking old code (at least not too much). Sure it crippled C++ from the start.
If C++ had stopped at binary compatibility (either with an FFI like Rust or Zig, or by deciding on a subset that can talk to C interfaces), it would have forced users to use two compilers, as well as learn an entire new language. Few people would have been willing to put in the work, Stroustrup knew this, and he wanted his language to be useful now.
And now we have this mess.
- pjmlp 5y agoThe best way to put it for modern generations is that C++ was "TypeScript" for C, with all the plus and minus that it entails.
- loup-vaillant 5y agoIf only. For all the "moar strong types" goodness C++ claimed, in practice there was very little. The same could have been achieved with stricter warnings, that C compilers now have. With TypeScript at least you have the option to go from full dynamic typing auto cast madness to meaningful compile time checks. That being said, if I had to write a serious web app today (that is, something that absolutely requires client-side scripting), I would consider using JavaScript as a compilation target only, alongside WebAssembly.
- galangalalgol 5y agoWill wasm ever get direct access to the dom so that isn't needed? I keep wanting to jump into wasm, but I don't really want to learn any more javascript than I already know, which is just enough to play codespells and screeps. And I certainly don't want to learn a framework which seems to follow the madden nfl release schedule.
- loup-vaillant 5y agoIdeally I wouldn't learn a single thing about JavaScript, and go straight to WebAssembly. Possibly chose a language that already has a compiler for both so I don't even have to learn the standard. And no framework either, I'd do my own things with as few dependencies as I can possibly manage. No point tying myself to some protean monstrosity that breaks code every 6 months and is abandoned 5 years later. (OK, not a web dev, so I don't know about that last one. It's just what I glean from the web's reputation.)
- pjmlp 5y agoThe compilers might have them, yet the large majority doesn't care they exist. Unless devops plugs them into the CI/CD pipeline with -Wall -Werror, most people will keep coding as they ever did. Why do you think Google is sponsoring KSPP and pushing C cleanups of bad code, despite all review processes that the kernel has?
- loup-vaillant 5y agoGoodness, I'm running a zero-warning policy with -Wall -Wextra all the time. They have removed tons of bugs in my code before I even touch the first sanitizer, they're my first line of defence.
- pjmlp 5y agoHere a hard reality of how much people care, https://blog.jetbrains.com/clion/2021/07/cpp-ecosystem-in-2021 https://blog.jetbrains.com/clion/2021/07/cpp-ecosystem-in-20... You will find similar results in other surveys.
- flohofwoe 5y agoThe comparison is flawed, because Javascript is a subset of Typescript, but C is not a subset of C++. A better analogy would be that C++ is to C what Dart is to Javascript.
- pjmlp 5y agoIt was when C++ came to be, 40 years ago. Don't mix stuff with how things are today.
- loup-vaillant 5y agoAlso, even now, the intersection between the two languages is large enough to be useful. I believe the entire Lua VM has been written in that subset, and so has my cryptographic library. Though you'd have to be careful, it's still possible today to write useful C code that also compiles as C++.
- pjmlp 5y agoIt surely is.
- galangalalgol 5y agoAdd to that c++ is infectious, both in a code base, because once you add c++ you can't go back, and in dependency chains. A c++ library that depends on c libraries often only exports c++ interfaces so the things that would build on them must be c++. Where julia might call into a rust library with a fortran and zig dependency.
- loup-vaillant 5y agoWhere I'm tempted to compare C++ and copyleft…