r/AskProgramming • u/Cartman1994 • Oct 01 '26
Should I learn C or Rust?
I’ve been working as a Java programmer for a few years now.
The thing is, I’d like to learn a second programming language for lower-level tasks—specifically, I want to work on things related to operating systems. Rather than building one from scratch, I’d like to explore and modify open-source operating systems like Linux or a BSD variant.
I’m doing this purely as a hobby. What drew me to C is its simplicity (though not necessarily ease of use) compared to Java or other modern languages, and its long history of use in systems programming. On the other hand, however, there are operating systems (or components of them) being rewritten in Rust—such as GNU coreutils or the adoption of Rust in the Linux kernel.
So, would it be more useful in the long run to learn Rust, given that it might sooner or later become the standard for writing operating systems?
Thanks.
7
u/Undeniable_Dilemma_ Oct 01 '26
C without any doubts.
If you go straight for the Rust, you will never truly understand some of the problems it attempts to solve.
C is still useful, it's everywhere, it teaches you a lot of concepts and helps you better understand modern language alternatives.
5
u/t-tekin Oct 01 '26
I’m assuming by learning you mean “learning the language concepts and understand enough to be able to stand on your two feet”
If you know Java, learning C is - 1 month tops?
Rust another month?
Ok learn both? Or even better read a bit about each and stick to the one you like?
I don’t understand why “which language should I learn” deserves this much thought.
2
u/7YM3N Oct 01 '26
I think C isn't going anywhere anytime soon, it might get slowly phased out over decades but it will still be used in places for decades beyond that
3
u/ight-bet Oct 02 '26
Learn C, then master rust.
8
u/GermaneRiposte101 Oct 01 '26
C. Everything meaningful is written in C or C++ (including ALL OS's in use).
Apologies for the BOLDS but it needs to be said.
2
u/annika-of-the-woods Oct 01 '26
If you want to be able to tinker with existing OS stuff, then starting with C makes sense. Personally I think it's also one of those languages you won't regret learning if you're interested in this kind of thing, even if you were to move on to something else later. It also has a much smaller surface area than Rust, and understanding some of the footguns of C will help make some of Rust's design decisions make sense if you do end up learning it later.
That said, if you were talking about writing some new complex piece of software from scratch I'd be much more inclined to recommend Rust. Not just for all the language features, but for all the tooling that makes project management so much easier.
2
u/jibbit Oct 01 '26
IMO it would not hurt to learn C as a step on the way to Rust, but don't make C the end goal. You want to understand the motivation for Rust. c is quite easy to learn and there's a lot to gain from having a good knowledge of it
2
u/AdreKiseque Oct 03 '26
Learn C first. C is foundational.
3
u/DestroyedLolo Oct 01 '26
First of all, C is close to Java in term of syntaxe (close, not identical).
Secondly, 99% of operating systems and userland are written in C. While there is significant hype around Rust, it is still in its early stages, and the promises used to advocate for a switch have yet to be fully realized.
Personally, I have been fluent in C and C++ for decades and do not see any significant added value in making the switch.
1
u/Several_Version4298 Oct 01 '26
Most operating systems are written in C, because it can handle low level stuff and general programming. Parts of the Linux kernel are being rewritten in Rust, replacing old potentially insecure C and assembly code, but it's very much a work in progress. Rust is much more secure which is important for operating systems and internet facing applications these days. Rust is a lot more complex than C and harder to learn.
You would have to learn C, and some assembly, to work on operating systems. While C isn't used much for writing large applications anymore, C++ still is.
1
u/marrsd Oct 02 '26
I'd probably go with C first because it will introduce you to the memory management issues that motivated the development of Rust in the first place. C also encourages you to think about how you want to manage memory, rather than just leaning on existing language features and idioms.
Rust is still worth learning, though. It brings together a lot of the best features of modern language design in a language that is quite pleasant to use for application development. I'd also look at some of the patches contributed to the Linux Kernel to see how it's also used for systems programming. I think all of the patches I've seen have made heavy use of unsafe code, and it's insightful to see how unsafe code is programmed for the kernel in Rust.
1
u/MimosaTen Oct 04 '26
C
1
u/huuaaang Oct 05 '26
While Linux kernel does allow Rust now, it's still primarily C. So if this is REALLY your goal specifically, then C is what you want.
But I'm not sure what kinds of things you expect to modify in the kernel. Unless you have some weird/poorly supported niche hardware...
1
u/Far-Championship-883 Oct 06 '26
C, rust is niche and frankly so anti productivity no real enterprise use will ever adopt it , despite the hype.
1
u/jerrygreenest1 Oct 01 '26
C
1
u/Least_Bid9692 Oct 01 '26
Go with C++
19
u/[deleted] Oct 01 '26
[removed] — view removed comment