Hacker News new | ask | show | jobs
by flohofwoe 1710 days ago
Zig fixes many more memory safety issues than C or C++ though, simply by being less "sloppy" and enforcing more correctness (e.g. no implicit type conversions, no over/underflows, proper range-checked arrays and slices etc...) - IME most memory corruption issues in C and C++ are actually secondary effects of such simple correctness issues. Zig just isn't quite as "extremist" as Rust (also, Rust is a great language for writing a sandbox, but if a memory-safe language must be used inside the sandbox to prevent damage outside the sandbox, then it simply isn't a sandbox.
1 comments

All of these are available and widely used in C++ (for example [1]). They are not enough.

[1]: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#...

"Widely used" might be a bit of an exaggeration, MSVC only added address sanitizer support very recently but doesn't support any of the other sanitizers, and none of the sanitizers are enabled by default in Clang.
The biggest companies on the planet with massive C++ codebases are all very aware of the clang sanitizers and use them regularly. UBSan has far more deployment than Zig.