Comment by nicoburns
3 years ago
> at the point my impression is that Rust is the consensus best overall systems programming language (assuming you’re starting something new). Is that just me or so others share that perception?
I think I'd probably agree with that impression. It's the route I've taken into "systems programming", and I don't regret it at all. The big advantage of going Rust-first for me is that C and C++ have so many unspoken rules that you need to follow in order to avoid security issues and hard to debug errors, whereas Rust codifies most of those as compiler errors. That makes it a lot more accessible for the beginner to learn not just the basic syntax, but a best practices and good habits.
C and C++ are still the mainstream at the moment, but I think they've peaked and would expect their popularity to wane over the next 10-15 years. On the other hand, Rust has only just hit the mainstream in the last year or two, so there's still a few missing pieces and adoption is not yet that high, but I think it's by far the best intro low-level language overall.
> The big advantage of going Rust-first for me is that C and C++ have so many unspoken rules that you need to follow in order to avoid security issues and hard to debug errors, whereas Rust codifies most of those as compiler errors. That makes it a lot more accessible for the beginner to learn not just the basic syntax, but a best practices and good habits.
Yes, I agree this is the big advantage for me too. Rust allows mediocre devs to build more ambitious systems than they would have otherwise attempted in other languages. You can certainly build anything you want in C++, but from my experience due to the number of, as you put it "unspoken rules", novice developers will encounter a lot of foot guns. It leads to code that works but is very brittle; if you look at it the wrong way, it ends up segfaulting.
Rust says "You can't run this until we're sure it's not going to violate any of my assumptions of how a system is built" and it goes through your code with you to check off all the boxes. Is this thing mutable? Does it have more than one owner? Yes? Well then Rust says that's going to lead to pain in the future and prevents you from doing it. C++ will let you do it and hope that the learnings from the pain you encounter in the future due to your poor choices will prevent you from doing it again.
When I started learning Rust in 2015 the biggest thing in C++ I had built was a robot, and in that world you do most of your work as message passing. It's really more like a style that Erlang devs would find familiar. It's really not equivalent to doing systems programming in the OS/compiler sense. I found Rust very hard to use because I had poor habits in terms of object lifetime and ownership management. But over time the I figured out what the borrow checker wanted and in doing so, it made my code sounder, and therefore far more robust than what I would have put together in C++.
Going forward I apply these ideas to all languages I write in, so this is why I teach Rust in my PL course: even if students aren't going to write Rust in their future career, I've found it makes them think harder about variable lifetimes when they switch back to C and C++ in the OS course.