What alternatives are there to C?

Because of Zed’s criticisms of C I’ve started wondering about what alternatives there are to it.

I have a Raspberry Pi 3 and an old Pentium 4 pc, I would like to play around with trying to write a simple kernel that will run some text on the screen in one of these two computers. Maybe I’ll even try to write a simple OS.

I’ve seen a course on C++ but I keep hearing about how complicated it is. Is C++ a good alternative to C?
I know that they are two separate languages and the similar names are only because of their shared history.

I’ve also been hearing about a language called Rust, though from what I’m aware it’s not yet possible to write something for the bare metal, there’s an OS called Redox written in Rust that can only be run with a virtual machine.

1 Like

C++ can be a good alternative to C, if you restrict the features you use, but C++ can also be this insane language with so much that nobody can ever really be good at it.

I believe that Go and Rust are the current best alternatives to C. Go fits the use of C as a systems tool language. I’d use it for things like servers, command line tools, and so on. Rust also fits that usage, but Go really has focused entirely on that space. Rust seems to be a good replacement of C for things like operating systems, embedded development, and similar where you need very bare metal access and no memory management.

Check out Steve’s Rust OS for an example https://github.com/intermezzOS/kernel


Zed, can C++ be exploited in the ways that C can? Or did it’s developers fix them?

1 Like

C++ can totally be exploited the same way, but if you code C++ with modern things and avoid all the bad parts of C (as in, use it like a better C), then it’s a lot less likely. Rust is similar in that you can still exploit it the same as you would in C, it’s just a lot less likely and the impact is a lot smaller when you do.

Here’s a great writeup by my friend Tony where he explains this very thing: