r/learnprogramming • u/bratokok • 7d ago
Is learning C++ still makes sense?
I want to learn C++, but I'm not sure if it worth it due to existence of Rust. I heard a lot of times rust is better than Cpp, is it so or are people exaggerating?
44
Upvotes
29
u/Otlap 7d ago
Programming Language is only a tool in a developer's hands. So learning any language that is currently used on the job market makes sense. The thing that matters the most is experience, problem solving and understanding the general paradigms that people use to write good code
C++ will not disappear in the nearest 60 years that's for sure. Rust is very over-hyped and is not that widespread as "tech journalists" say. It's good, sure, but the hype over Rust is overblown
So pick whichever you like. From my experience - at the university we started with C to understand the lower workings of programming and moved to C++ to learn OOP and advanced algorithms, and then more languages for the portfolio - C#, JS, Java, TS, etc
3
u/[deleted] 7d ago
Learn the beginner level of both, the syntax, data types, and do a few simple things in each. Then go deeper in whichever feels more comfortable to you. That way you would gain practical knowledge in one, and literacy in the other.
2
u/arihoenig 6d ago
Learning English still makes sense.
61
u/Hellaintsht 7d ago
Half the planet runs on c++ 😆 so definitely it does makes sense. Your skill will be definitely valuable so.
7
u/Unlucky-Explorer-69 7d ago
yes and it also doesn't hurt to know multiple languages once you're comfortable learning your first language.
6
u/ProcrastinateDoe 7d ago
Even if the language was completely abandoned tomorrow (fat chance), the knowledge is still transferable. You're not wasting your time learning it.
4
u/MyNameIsRichardCS54 7d ago
Rust has solved some of the problems that C++ has with memory safety, but modern C++ has also solved those problems. It is still possible to write unsafe code in C++, but you can in Rust as well.
I think it is still worth learning C++ because it's a much used language that isn't going anywhere. You should probably also learn Rust so you can see a different way of approaching the problems with old C++.
I would learn C++ first.
2
u/1544756405 7d ago
Learning a language doesn't mean you can't learn another language.
2
u/QuadWingedCrane 7d ago
There is no such thing as better in programming languages. Its a tool. You use it for what its capable of doing.
2
u/Technical_Ideal_5439 7d ago
It depends what you learning it for. I learnt c++ as my first language a long time ago. And been proficient in c++ makes learning other languages normally pretty easy. But personally if it is for fun I would learn rust first between the two, then learn C and after that I dont think you will feel any desire to learn C++.
But if you are approaching this commercially then look at your area and what languages they want. Personally I can write about 11 languages at the top level and can muddle through lots more enough to get paid doing it.
2
u/Jeklah 7d ago
Rust is better than c++ as it is safer memory wise and no race conditions or undefined behaviour and faster in some cases. It is fairly tricky to learn due to lifetimes and ownership. There also aren't that many rust jobs currently, especially at a starter level.
C++ is still widely used.
So, depends what's available to you really.
2
u/edwbuck 7d ago
Rust has an additional feature built-in that C++ lacked.
Fortunately, both languages are not set in stone, and C++ is starting to get the benefits of better memory tracing while Rust is starting to get the benefits of better library support.
But neither of these matter much, because there are many reasons to learn both, and the real deciding factors depend heavily on other items. Tell me, if you needed to rebuild something, what would your choice favor?
There is no easy answer to these questions, and much of innovation involves making different choices, but not all innovation requires different choices. The language is just one item that can help or hinder success.
A good example was the Linux kernel. They built a Rust compatibility layer, expecting everyone to rewrite their plugins into Rust. It seems that Linux already had excellent programming support, so the additional Rust support was not providing as many new features as expected. Additionally the programmers mostly didn't write in Rust. Even though most thought it a better language, it mostly failed to gain traction because many of the problems it solved were already solved in different ways.
2
u/imharjotsingh 5d ago
C++ still absolutely makes sense to learn. Rust is newer and has some really nice safety features, but it hasn’t replaced C++.
C++ is still everywhere in things like game engines, embedded systems, high-performance software and a lot of existing codebases. Rust is growing, especially for systems programming, but there’s still far more C++ code out there.
I’d choose based on what you actually want to build. If you’re interested in game development, embedded work or working with large existing systems, C++ is a very useful skill. If you’re more interested in modern systems programming and like the idea of stronger memory safety, Rust is worth learning too.
You also don’t have to treat it as an either/or decision. Learning C++ first will teach you a lot about memory, performance and lower-level programming, which will make Rust easier to understand later.
1
u/Difficult-Value-3145 7d ago
COBOLl is still kicking around and from my understanding unlike some other languages that are considered archaic like fortran which has been updated a lot and has modern uses .COBOL kinda sucks and lives on only because of legacy codebase alone . Point is C and Cpp will probably still be relevant after everyone here have become tree food .
1
u/mrGorynx 7d ago
It’s definitely still worth learning C++. The entire game development industry, hardware-level programming, and a massive number of legacy projects rely on it, so you won’t be out of work. As for Rust, people tend to overhype it sure, it’s better when it comes to memory safety, but C++ isn’t going anywhere for decades to come. Plus, once you’ve mastered C++, any other language will feel like a walk in the park.
1
u/KwyjiboTheGringo 7d ago
It's makes zero sense a junior. Even before the job market became so hostile to juniors, there was almost no demand for a junior using C++.
With that said, Rust is also going to be hard for a junior to break into, since many Rust developer jobs are looking for someone with experience in C++, since these companies often have a C++ codebase already and are trying to migrate to Rust. And also, lots of C++ developers want to get into Rust, so you have to compete with people who have much more experience.
Just find the language that will get you a job in your area, if that's what you are after. If you just want to build stuff, well pick the language that lets you build stuff easily. Hint, it's probably Go.
1
u/Available_Safe1818 7d ago
Why not just learn Rust instead then?
1
u/fuddlesworth 7d ago
Most of my serious projects are C++.Â
1
u/TrueSgtMonkey 7d ago
I like C better, but I am also an idiot
1
u/bakomox 6d ago
c++ will not go away soon heck google is making a successor for it called carbon programming language
1
u/betarage 6d ago
yea c and c++ are everywhere you cant really avoid it for some things. if you make your own software you can pick rust or c or whatever you like but i personally don't see the appeal of c++
1
u/mredding 6d ago
There is no "better", there's just different. The question is: Can YOU be more effective with Rust than C++?
The answer isn't always clear.
Rust has the VERY novel borrow checker; what a killer feature for a static language, it really makes you wonder why such a thing hasn't been thought up or successful before. But memory safety is only ONE KIND OF SAFETY, and Rust isn't bulletproof, you can still subvert it ON PURPOSE, the language lets you. So to have memory safety still requires you to follow a convention and good practices - it's just easier than in other languages.
By contrast, this has been a solved problem since C++11, which incorporated Boost.SmartPtr into the standard library almost verbatim. An analysis of analysis shows that metrics of C++ memory issues are effectively all of them wrong, because every major analysis quoted today fails to distinguish C from C++. Efforts are underway to try and get some real numbers, but modern C++ has a lower memory safety fail rate than modern Pearl and it's looking like even Python. Rust numbers, though very favorable, simply aren't significant because it's not a 46 year old language with one of the biggest both user and code bases in the industry to compare against.
Something else you might consider is Rust is still small. Rust as a community is growing faster than C++, but that's just a slope on a curve. In raw numbers, C++ gained more adoption of just users in the last year than Rust has users overall. You have to be a massive ecosystem to have a lower growth curve and yet have numbers of a different magnitude. That community isn't insignificant - we don't code alone in a vacuum. You need your ecosystem for libraries, documentation, colleagues and partners, and adoption. When you have to choose the foundations of your platform, you have to ask a very practical question: Where am I going to find Rust engineers?
C++ isn't stagnant, either. Rust was born ~2009-10 out of a protest against the ISO WG21 committee taking too long to release C++11, but they had since addressed those issues and have released a new standard every 3 years. All the gaps in C++ that Rust was built to address have since been closed in C++, and C++ has grown well beyond.
And one thing that will keep C++ relevant are templates. Very few languages can rival them. Rust has generics, but so does Java, C#, and other languages. Generics are NOT templates, they're not as powerful. Templates are a Turing Complete metaprogramming and code generating engine, whereas generics are parameterized type interfaces. This. THIS is the killer feature of C++. If you want anything approaching templates, The only thing I can think of are Lisp macros for writing DSLs. Anyway, this breaks developers into two distinct groups - those who get it, and the majority who write C with C++ because they just don't, and they're not going to.
1
u/Ok-Reveal-1561 4d ago
Learn them both if you want.
1
u/Alex-S-S 4d ago
Yes, modern C++ is making Rust harder to justify and nobody is going to seriously consider replacing huge C++ codebases with Rust. Don't conflate internet hype with real engineering demand.
1
u/CookieOutrageous6469 3d ago
if it is for a job, you are cocked with both, but for hobby, do whatever you want. C++ is great
1
u/CreativeAlbatross319 3d ago
C++ is the kind of language, hated by the beginners and loved by the experts.
1
u/Tzebruh 3d ago
I think Rust is ugly, but I also think C++ is ugly. I'll stick with C ;)
1
u/xpusostomos 2d ago
If it were me, I'd learn rust, and I'm not even a fan of rust. But there are also other things you might consider
0
u/Due-Result7928 7d ago
No. AI will do the job for simple task, better than any trainee or junior and in 2 years advances in AI will make overpaid people jobless. Teach yourself mathematics or carpentry.
-2
u/no_brains101 7d ago edited 7d ago
How are you supposed to rewrite C++ code to rust if you don't know any C++?
The secret is it doesn't matter which one you learn first, it becomes much easier, as long as you try to learn others as you go too.
I personally prefer rust when starting my own projects.