r/rust • u/ElectricalKoala3771 • 8h ago
đ seeking help & advice Should I learn C++ or Rust first?
Hi everyone! I'm a teenager and I'm really into FOSS software and Linux. Up until now, I've only been a user, so I'd love to finally step into the 'kitchen' and start building things myself. Aside from some basic Linux shell scripting, this will be the very first programming language I'll learn, so I'm trying to pick the right starting point. I've heard that Rust is the future of both Linux and FOSSâis that really true, or would something else be better for me? Could you please help me make up my mind? Thank you!
33
Upvotes
52
u/Bagelsarenakeddonuts 8h ago
I think you will learn better habits from rust, and its quickly overtaking c++ for new projects. But there is a much larger existing codebase of c++.
I think if you have the drive, go ahead and try with rust. If you can stick it, you will build really good habits to start, and you can easily learn other languages after. If you find it overwhelming, don't give up coding entirely, there are other easier languages to pivot to and you can try those too.
42
u/KingMagnaRool 7h ago •
I wouldn't recommend either. C++ is an enormous language with a billion different ways to do the same thing. Knowing which ways are "correct" in modern C++ is a difficult thing to pick up as a newcomer, and there are a ton of outdated resources to make things even more confusing. Meanwhile, while Rust is far more restrictive on what you're allowed to do with it... it's far more restrictive on what you're allowed to be doing it, and you will be fiercely fighting it at every turn as a beginner.
I would seriously recommend learning C before Rust at the very least. C is a much simpler language than C++, which makes it much easier to figure out how you're supposed to do things in a general sense. Its basic operations are very close to Assembly relatively speaking, so if you end up learning that to get a better sense of the instructions a computer is running under the hood, it'll be a slightly easier transition. You'll also be able to shoot yourself in the foot with segfaults, and hopefully gain an appreciation for what both Rust and modern C++ constructs are trying to solve.
6
u/kamikamen 7h ago
Whichever one you want, but Rust.
6
u/Joe-Arizona 7h ago
Do the Harvard CS50 course on YouTube, learn C then move on to Rust.
Iâm glad I learned C++ but it is a gigantic language with many ways of doing the same thing. Read up on the basics of it on the side but I wouldnât focus on it too much.
4
u/elitegreg88 5h ago
I know both C++ and Rust. Do yourself a favor and learn software engineering instead. Learn about building scalable software, about keeping data safe and secure, about performance, and about designing tests that prove software works. AI writes great code these days for most applications and you won't beat it in a bidding war unless you will work for bananas. I'm fairly confident the next major computer language will be designed to be optimal for AI writers.
3
u/shizzy0 4h ago
I only truly understood C++âs dream when I finally learned Rust but Iâd say learn C first. C is tiny. C++ is huge. Rust is medium.
5
u/Puzzled-Extent7817 5h ago
C, then rust
7
u/jesseschalken 6h ago
Rust is a fine first language. Itâs also a good âlastâ language, itâs so versatile that you donât need other languages very much. Although Python is still convenient for scripting and data science.
I definitely wouldnât learn C++ unless there is a specific C++ codebase you want to work on.
3
u/nhermosilla14 7h ago
Start with Rust, then learn modern C++ (which borrows a lot from the same ideas, no pun intended). Rust feels much more restrictive, but it's not that terrible once you get used to it. C++ is like a very long tv series, one where the main characters from the initial seasons got replace several times already, so you will find a lot of seemingly contradictory stuff on it that doesn't apply to the current state of the art.
3
u/shonks1 5h ago
What I always recommend people for starting for starting with your âfirst programming languageâ:
1
u/scadoshi 7h ago
I would highly recommend building your projects in Rust while having C++ or C scratch projects tandem to them.
Like what I see others recommending in this thread, Rust will teach you really good habits and eliminate a whole category of bugs, BUT it's helpful to know why it does what it does.
That's where the C++ or C work comes in. Trial parts in freer languages to get an idea of how memory management by hand is done and where it could break. Then land in Rust resulting in more knowledge and more solid projects
1
u/Unhappy-Salary8171 7h ago
That's a great question. Go with Rust if you want to learn best practices in programming. You could say it gives you less "freedom," but that's exactly what will make you more aware of your code and who's using it and when.
Use C++ if you want to learn the hard way. Itâs always been said that C++ gives you absolute control, and thatâs because it assumes that every step you take is carefully considered and that you know exactly what youâre doingâbut more often than we realize, thatâs not the case.
With C++, youâll feel like youâre moving fasterâthat everything is smoother and quickerâbut at any moment you might crash, and your code might have a memory leak or a segmentation fault without you knowing where it came from. With Rust, youâll go a bit slower, but because of the way itâs designed, your code will be much cleaner and safer.
1
u/Expensive_Bowler_128 6h ago
I would like to second another commenter in saying learn C first, then Rust. C++ has a lot of features and a lot of ways to solve the same problem. Learning how to do it âthe hard wayâ in C will provide a good foundation for when you get into Rust to understand what problems Rust is trying to solve. It is hard to appreciate Rust if you have never experienced a seg fault or worked with raw pointers.
If you ever choose to learn C++ down the road, C will be useful as any valid C program is a valid C++ program - C++ simply builds on the language
1
u/UnlikelyFuel5610 5h ago
C++17 first
1
u/Formal-Grass-3173 4h ago
I learned C++ first then Rust, but I mainly work with Rust now. Language barrier is not a thing anymore as you can code with ai, so you can perfect yourself on both at the same time.
1
u/candyFawny 4h ago
rust's habits sound worth the grind
1
u/kittenheart 3h ago
C++ first then you will appreciate rust.
1
u/Only_ITR_No_Bakwas 3h ago
Unpopular opinion lear c or python first
1
u/goomyman 3h ago
There is no reason to create a c++ project anymore. The disadvantages of Rust were its difficulty- which AI addresses.
I would learn RUST. Itâs going to be in demand since AI is writing everything they will want a human in the loop to review things.
Honestly though I would learn C until you understand the basics then RUST.
1
u/thisisnotmynicknam 3h ago
Start with C, then you learn a most high leel language.
1
u/Key-Stay1118 3h ago
The method you use to learn is what you need to master, not the subject.
Ask ChatGPT to organize the chapters for you. It is very helpful than bunch of cheap shit Udemy or repeatedly monkey sees what monkeys do on Coursera nowaday.
All other comments above are pretty much bias and keep repeating what you might have already known.
Donât be on Rust side nor Câes side. These fools will just keep arguing and bringing more out of topics in regardless of your level.
Print each chapter of your currently ebook one by one and upload them on ChatGPT, use it for your own workbook and unique learning path.
Your time, your choice. Donât fall for the âPython is for beginnerâ crap.
Everyone who passes GED can learn pretty much any modern programming language.
1
u/Aghoradas 3h ago
Don't listen to ANYONE about this question unless they say both, or they say whichever you want. Everybody else has an agenda, which you have already seen from the first bit of responses you've gotten. Just pick one, whichever, and start coding. You can always learn another language. Programming basics are universal.
1
u/Technical_Ideal_5439 2h ago
Dont learn C++.
C then Rust. If you really want to to be a solid programmer you need a solid full featured language to be your first and best and Rust can fulfill it. Admittedly C++ was mine but latest and greatest C++ I think has lost its way.
Though personally I would learn golang and see if you can contribute to any CNCF projects. And stay away from javascript as your first solid language.
And Rust is flavour of the month, because it maybe technically superior does not mean it is the future. The reason languages do well is normally far from their technical superiority.
1
u/ComedianMuted5486 2h ago
There's a lot of recommendations to learn a bit of C first, and in the abstract I agree. It will help you gain an appreciation for what Rust provides and what issues it prevents, which will help the learning curve with Rust later (when you may sometimes wonder why it's being restrictive). Python is also a really good language for picking up programming as a beginner (from the complete opposite direction as C)
But the most important thing is to stay motivated, and in that sense, don't pursue "learning the right way â˘" to the detriment of actually learning. If your motivation is to learn FOSS and Linux then learning a bit of all of it is great, if your motivation is primarily Rust then don't feel like you have to do the other stuff. You can just learn Rust if you want.
1
u/DanKegel 2h ago
I agree with learning Rust over C++ for systems programming; anything that needs to be right and fast should be in Rust.
But you may as well also learn some Go; it's easy, and some jobs might prefer it.
1
u/bogoris76 2h ago
If you never programmed learn python first. Reasons are pragmatic: it's simple to starty, easy to run, good IDE support -- e.g for debugging. Once you are able to build some applications step up to something closer to the metal.
1
u/AgentAppropriate1996 1h ago
Rust
1
u/meowsqueak 1h ago
Youâll never master C++ unless youâre prepared to put in decades of study. And by then itâll have got 2-3x worse anyway.
Go with Rust, itâs harder at first, but once youâre over the hump you will have a decent shot at becoming an expert, and itâs also a more friendly and respectful community.
Youâll also learn more if you ask questions about Rust design because itâs been designed to meet real-world problems, and not by a committee that decides what is least likely to offend existing developers or break everything in the world.
1
u/MyFistsAreMyMoney 1h ago
Rust. C++ is a mess and you can do several things wrong
1
u/_janc_ 1h ago
C++
1
u/yahbluez 40m ago
rust, it will help you nothing to learn c++ if you like to understand rust. It will make your way to rust harder not easier.
1
u/dariusbiggs 39m ago
C++, so you can learn why rust exists and why people use it
1
u/Weak_Painting_8156 26m ago
Learn markdown, the rest is obsolete. đ¤ˇ
1
u/creeper6530 16m ago
You'll learn good habits in Rust you can then carry over to C++.
Learn C first tho.
1
u/EmperorOfCanada 1h ago
The question is why?
I have been programming for over 3 decades. That is 3 decades of no AI.
I've primarily used C++, but over that time, I have had to solve a massive number of problems, and while C++ was a good solution to many of them, it often was not, and thus, I learned some new language.
What I've learned is a few things which go far beyond C++ or any individual language. I've learned that tech debt is what kills good projects. I've learned that communication skills are insanely important. If you don't communicate well, and end up building the wrong thing, it does not matter how well you built it.
I've learned that workflow is often what makes the difference between a nightmare project and one which is pretty smooth.
But, I learned all these lessons from two sources. The hard painful way, or sitting around the development campfire and having other people tell me their painful stories, and the useful discoveries they made while suffering.
With AI, all the traditional suffering is gone. The problem for someone like you is that AI is better than you are right now. Way better. What you want to do is to somehow bridge the gap to where you are better than it as a common sense human being. This takes experience to be able to call BS on what it poops out, as it will poop it out with great confidence.
To badly answer your question, rust is an excellent language for the present, the future, and for working with AI. I could spend the next 10 hours writing this comment about how I love it and it has changed my life.
Yet, I'm going to make a different recommendation. Don't learn C++ or rust, or even python.
Learn C and Assembly. Don't learn to get AI to do C and ASM for you, but actually make programs, by hand, from scratch, which do things.
There is a game library called raylib. It is about as clean a library as I've seen in my life. Make games in C with that. Make pacman, make space invaders, start with pong.
But, then push it hard. Make multi player networked pong, make sure it is using threads like you get $1000 for every thread you use. Not because it makes for a better pong, but because threads are a nightmare to get right.
Make a server which hosts games, make them on multiple platforms.
Use AI as a textbook. Don't copy and paste anything from it.
This way you can become a developer, and as a developer, you will be far better able to wield AI programming tools, as that is what they are. Tools. They aren't developers.
Maybe you won't use C in your future, but it will give you a brutally hard introduction to what the computer is doing under the covers. Then, when you probably end up using rust, you will find it smooth sailing, and have the confidence to understand when the AI is feeding you poo.
0
u/Middlewarian 7h ago
I think languages that embrace on-line code generation have an advantage over those that don't. I'm biased though, as I'm building an on-line C++ code generator. However, I acknowledge that Rust has some strengths and hope to 'rustify" my software.