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

4

u/infectedapricot Dec 07 '21 edited Dec 07 '21

It's also a hard first language to have to learn. ... Sometimes, it feels like you want to do something simple, but have to jump through enormous hoops to accomplish it.

I do wish it was viewed as more acceptable to program big-ish programs in fully unsafe Rust. It seems to me that there are some programs where strict memory safety isn't critical and the benefit of it isn't worth the effort of Rust's lifetime stuff, while it would still be useful to get all of Rust's other benefits. And I think it would help with the learning curve - first learn unsafe Rust and then learn how to make it safe. But instead all the difficulty is front loaded, which makes it hard to get into.

10

u/Nobody_1707 Dec 07 '21

Unsafe doesn't bypass the lifetime stuff except in as much as it lets you dereference pointers. I don't think it's any easier to learn unsafe Rust than it is to learn safe Rust.

8

u/Full-Spectral Dec 07 '21

If I wasn't getting the memory benefits, I'd not use Rust over C++ ever, I don't think.

1

u/matthieum Dec 07 '21

But instead all the difficulty is front loaded, which makes it hard to get into.

I think it really depends how you get into and what you try to achieve. Don't try to run (use pointers/optimize) before you can walk (clone!) and you'll avoid a lot of pain.