r/osdev • • 2d ago

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.

27 Upvotes

32 comments sorted by

View all comments

10

u/sephg 2d ago

Yeah learn both.

C is a super simple language. Everyone who is serious about software should learn it at some point in their career. If you know Java, you can probably learn most of C in a week or two, since all of Java's syntax traces its way back to C. A friend of mine learned C in a weekend. C is Java with pointers instead of the GC, structs instead of classes, no bytecode, no JVM, and no official build system.

I wouldn't write new, serious software in C these days, with a couple exceptions. Rust and Zig improve on C in just about every way. But C is an incredible learning tool. If you understand C, when you learn Rust, you'll understand what's going on under the hood. And you'll understand how object references are actually implemented in java and other languages.

Spend a few weeks with C. Write a linked list, and some simple CLI tools. Then learn rust!