4 ms·
C++ is a monster. The 2026 proposal has some neat ideas (I like the ability for the developer to give a reasons for modifying behavior that may create otherwis
by jll29 2y ago
C++ is a monster.
The 2026 proposal has some neat ideas (I like the ability for the developer to give a reasons for modifying behavior that may create otherwise cryptic error messages, for instance); but the more things one packs in there, the uglier, bloated the specs, and the more complicated and buggy compilers will be.
Once C with Classes was an experimental pre-processor to try out bringing in some Simula ideas into the C world. Today, C++ has become a language that changes dramatically every half a decade, where the main question is "will it
compile" if you receive someone else's code, and where even experienced
developers cannot tell from compiler error messages what's wrong (g++). The undoubtedly clever people who have been working on it have nevertheless committed war crimes in anti-orthogonality.
Tip: introduce a versioning mechanism like Rust has it, so that you are freed from the burden of having to be backwards-compatible.
- wslh 2y ago> C++ is a monster. I haven’t fuzzed a C++ compiler myself, but our team recently tried fuzzing a relatively simple S-expression-based compiler and discovered several issues in a few weeks [1]. I can only imagine what could be uncovered in C++ compilers. If this hypothesis holds, it suggests a significant attack vector that might elude even the smartest security researchers who are only analyzing repository codes and dependencies. [1] "Why the Fuzz About Fuzzing Compilers?": https://www.coinfabrik.com/blog/why-the-fuzz-about-fuzzing-compilers/ https://www.coinfabrik.com/blog/why-the-fuzz-about-fuzzing-c...
- JonChesterfield 2y agoCompiler engineers like fuzz testing. You'll find a bunch of infra for it in llvm. That should mean the easy targets have already been hit, though I wouldn't be too confident of that stance.
- fruffy 2y agoPlus there are hordes of academics using Clang/GCC as targets for bug-finding papers. The Csmith [1] paper alone has over a thousand citations at this point. I'd assume most of the low-hanging fruits are picked. [1] https://www.cs.tufts.edu/~nr/cs257/archive/john-regehr/finding-c-bugs.pdf https://www.cs.tufts.edu/~nr/cs257/archive/john-regehr/findi...
- wslh 2y agoIn my humble experience, both in academia and the cybersecurity industry, there are relatively few individuals and teams with the drive necessary to discover the most challenging bugs, especially compared to the sheer scale of the challenges. Fuzzing is just one example of this. Additionally, with billions of lines of code, it takes significant time for research to translate into real-world engineering practices. One example of a higher order reasoning about this is [1] (includes metrics). [1] "As TVL rises, so does the probability of being hacked" https://www.bittrap.com/resources/defis-growing-pains:-as-tvl-raises-so-does-the-probability-of-being-hacked https://www.bittrap.com/resources/defis-growing-pains:-as-tv...
- d0mine 2y agocppfront simplifies C++ a lot by introducing unifying syntax (that compiles to ordinary C++ -- same semantics in the end) https://github.com/hsutter/cppfront https://github.com/hsutter/cppfront
- linkdd 2y agocppfront is an experimental sandbox. Its goal is not to replace C++ nor offer an alternative. Its goal is to explore features and semantics in order to improve C++ itself.
- pjmlp 2y agoThat is like pretending using Typescript or Objective-C, doesn't require understanding everything else they build upon. Herb Sutter always tries to sell cppfront in a different way, due to his position at WG21. It would be rather odd if the chairman of WG21 would also be proposing a C++ replacement.
- d0mine 2y agocpp2 is "A Typescript for C++" is how the author himself categorizes it https://herbsutter.com/2023/08/13/my-c-now-2023-talk-is-online-a-typescript-for-c/ https://herbsutter.com/2023/08/13/my-c-now-2023-talk-is-onli... Yes, knowing underlying levels of abstraction may be useful e.g., godbolt.org is excellent, knowing CPU caches, pipelines, branch prediction, out-of-order execution may be essential for getting orders of magnitude improvement in performance. It doesn't mean the abstraction itself is useless.
- pjmlp 2y agoThat categorisation is exactly the point, Objective-C and C++ didn't stop at being Typescript for C, they became their own thing, after using C compatibility and C code generation as their bootstraping mechanism. Also plenty of languages compile to native code via C or C++ generation, Eiffel, Nim and some Scheme compilers being the most notorious ones. However the WG21 chairman can't in a political correct way, assert that like Objective-C and C++ did to C, cppfront if successful will trail its own path, effectively being yet another C++ replacement language.
- heresie-dabord 2y ago> C++ is a monster. Perhaps you meant monstrous? The dev community (and software profession) is crying out for legible, parsable notation and greater safety. All the modern languages are drawing us towards some of these crucial goals. Python above all for its legible/usable notation, Rust for its compile-time and run-time characteristics; Go somewhere in the middle. As a recovering C++ coder who discovered that there are better languages, I think that within the Tower of Babel that is the coding-language community, C++ has leased an entire floor for its ravings to the congregation.
- kanbankaren 2y agoBeen programming in C++ for 25+ years and I could say the complexity exploded after C++11 with the introduction of rvalue references. The template syntax could have been simplified, but you get used to it. People should use more typedef to make C/C++ look sane, but there is some pushback that it hinders readability, but I feel that it is the opposite.
- jprete 2y agoRvalue references et al are a valuable addition to the language if you're trying to avoid gratuitous copying. The performant alternative is a messy variety of functions that have the same effect as move semantics, except with ad hoc (or no!) compile-time checking. Using them correctly does requires a lot more background knowledge and conscious decision-making from the user than the rest of the language. Templates are not that bad as a user, but as a template author, they're a completely different programming language that makes it much harder to express even simple ideas. (Concepts may have changed that, but I haven't had a chance to use them.)
- whiterknight 2y agoThe solution for move semantics before was specializing the swap function for container types. This was a much more pragmatic approach
- fsloth 2y ago