top | item 14782852

(no title)

elementalest | 8 years ago

Whilst I agree it is hard to consistently write safe/secure code in C for increasingly more complex code bases, and that C is no longer the best tool for the job in these cases (there are better tools/languages out there), I think the author unfairly lumps modern C++ (>C++11) in with C. Modern C++ has many of the tools necessary to mitigate many of the problems C (and <C++11) can encounter.

I do think Rust is a viable replacement for C, but not a replacement for modern C++, rather an alternative - at least for the foreseeable future.

discuss

order

pcwalton|8 years ago

I actually think modern C++ is less safe than C, because of the ability of destructors to be invoked invisibly and cause use-after-free, just to name one major issue.

jstewartmobile|8 years ago

That's not even the half of it! Start using a variety of different C++ compilers. Then there would probably be more profit running bets on what the code is going to do than there would be in the actual software.

elementalest|8 years ago

Unless I'm mistaken, if you're using smart pointers, the memory wont be freed until the destructor has executed its code. Use after free should only be an issue if you're using raw pointers.

bobbyi_settv|8 years ago

The reason to use C++ is that it's reasonably widely known. "Modern C++" isn't.

I went to college less than 20 years ago where I used plenty of C++ and I've had multiple jobs since then using it (my current work is in Scala). I have no idea how to work in Modern C++ and I'm pretty confident it would take longer for me to learn than Rust.