I have quite a lot of experience in C and C++ and a bit in x86 assembly. Let me tell you, Rust definitely should not be your first language! Even I feel Rust to be very hard to learn. I have studied it one month, but I am still not able to write any meaningful program.
But I gradually get to feel the big picture of Rust. I now know very well about the Rust compilatin model, I understand crates, modules very clearly. My next step is to translate my C program into Rust. Therefore I digged into the Winapi crate, and I am currently stuck at Rust macros. This part of Rust is quite undocumented and I also feel very hard.
However, Iâm really interested in learning Rust as a first language.
Why? You haven't listed any reasons, not even bad ones.
I received a few opinions about how to go about this, but it seems most have different views on the approach.
Having even more arbitrary opinions generally doesn't solve anything, unless you're just shopping around until you find enough people that agree with your original plan while ignoring the increasing numbers of everyone else.
Some feel learning C first would be a good way to start.
You'll find people who swear C++ is a good starting language, so I'm not sure how that means anything.
My question: whatâs the best way to approach this? I thought about getting the basic required knowledge on C to start this book on Rust36. What do you think?
I would just learn Rust. Polling everyone until some arbitrary point, learning other languages before learning this one, etc. all seem like procrastination, even if you swear 'it's just research to do things right/the best way' or any other reason/excuse.
But don't learn Rust first. Learn something easy like Python. Do you really want constant problems with the borrow checker while having to learn the basics of programming? It'd be one thing if you'd already gotten started on your own and found it to be ok, but you haven't even gotten started yet according to you...
Also, you might want to figure out why you really stopped learning Haskell and just keep going with that until you're no longer saying you need to learn something 'as a first language'. If you're jumping ship/quitting already, I wouldn't start again with something even more difficult, like Rust.
Some of this is because you already have a lot of assumptions about how programming should work. Beginners have no such assumptions, and so don't have as much to unlearn. I've seen newbies start with languages like Haskell, which experienced programmers find tough, and have a much easier time with it.
I still think the lack of resources means that it's not a great idea, but I don't think that this reason is inherently a show-stopper.
While the approach of getting started with "lax" languages like Python or Javascript is definitely getting more popular than that of teaching with "strict" languages like Ada or Rust, I would hesitate to consider it unilaterally better. Rather, I would say that it is the old trade-off between short-term and long-term thinking.
As teaching tools, strict languages make you face the full complexity of programming early on, and try to make you do the right thing right away. This is hard, and will discourage some learner types early on, and AFAIK that's the main argument against using them for teaching. In contrast, lax languages will let you get away with a more sloppy understanding early on. But you will pay for that later on, at the time where you need to debug incorrect programs or to learn a stricter language, and will then realize that many things you thought you knew are wrong. I would argue that this complexity wall is more difficult to climb than the one which strict languages make you face at the beginning, because you need not just to learn new things, but also to un-learn some incorrect things you thought were true.
In that sense, I have the impression that the best way to teach oneself programming is to go for a language which is as strict as you can withstand, but no stricter. The perfect choice will depend on each learner's character. The stricter the language you can go for at the beginning, the easier time you will have later on, but it is important not to go for something that goes beyond your patience or willingness to fight the computer, and to stay at a challenge level which you feel comfortable with.
Rust is a fairly advanced language, with many features and interplay between them. Itâs a language where you may find it much easier to read existing working code than writing your own from scratch, which may give an illusion that itâs easier than it really is. Like with learning anything, itâs usually not a good idea to reach for the advanced version of that something; start simple and build up.
Having said that, if someone is patient and methodical enough then Rust might not be a bad idea as the first language. But I suspect this will be the minority of people.
Java was mentioned upthread as a good prereq for Rust. Iâd have to disagree with it being a good language to enhance understanding Rust. It lacks a good amount of language features and the ones it has are not at all how Rust works (eg generics). In addition, itâll steer you into dynamic dispatch and classic OO, which again isnât where Rust will sway you.
Iâd have to say that (modern) C++ is a good background for Rust. Not that you should learn C++ first (you shouldnât), but if you already know it well, it should be quite helpful.
Finally, one should really try to have realistic expectations about getting to a comfortable point with Rust. One month is not going to nearly enough for vast majority of people, I suspect - no matter the background. Go at your own pace and donât set mental milestones for yourself.
Rather, I would say that it is the old trade-off between short-term and long-term thinking.
There's far more to it than that.
This is hard, and will discourage some learner types early on, and AFAIK thatâs the main argument against using them for teaching.
That's a good example of it being far more than just the above. There's also the idea of learning programming in general vs. learning a specific language. C++ and Rust are good examples of languages where you need to learn a lot that doesn't transfer to other languages, making them worse for learning programming in general.
and will then realize that many things you thought you knew are wrong. I would argue that this complexity wall is more difficult to climb than the one which strict languages make you face at the beginning, because you need not just to learn new things, but also to un-learn some incorrect things you thought were true.
That's vague and true for any language. The more you learn, the more you refine your mental model.
In that sense, I have the impression that the best way to teach oneself programming is to go for a language which is as strict as you can withstand, but no stricter.
Nice! That's why I would suggest avoiding Rust or C++ as your first language for the general case. It's not like there isn't tons of stuff to learn with other languages as a first language, probably more stuff that applies to programming in general, not just the language you're learning. Obviously, some people will be fine with anything...