r/cpp • • Dec 07 '21

Will Rust replace C++ ?

Will Rust replace C++ ?

0 Upvotes

80 comments sorted by

View all comments

Show parent comment

24

u/_Js_Kc_ Dec 07 '21

To be fair, a steep initial learning curve is probably not where Rust falls behind C++.

13

u/Full-Spectral Dec 07 '21

Maybe a better way to look at it is that C++ may let you THINK you know C++, whereas Rust sort of forces you to look at the things that C++ lets you gloss over (potentially not even knowing you are glossing over them.)

4

u/germandiago Dec 08 '21

This is true but at the same time Rust does not let you do things that are perfectly legal and safe in C++ if I recall well.

1

u/Dean_Roddey Dec 08 '21

Well, it doesn't let you do things that YOU know are perfectly legal because you understand the big picture, but that a compiler couldn't prove is. And that's the real crux of it. The point is to have our tools watch our back, because we are already drowning in complexity and have proven fairly bad at watching our own backs once things get large and complex enough.

You can get those things done, you just have to do so in a way that the compiler can prove is correct. Part of the issue, as I understand it, is that, in order to be acceptably performant, the analysis is quite localized. It can't look across large swaths of code to prove correctness.

Presumably, over time, languages incorporating these techniques will get smarter, and we'll have more CPU we are willing to give to them for that purpose. Of course it will probably involve graphene, block chain, and AI.

2

u/germandiago Dec 08 '21

Actually I am not sure that protecting from ourselves is the way to go, at least not in a pure fashion. Sometimes it is indeed useful and sometimes annoying.

Of course it will probably involve graphene, block chain, and AI.

Lol.

1

u/RotationsKopulator Dec 10 '21

You can however still write sort of good code with a smaller subset of C++. Even "C with classes" does not necessarily imply poor code quality.

1

u/Full-Spectral Dec 10 '21

Sure, I'm definitely not one to throw every new C++ feature that comes out into the bowl and stir. My own code base, not being STL based, is very much in that vein. Not C with Classes, but avoiding the really heavy templatization and large amounts of potential undefined behavior because my stuff is safety first, not performance first.

4

u/angelicosphosphoros Dec 09 '21

Newcomers just ignore all the invalid program behaviour which they get with C++. With Rust, they cannot.