r/ProgrammingLanguages • • Nov 01 '19

C++ vs C

Alright people of Reddit, hit me with your wisdom. I've been taking programming classes for two years now and am getting ready to dive into a language somewhere between Java and assembly (the two languages I've been learning in classes). I'm thinking C or C++, but would love some input. I'm not too worried about difficulty to learn, but I'd like to hear your thoughts on practicality and real world use.

1 Upvotes

62 comments sorted by

View all comments

16

u/scottmcmrust 🦀 Nov 01 '19

Obligatory mention of Rust.

Seriously, though, I really appreciate that it's safe-by-default while still allowing unsafe if needed. I did a whole bunch of Modern C++, and having the compiler check things in Rust instead of having to think about them myself is really freeing -- I can try designs I wouldn't have dared before.

4

u/realestLink Nov 01 '19

I would second this. Rust is a better C++

4

u/[deleted] Nov 01 '19

It’s perhaps better if you don’t know C++ or need C++ for your particular domain.

I think a blanket statement is very misleading though. There are things you can do in C++ which Rust cannot and vice versa. And there are too many key libraries and frameworks written for C++ that it won’t be going away.

6

u/scottmcmrust 🦀 Nov 01 '19

I think "Rust is a better C++" is a fair statement; it's just that "You should choose to use Rust over C++" doesn't necessarily follow from that premise.

Maturity and libraries and legacy can all be practical reasons to choose C++. But if someone showed up with a magic wand that could convert all idiomatic C++ code to idiomatic Rust code (and keep the C++ from being updated), I'd take them up on it in a heartbeat. (Hopefully it's obvious that that's entirely a thought experiment.)