← See all my articles

The time I tried rewriting my OS in Rust (and why I went back to C)

A little while ago, I made a HackerNews post about TacOS. It got a fair bit of attention (at the time of writing it's still the 81st top post of 2025), but one comment stood out to me:

A screenshot of a hacker news comment

Not a bad point. Why don't I use Rust? Well, at the start there were a few main reasons:

But, literally 11 days later, I decided something. I did want to do a rewrite in Rust, but not because of Rust itself. See, TacOS is my 3rd OS project, and while it's a lot better than my older ones, it still has some bits of code from my older projects, and those bits of code are not good at all. They pollute the codebase. The reason? All of them were written in C, so it was too easy to use my old code. Reimplementing it in Rust, however, forced me to rewrite it.

Rust also had some added benefits:

I got a bit through the Rust rewrite, not super far though. I had flanterm on the framebuffer and serial output, I had a physical memory manager, a paging mechanism, and a TempFS (I never got to a VFS in the rewrite). Not even to userspace.

It was at around this point that I decided to go back to the C version and fully delete the Rust rewrite branch. Rust just felt too limited with its "safety" features and overall wasn't well suited to OSDev. I'm also just not used to it enough compared to C, to be able to use it in a low level environment.

Honestly, I feel like trying the rewrite really made me appreciate C more. Dennis Ritchie, you've done me proud!

If my article was interesting...

can I send you some emails? 😔 I promise I won't spam 🌳

I will never spam you, and you can unsubscribe at any time through the emails. I don't want to sell you anything.