Hi I’m interested in learning rust. What the best way to learn this language for non programmer or people with little know of swift or another language ? Will be hard to learn this language as first or little experience?
I am personally of the opinion that you can learn Rust as a first language.
However, you should accept that Rust is a strict (but helpful) teacher.
There is a phase with every program where you know you are almost done, but the compiler is not happy yet. In some cases, making the compiler happy will require rethinking mostly everything.
A C/C++ (or python, or most other languages) would have already accepted it, and just crashed during runtime (and lead to frustrating debugging experiences…)
I’ve seen it quoted that “Rust makes bad design more difficult in early stages”, which is a good thing, you don’t want to waste time on something that won’t end up working.
Rust forces you to know what you are doing.
Start by reading The Rust Programming Language, this gives you a relatively gentle introduction.
Especially the first four chapters explain why Rust is different from most other languages.
The “other book”, (Programming Rust) assumes a long experience with C/C++, so I wouldn’t recommend that as a first read.
Also, this question has come up several times before, do a forum Search for “Rust as first language” for some more helpful topics, suggestions and links.
my experience is that new programmers learning rust generally don’t appreciate the trade-offs, such as the borrow-checker, it takes years of messing up with threads, ownership and such in a language such as C or C++ to fully appreciate that
but if you’re going to learn a systems programming language as first language, i think Rust is a good choice, you can save yourself all that frustration !
i don’t think there is a truly ideal beginner’s language, any language will have its more peculiar corners to work through
this twitter thread was suggested on reddit /r/gamedev for learning rust, it includes some good book references: https://twitter.com/AndreaPessino/status/1042120425415700480
…if you are lucky enough. Once you opened the undefined behaviour box, your code could resemble unicorns.
Ok, joking apart, to emphasize what the others are saying: with Rust you can learn to correctly code thanks to a strict teacher (as @juleskers said), and this costs you the understanding of many concepts (ownerships, lifetimes…).
With C++ (and I don’t want to talk about C for reasons) you learn how to do basics things, then at a certain point you figure out that your code crashes once in a while. You understand that you should have enabled the compiler warnings, which now helps you find some things that were working just because you were lucky (or unlucky, depending on the way you see it). Then you discover that you were learning C++ like in 2003, and that now there are better and safer ways of doing the same things. And you go deeper in the rabbit hole, until you realize that you were just pointing to memory that was fine until you pushed a new element in the relative container.
At the beginning, it is easy to believe that Rust is harder because it does not let you do that, but if you are able to understand the reasons (and the cost of debugging a heisenbuggy UB) you will find that Rust is much easier than C++.
IMHO, you cannot compare Rust with garbage collected languages, it is like comparing a F1 car to a modern car with cruise control, automatic transmission and emergency break assist. The latter is very nice and comfortable to drive, but you will be never get the speed and the control of the former.
If you’re completely new to programming – still struggling with things like “what is a function?” – you may have a hard time starting with Rust. But I don’t think this is because Rust is a bad starter language; it’s just that the learning resources that exist are generally aimed at people who have mastered the basics. TRPL is great, but it doesn’t spend much time explaining that stuff, and the other resources available mostly assume even greater knowledge.
That’s not to say you shouldn’t try. I believe Rust is probably a good first language, once you get past the initial challenge. The hardest parts of Rust for people coming from other languages are things they have to unlearn (garbage collection, duck typing, subclass polymorphism). New programmers don’t have that disadvantage, but you may have to read between the lines a bit, and look things up when the book uses a term you don’t understand.
If you’ve acquired the basics in some other language, Rust should not be too hard for you and The Rust Programming Language is the best way to learn it.