Ask HN: Learn C++11 or Rust in 2022?
Between C++ and Rust, my bet would be that you decide Rust.<p>But—also learn Zig in addition to Rust.<p>Having seen first-hand how so many threat vectors these days are now supply chain attacks, having reported CVEs and earned P1 bounties in memory safe languages, and having worked on static analysis systems to detect zero day exploits—I&#x27;m also impressed by Zig&#x27;s overall approach towards safety, as being more than only memory safety.<p>For example, this comes through in Zig&#x27;s extreme simplicity and explicitness, and also how Zig enables checked arithmetic by default for safe builds. For people who haven&#x27;t worked in security, integer overflow and wraparound may seem like small things, but they increase the probability of exploits such as buffer bleeds, i.e. attacks like OpenSSL&#x27;s Heartbleed, which are often remotely accessible and easier to pull off than a UAF.<p>In fact, no language is 100% memory safe, i.e. able to prevent a memory buffer bleed, because these are logic errors with respect to the protocol. However, explicit control flow and checked arithmetic do help to close semantic gaps and minimize ambiguity, which is what good security comes down to.<p>Of course, Zig only offers spatial memory safety, and not temporal memory safety like Rust. So Zig is more memory safe than C, and less memory safe than Rust or JavaScript. Nevertheless, Zig is safer than Rust when it comes to being able to handle memory allocation failure.<p>Again, Rust&#x27;s borrow checker is also valuable for concurrency safety, i.e. for multithreaded systems, but if you&#x27;re using io_uring for fast I&#x2F;O, then multithreading is less of the necessary evil that it used to be a few years ago.<p>Zig is something you can pick up in a week, with state of the art tooling, and fantastic C-ABI interop for libraries.<p>So... learn both!