I'm a web developer who's become more interested in programming. I've explored other languages like Haskell and found it interesting. However, I'm really interested in learning Rust as a first language. I received a few opinions about how to go about this, but it seems most have different views on the approach.
Some feel learning C first would be a good way to start. 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 Rust. What do you think?
Well i don't know C that much, and my first language is Python.I wanted to learn a new language and didn't seem to like C that much that i would continue learning it, but i found Rust. So from my perspective you don't need to know C, it is probably better if you knew it though.
I also don't come from a programming background.I learned everything online.
Knowing about low-level memory management concepts like stack vs heap allocation, pointers, and layout of data types in memory may be helpful in understanding Rust.
However, learning C first is unnecessary. In fact, C has its own quirky ways of handling arrays and memory management that you would need to unlearn to use Rust proficiently.
A friend of mine has known Python for over a decade and a half. He taught himself to program (he studied to be an electrician) and he did a few attempts at learning C, always ending up feeling overwhelmed and getting tired of pointer handling and all the manual resource handling. Recently he gave Rust a try and his first comment after a few days was “well, of course it's not Python, but contrary to C, Rust actually feels sane”.
From our conversations, my gut tells me that Rust can be a good option even for people who may not have a formal CS background
Having tried to learn C at age 12, and since having learned/dabbled in ~5 other languages for work, learning rust sounds smarter to me than C.
C will let you get up and running quicker in the same way that you can get around the Tsjernobyl radiation zone "quicker" without the radiation suit.
It'll work, but all the sneaking mistakes will silently pile up until they kill you.
Rust is a harsh, but fair mistress. It will take hundreds of (friendly, helpful) compiler warnings before things will work, but you'll save yourself So.. much... Debugging!
At RustConf 2017, Andrew Brinker gave a talk named A Tale of Teaching Rust:
The conclusion was that Rust can definitely be taught to new programmers. Learning C is not a requirement — but since the languages belong to the same language family, knowing C will of course help you learn Rust. However, I would also say that knowing Rust will help you learn C later, if you decide to make that effort. You'll then probably find C to be a dangerous, primitive and unhelpful cousin of Rust, simply because it has much fewer safety features.
This was such a great presentation. I appreciate the guidance on the order in which he introduced concepts. It made a lot of sense and can see how it would work for new dev. This talk gave me the courage to set aside a couple small rust projects to give our interns.
Both Rust and C being systems programming languages are only concrete implementations of many abstract CS concepts. C is more involved than Rust in the same way as driving a manual transmission is more involved than driving an automatic one. But learning to drive a "stick" does not make one a theoretical physicist. Learning C is not a substitution for learning basics of computer science either. And in my (limited ) experience CS basics are more important in day to day programming than knowledge of physics is in day to day driving.
This is my way of saying that learning C (in my limited experience with CS, programming, C/C++ and Rust) is not a prerequisite for learning Rust. But If and when you decide to use Rust for actual systems programming (OSs, drivers and such) you might want to learn C, because of its status of lingua franca of systems programming (millions and millions of lines of relevant code written in C).
If you want to learn Rust, I would recommend to learn a language without memory management first (in hindsight, I would pick Python, Go, ML or Lisp) and skip C. The Rust book is designed for people who come from languages without memory management, so I don't think learning C first is necessary.
Knowing a bit about C is mostly useful for some rather advanced stuff (interfacing with other languages, implementing libraries that communicate with the operating system). The basics about memory management are better taught with Rust IMHO.
Well, I tend to think first languages are those you know more than the rest. Though, in my case, I learned Java, moved on to C/C++ and never touched Java again. Had Rust been around in 2003 and my first language, I'd likely be a master of it. C/C++ I know most of (though a few things in recent standard revisions are difficult to understand) but I do struggle with algorithms, especially bitwise ones. I've been into Rust since about April and I know much, but I also still look at Rust code thinking "holy hell, what IS this??"
Yeah this is a great resource I just went back and looked at it. One thing is, it is a tad out of date, it looks like you can do all the things that used to require nightly in stable now. And I think at the time that was written Rc's didn't have the ability to be weak references, which might make it easier to do a doubly linked list. Like using weak references in one direction so that dropping the head drops the whole thing. But I don't know if that would really work or not. Anyway it is a great article.
I'd say that Rust is a perfect first language. The compiler errors are very helpful to point out exactly what you've done wrong in most cases, and it's helpful that you can be guaranteed that your program at least runs properly without a segfault after it compiles. In addition, as a modern multi-paradigm systems language, you are taught a large array of concepts and features from the getgo. Many of which would be completely unknown to someone who learned only C.
As C is such an incredibly old language, it's very limited in the amount of knowledge that it can pass on to the programmer. Where someone who first learned Rust and then went onto C would have a solid understanding of approaching problems with more sophisticated solutions, a C programmer who then moves onto Rust will likely have hundreds of bad ideas that they learned when writing C solutions, and may not understand at all as to why their solutions are bad when they 'just work' in C. They'll also be completely unaware of possible superior solutions that are idiomatic in every day Rust software.
I've generally seen that those who come at Rust without any preconceived notions about programming tend to fare much better in the long term than those who approach Rust with learned notions from other systems languages. Hence, those who approach Rust with a C mindset will often struggle, whereas someone who has never experienced C will have no problems easily digesting the rules. They are much less likely to fight with the compiler. I've mentioned it before, and I'll mention it again: Rust's compiler is like a Chinese finger trap. Those who find Rust difficult are those who try to fight it. Eat your vegetables and you'll do just fine.
This mostly confirms my thoughts each time I made an attempt to learn C. Rust is moving at such a fast pace, I feel a year from now the documentation and training will be a key to the success of this language. I’m currently working my way through RustConf 2017; lots of great things to expect in the next year!
@vks your comment stood out to me the most. I've since started to learn a language as suggested, though, I'm not sure it's entirely what you recommended. Maybe I could get your thoughts. I started learning Haskell via Haskel Programming from First Principles. Thanks.
I don't really have a strong recommendation for a specific first language, so I just listed some languages I know and like. I didn't list Haskell, because it avoids the imperative approach common in Rust, but so do some Lisps. (There are a lot of other things in Haskell that are similar to Rust though.) In my opinion, Haskell is a solid choice as well.
Being a web developer, do you already know JavaScript? I think that would be enough to get started with Rust.
Rust is the hardest language I have ever tried to learn. Over the last 20 years I have used C, C++, PHP, JavaScript and Python, yet I found Rust to be toughest nut to crack. It definitely should NOT be your first language.
The Rust documentation is not designed for a beginner. If you have another programmer to help you and answer your questions, then maybe you could do it, but if you are on your own, then you need to a book that assumes that you are a beginner. There are a number of good C, C++, Python and Java books that are designed for beginners.
Personally I would go for Java, since it easier than C/C++, but it has a similar syntax to Rust and it will teach you about data types and classes, which will help when you get to Rust. However, if you really want to understand why Rust was designed the way it was, then learn C++. I recommend Steven Prata's C++ book (not the Kindle version), since it goes very slowly and explains each concept in depth.
Great response! I would’ve never expected someone to recommend Java to learn Rust, but I did think about C++. Anyhow, since this post was made, I’ve mostly been digging deeper into JavaScript. However, I’d love to get more into a systems programming language eventually. Thanks again!