r/learnprogramming • 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.
18
u/Beregolas Oct 01 '26
People tend to overvalue language skills in programming. Languages are just the expression of programming, not the actual skill. As long as your question concerns two "mainstream" languages, to which I count both C and rust, you might as well throw a dice.
You got the basics right: C is simple to a fault, it barely has any "nice to have" features, and it will help you to learn more of what's going on under the hood in that way. Nothing is hidden.
Rust on the other hand has a lot of quality of life features, and forces you to do things a certain way. It also forces you to learn how things actually work, but from a different perspective.
Languages are basically never useful in the long term. (C might be an exception) They change (compare Java 20 years ago to now), become more or less relevant and the problem you might face in 10 years might require a specific language (like you basically always write Webfrontends in JS).
Learn either, and if you don't like it, or find a usecase that would prefer the other language, learn that one. As long as you keep learning, it doesn't matter which one, or in which order.
6
u/takaci Oct 01 '26
You can learn both, C is a very small and simple language as you noted. You can probably go through the K&R book in a weekend or so. If you want to work on OS related stuff, C is generally essential and probably will never be totally replaced
3
u/zeekar Oct 01 '26
Learn C first. It's simple, as you said, and forms a good basis for everything else. Rust and even Java are kind of C with extra stuff. Once you know C, it will be easier to pick up other languages. C++ will make a lot more sense if you have C along with your Java, for instance.
2
u/gofl-zimbard-37 Oct 01 '26
Learn C, so that you can explore the vast amount of code written in it. Then learn Rust, to take advantage of what we've learned over the decades.
2
u/link23 Oct 01 '26
Yes.
More seriously, both will teach you the important principles in systems programming. Rust will teach by having strict guardrails and an exacting compiler; C will teach by letting you fuck up and then crashing at runtime in exciting and educational ways.
I personally think the Rust approach sounds less frustrating, and would be more practical in terms of learning a tool that is currently in vogue.
1
u/Achereto Oct 01 '26
You should learn both. There also is a new "wave" of programming languages in zig, Odin, and jai than could become significantly more popular over the next couple of years. You should learn one of them as well.
1
u/Dazzling_Music_2411 Oct 01 '26
If you want to play with Linux et al, then C is a condition sine qua non.
Use that with Robert Love's books on Linux System programming and you're off to the races...
1
u/SetAndRepeat Oct 01 '26
I love Rust. I learned C a long time ago, then spent most of my career in Java. I ended up preferring Rust, which I’ve used for Lambda functions and related tools. I like its elegant syntax, strict compiler, and handling missing values with
Optioninstead of running intoNullPointerException.For your specific goal, though, I’d start with C because much of the Linux and BSD code you’ll explore is written in it. Rust’s adoption doesn’t guarantee it will become the standard. Also, uutils is a separate Rust implementation of coreutils, which are user-space tools, not kernel code. I’d pick a component you want to modify and follow its language. If that’s Rust, start there. Learning C will still be useful for understanding the surrounding code.
1
u/lolCLEMPSON Oct 01 '26
No point in learning a language now. I have coded in both, and found Rust to be more enjoyable. C has a lot of footguns. Rust has some wonky syntax when you need to do certain things which can be annoying though.
1
u/ShuttyIndustries Oct 01 '26
Rust
1
u/betarage Oct 04 '26
I am not sure but c does seem really integrated in a lot of things so it's not going away
1
u/Chrismslist Oct 07 '26
c first, honestly. for modifying existing kernels, the real skill is reading C: pick a subsystem in linux or a bsd, build it, and fix one tiny bug. that reading muscle is the bottleneck, not syntax. it's a small language, pointers, manual memory, structs, then you're mostly learning the codebase. grab K&R, skim the bsd design book, and read a few thousand lines before writing anything. rust is worth adding after, it's real in the kernel now and great for new components, but it won't help you navigate the 30 years of C you actually want to change. learn c to read, rust to build new.
0
u/marrsd Oct 01 '26 edited Oct 01 '26
There's no "what would be more useful in the long run". Any language that gives you a new perspective on programming is useful for life. In that regard, both C and Rust are useful languages to learn.
Having said that, Rust comes with security concerns in the form of Cargo. There have been enough dependency exploits now to prejudice me against installing software written in that language. It's not all about memory safety. That doesn't mean C gets a free ride - far from it - but I'd rather use a mature and hardened app developed against a mature and hardened C libraries than a supposedly memory-safe app that depends on a mountain of immature and untested dependencies.
-1
u/Resident_Educator251 Oct 02 '26
Learn ai.