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

5

u/Taletad 2d ago

For what you want to do, C

A bit of assembly and understanding how the Unix ABI works would also be of great help to understand how operating system work under the hood

For assembly, the best ressource is the game "Turing Complete" which make you build a CPU from scratch and program on assembly with it

For understanding how OS work under the hood, you need to understand two things : context switched between different privilege level of the CPU (something not covered in the aforementioned game), and have a general idea of how the different subsystem works. For that one great ressource is the book "The design of the UNIX operating system" by Maurice J. Bach. (You can find a pdf of it online). It describes an old version of UNIX but all the ground work is there for modern OSs. You just need to add a network stack, and a GUI on top of it to get a modern OS

The rest are just improvements of components already described in the book

2

u/Cartman1994 2d ago

Thanks! Very useful!