Does it make sense to learn the Rust language by programming?

Hi while learning a programming language, for example, is learning by doing different projects an effective way to learn it?

For example, you will learn a new language, you learn by trying to write a compiler in that language.

Yes, it does make sense to learn Rust. And no, if you are just learning to code you shouldn't try to write a compiler, try to focus on the basics like what is a function, a variable, a type, and so on.

Of course. There's a lot of things which seem hard in theory, but can quickly fall into place while practicing.

No, if you haven't created a bunch of compilers already. It's almost always better to split the tasks - learn new language with already-known problems, solve new problems in already-known language.


Certainly writing some code while learning is a good idea. Learning by doing, as they say. Rather like learning mathematics, doing lots of exercises is going to help a lot.

I suggest not tackling a large project in Rust until one has at least worked through the Rust Book and tried out a number of small programs.

I imagine that very few people attempt to write a compiler in any language until they have learned and become comfortable with the language.

1 Like

In my experience in learning Rust, of course praticing trying to code actual things with actual projects is essential to learn the language, but also I must admit that it helped me a lot to give a good brush first to the theory with the Rust-lang book.

I think that without that it would have been much more difficult to understand clearly how to solve problems specific to Rust such as lifetimes handling, ownership and borrowing, etc...


I like to recommend the Rustlings project; you get to actually write some code, but it also points you to the sections of the book relevant to each exercise, so you can read a bit about it as you learn.


I'll be a bit contrarian and say: if you want to write a compiler, go ahead and start writing a compiler. Whatever you enjoy doing.

Writing a state of the art optimizing compiler for a complex language is a huge project. But writing a basic compiler for a simple language is not that hard.

You may get stuck if you aren't experienced in Rust, but when you do you will know it and can always start doing something else.


The best way to learn something is to teach it to someone else. The second best way (with respect to programming languages) is to build something with the language.

So to answer your question...yes, do learn Rust by doing. And to learn it even better, build something in Rust, then teach someone else about what you built.


This was a great recommendation! After I read the official Rust Book I did the Rustlings project to help reinforce what Iearned and it really helped! I read the hints (even if I didn't need them) because they also point you to some good resources to read on particular subjects.

Another good one to quickly get exposed to Rust in 30 minutes was: A half-hour to learn Rust

My next read is going to be The Rustonomicon which seems like it is more advanced.

I really like Rust!

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.