Comment by Ygg2
Comment by Ygg2 21 hours ago
> It isn't optional, and yet it's also not at any cost, or we'd all be programming in ATS/Idris.
In a better, saner world, we'd writing Ada++ not C++. However, we don't live in a perfect world.
> The goal isn't to write the most correct program; it's to write the most correct program under the project's budget and time constraints.
The goal of ANY software engineer worth their salt should be minimizing errors and defects in their end product.
This goal can be reached by learning to write Rust; practice makes perfect.
If GC is acceptable or you need lower compilation times, then yes, go and write your code in C#, Java, or JavaScript.
> In a better, saner world, we'd writing Ada++ not C++.
As someone who worked on safety-critical air-traffic-control software in the nineties, I can tell you that our reasons for shifting to C++ were completely sane. Ada had some correctness advantages compared to C++, but also disadvantages. It had drastically slower build times, which meant we couldn't test the software as frequently, and the language was very complicated that we had to spend more time digging into the minutiae of the language and less time thinking about the algorithm (C++ was simpler back then than it is now). When Java became good enough, we switched to Java.
Build times and language complexity are important for correctness, and because of them, we were able to get better correctness with C++ than with Ada. I'm not saying this is universal and always the case, but the point is that correctness is impacted by many factors, and different projects may find achieving higher correctness in different ways. Trading off fewer use-after-free for longer build times and a more complex language may be a good tradeoff for the correctness of some projects, and a bad tradeoff for others.
> If GC is acceptable or you
BTW, a tracing GC - whose costs are now virtually entirely limited to a higher RAM footprint - is acceptable much more frequently than you may think. Sometimes, without being aware, languages like C, C++, Rust, or Zig may sacrifice CPU to reduce footprint, even when this tradeoff doesn't make sense. I would strongly recommend watching this talk (from the 2025 International Symposium on Memory Management), and the following Q&A about the CPU/footprint tradeoff in memory management: https://www.youtube.com/watch?v=mLNFVNXbw7I