Would learning Rust give me system programming skills at the same level as C?

I'm very interested in operating system programming, network programming, memory management, understanding the machine at the low level.
Until today, I only had contact with web development and, to tell the truth, I find it a bit boring.
So I was thinking of studying C more deeply, because language gives me an understanding of the things I mentioned above.
However, I came across Rust recently, watched some talks, read some texts and was quite attracted to the language. But I'm reluctant to start learning Rust and skipping steps (since C is always indicated as THE language for working at the low level) and whether or not there's no time to learn everything.
Would learning Rust give me knowledge at the level that C provides?

Thanks in advance.

1 Like

Yes, in fact I have learned more from Rust than C and C++ combined due to the excellent error messages and help from the community.

5 Likes

As a long time user of C and C++ I have no hesitation in saying for sure have a go at Rust.

In no particular order:

Rust can do anything C can do.

Rust can turn in the performance and small binaries of C.

People are already using Rust to build operating systems and in small embedded systems.

The Rust compiler delivers very helpful error messages. Which is more important than it sounds.

You may get frustrated when the Rust compiler does not compile what you think it should. However that is a lot less frustrating than having a C program compile then crash and burn at run time, requiring what can be complex debugging.

At the same time Rust provides higher level language facilities that one might expect of C++, Java, Javascript etc.

The Rust documentation is very good.

The Cargo package/build system is amazingly convenient compared to anything in the C/C++ world. More like the community package systems of node.js (NPM) and Python (pip).

As a web developer you might like to investigate WASM. Using a "real language", Rust, in the browser.

The big attraction for me is Rust's memory safety. It won't let you produce code that compiles and runs but then suffers from all kind of weird and random behavior because made a little mistake in referencing objects, arrays and so on.

I could go on...

Of course there is no limit to this idea of understanding the machine at a low level. For that the next step down is to learn some assembler.

3 Likes

@ZiCog

Thanks for the answer.

I will definitely learn Rust. I am enjoying what I have seen and heard.

Anyway, I'll have to deal with C because it's the language that is used in the Compiler course at my university. Do you think it is a bad idea to learn the two languages ​​in some ways in parallel?

I've had experience writing small C programs, but nothing that comes close to networks, operating systems, and so on.

Tackling both Rust and C at the same time may be a challenge but I think it is quite doable if you already have experience in programming, be it PHP, Java, Javascript, whatever.

I firmly believe that if once you have learned to program in any language it's not such a stretch to pick up any other as long as it is of a similar paradigm.

After all, all of programming is just "sequence, selection and iteration" all else is organizational abstractions and syntactic difference.

Mind you, I find that I get confused if I have to use two languages concurrently. Better to have time to do something in one then time to do something in the other. Minimize the context switches.

As a practical matter, in my explorations of Rust I have recreated some things that I had previously written in C/C++. Perhaps not the best way to learn "idiomatic" Rust but I wanted to see how smoothly it would go. The results were good, in fact better than expected, so I was encouraged to continue.

I also think if you are studying the in's and out's of networking, or operating system building, or actually anything in computer science, that is a totally different thing than whatever language those ideas might be implemented in. They are orthogonal issues.

Of course if a course material is presented in C, or whatever, you will need to be somewhat familiar with that.

I came to Rust because of the promise of speed and safety, but I stayed because of the error messages, type system, emphasis on correctness, and simplicity. The last point may confuse people not familiar to Rust, so I'll explain.

Rust has a relatively small number of orthogonal parts that compose really well. I think there are only a handul of features in Rust that I don't use on a normal basis. Here is a list of core features: functions, lifetimes, traits, algebraic data types, generics, unsafe, const. Everythjng else is sugar to make these core tools easier to use (lifetime elision), or combinations of these core tools (like const unsafe fn).

Rust also has strict typing without rampant coercions, and this makes code so much easier to reason about and change. If I change a type, and can be sure that the compiler will tell me everything I broke so I can go fix it.


That being said, you should absolutely learn C, it is the industry standard, and so you are bound to encounter it almost anywhere Rust is applicable

10 Likes

Thank you, @KrishnaSannasi !

What are you currently developing using Rust?

It may sound a bit flippant, but Rust will not force you to become familiar with debuggers and memory sanitizers (they work for Rust as well as for C, but you just won't need them for safe subset of Rust).

Since C doesn't come with safety guarantees, and relies on the programmer not making mistakes, mistakes will be made, and segfaults and memory corruption will happen. Getting familiar with them was part of the journey of systems programming.

Despite that, I would still recommend learning Rust first. Rust has explicit constructs and well-defined vocabulary for ownership and thread safety. These constructs also exist in C, but they're informal. So it's much nicer to learn them under Rust's guidance than to learn them from scratch in C by "winging it".

10 Likes

yes: rust works at the same level as C, you can use raw pointers as in C (through the unsafe keyword) though generally ill-advised because that way, you lose the safety guarantees that rust provides on top of C

1 Like