r/C_Programming • • Jul 18 '26
Which is better, Rust or C/C++?
I decided to look into this specific topic and found something that suggests C/C++ might be phased out in the distant future.
One of the reasons I say that C/C++ could potentially be replaced by Rust is:
1/ It can manage memory automatically and manually, and does so securely
2/ Its performance rivals that of C/C++
However, there are also drawbacks, namely:
1/ The Rust ecosystem is minuscule compared to that of C/C++
2/ It lacks the freedom we have in C/C++ to run code as we please; instead, Rust provides built-in safety features that prevent you from making mistakes
There are also things they have in common, such as:
1/ Direct control over resources
2/ The execution model
3/ Low abstraction
4/ High performance
Is Rust a suitable alternative, or is it better to use C/C++ alongside Rust?
This is information I’ve researched, and I’d appreciate it if anyone could correct or add any details I’ve omitted.
Best regards
32
u/DreamingElectrons Jul 18 '26
If you ask in a C sub, the answer is obviously C.
Ask in a C++ sub, the answer will be C++.
Ask in A Rust sub, the answer will be Rust.
14
u/necheffa Jul 18 '26
It is difficult to make a comparative analysis because C/C++ isn't a language.
4
u/Deriviera Jul 18 '26
If your goal to find a job in the future filter by salary and amount of job postings. Otherwise just try them all and choose what you like more. I personally both work as c++ dev and write in c++ as a hobby.
4
u/Hoshiqua Jul 18 '26
I for one believe there is no such thing as a better language, overall, from an objective perspective, because in the world of the objective a language is only a means to an end.
Narrow it down to coding style, constraints, the type of problems you're trying to solve, whether the project is even result oriented or is educational... and the answer becomes impossible to give.
As someone who, when at all possible and reasonable, exclusively uses C / C++, my take on Rust is that it should stop being compared to C / C++ so much and rather be compared to C# and Java, because they all come from the same lands of "safety as a language construct" and "package-based composition of software" which are two things that will never be so important to your average C / C++ programmer in 2026 on their own.
Educationally, however, I remain convinced C and old school C++ are better precisely because it exposes everything to you and slaps you for all sorts of mistakes you couldn't openly make or spot as a beginner in other languages.
7
u/DDDDarky Jul 18 '26 edited Jul 18 '26
First of all, there is no C/C++, they are very distinct languages.
Should be noted c++ has automatic memory management features for a long time.
Performance of most compiled languages is usually quite similar, although C and C++ tends to be better optimized.
C's ecosystem is not?
Not entirely true, you can make mistakes in any language, Rust's compiler enforces certain things that can prevent certain types of errors, in other languages these are rather optional for the decision of the programmer.
Afaik it's not really an alternative as they are used in distinct fields.
4
u/Interesting_Buy_3969 Jul 18 '26
assembler language
6
u/Aexxys Jul 18 '26
If you’re a programmer then C
If you need your compiler to babysit you then Rust
2
u/non-existing-person Jul 18 '26
Depends on what you plan to do
1
u/v_maria Jul 22 '26
zig
1
u/Positive_Method3022 Jul 18 '26
I like the borrow concept from rust. In huge projects it is was easier to on-board other developers to your code base.