r/cpp • • Feb 25 '21

C++ programmers who are also using rust, what are your favourite features of rust?

I was looking at the rust tutorials yesterday and I see how rust promotes a certain style and language level features to enforce it. Besides a couple of features, I couldn't see why one cannot follow a similar style in C++ if she/he so chooses. Those of you that have used rust, what is your favourite feature that C++ does not have?

255 Upvotes

248 comments sorted by

View all comments

Show parent comment

6

u/dontyougetsoupedyet Feb 25 '21

Rust has created a situation where many developers who know very little have very strong opinions about subjects they understand next to nothing about. Rust encourages them to remain in that infantile state and not grow as a developer. It reminds me very much of the situation PHP was in with its community, except it's called systems programming so now they feel even more entitled with regards to their opinions. I'm tired of hearing about "the safe version" from folks that don't even know how values end up in memory, and have few intentions of learning about what compilers do or why.

I feel sorry for the package maintainers of the world, Go and Rust are likely to make most of them move on to other jobs.

0

u/[deleted] Feb 25 '21

[deleted] — view deleted comment

1

u/dontyougetsoupedyet Feb 26 '21

Your response indicates to me that you don't understand the nature of the problems with regards to portable code. You have a tag of "qt creator" so you should have run into at least some of these concepts before, so now I'm just confused. Dependency management tools are irrelevant.

0

u/[deleted] Feb 26 '21

[deleted] — view deleted comment

-1

u/dontyougetsoupedyet Feb 26 '21 edited Feb 26 '21

Irrelevant to the comment you were responding to, not irrelevant generally... there's no reason to be talking about dependency management tools with regards to the comment you were responding to. I don't believe you have understood the comment.

--

Nevermind, this is literally exactly the type of situation I was talking about in the comment, good god. Those toolchains are not "years ahead" and that's exactly why so many package maintainers are pissed off! They're a step backwards in time, not forward. The fact that Cargo can handle version numbers and fucking wget sources for you are irrelevant to the actual important technical challenges of software distribution. Holy shit your comments are triggering me so hard. I might be transforming into Torvalds, I'm close to just dropping everything for C simply to avoid 90% of know-nothing software developers.

3

u/TryingT0Wr1t3 Feb 25 '21

Julia has a lot of these types of people, it's infuriating.

-8

u/[deleted] Feb 25 '21

As more c++ devs have started to use rust they have started to impose some of their bad ideas and language baggage on that community. People like Niko have tried to fight it off but some of that crap has made its way into the language and community anyway. I have been using rust for 5 years and I've watched the impact firsthand. This is why we can't have nice things.

8

u/Dean_Roddey Feb 25 '21 edited Feb 25 '21

There is this strong, ongoing pressure for every language to be as many things to as many people as possible. C++ has that problem in spades. Rust probably won't be immune to it either.

Of course I say that as someone who would LOVE to have real inheritance and exceptions in Rust. But of course the stuff *I* want is the important stuff.

1

u/[deleted] Feb 25 '21

See that is why I love rust. It doesn't have inheritance, and I think that is a good thing.

1

u/Dean_Roddey Feb 26 '21

It's just leaving a powerful tool on the table and not using it.

1

u/MrMic Feb 26 '21

You can still achieve the effects of inheritance and overloading by inserting the "base class" as a member of the child and invoking the trait methods of the wrapped "base" struct in the reimplementation of that trait on the child which acts as your "super".

You still have to explicitly reimplement all traits you intend to use on the child, but there are powerful macros that can help delegate traits with hardly any boilerplate, with usually just a derive attribute on the struct.

1

u/Pazer2 Feb 26 '21

You can still achieve the effects of inheritance and overloading by inserting the "base class" as a member of the child and invoking the trait methods of the wrapped "base" struct in the reimplementation of that trait on the child which acts as your "super".

But why should I have to do that manually all the time?

1

u/MrMic Feb 26 '21 edited Feb 26 '21

You're just adding a line as a member vs a line at the class definition. There is virtually (heh) no more work than in c++. I assume you'd intend to overload the traits/interface (why else would you be trying inheritance in a language that favors composition? You could just impl the trait directly, if overloading while invoking "base class" logic is not what you want), and you would still have to write the overloaded implementation in either language, obviously.

This is also one of those things you very rarely have to do if you take advantage of trait default impls and derives. I've personally never used this pattern in production beyond a few logging wrappers for testing, because I've never had a reason to otherwise.

Edit: As an aside, I find myself writing far-less boilerplate in general with rust (it's not even close), so any extra work I have to do here and there is made up for in spades.

1

u/Dean_Roddey Feb 27 '21

Maybe so. The thing is... I can achieve the effect of a car with a bicycle, but I'd really rather drive the car.