I came across this article the other day, titled “Why Rust cannot replace C++”.
I feel that the author completely fails to understand the opposing argument. The article claims that with “new” C++ features like smart pointers, you can write safe code in C++, therefore Rust is unnecessary.
But I don’t want a language where I **can** write safe code, I want a language where I **must** write safe code.
https://medium.com/@pepitoscrespo/why-rust-cannot-replace-c-but-quite-the-contrary-5577e1f5af0a
There’s this common statement that “the cognitive overhead of working with the borrow checker just isn’t worth the security benefits when you can write safe code in other languages”.
But the comparison is always to the “cognitive overhead” of writing something in some other language. When the comparison should be to writing something **correctly** in some other language.
1/3
Sure, it’s much easier to pass pointers (*, &, or shared_ptr) around, but now I have the “cognitive overhead” of ensuring that it’s only accessed from one thread at a time. Or not used after it’s been freed in the former cases.
When I’m working with the borrow checker that is something that I **don’t** have to think about. It’s less “cognitive overhead”.
#rust #rustlang #cpp #programming
2/3
@hds We had a training about modern C++ at work two weeks ago. I learned a lot of knew things but many of them where somewhat familiar. But during these three days I kept thinking „What’s the point?“.
I can understand that there are people who programmed in C++ for a long time and they know everything about the language, for them it is nice to also have these shiny new things that newer languages offer.
1/2
@hds But this is complicated for someone learning C++ from scratch. It does not suffice to only learn the modern way. When you start working at a company and have to maintain legacy code chances are high it was not (completely) refactored to use modern C++. So you have to learn the whole range of C++ to be able to use it professionally.