Learning Rust with Official Books & Documentation

Hi

I'm trying to learn Rust and I'm having some difficulties. I just finished Traversy Media's "Rust Crash Course" tutorial and loved Rust, but:

The Rust Programming Language + Rust by Example I think both are not suitable for beginners. In both, many chapters seem to be written to be used as a resource on the subject rather than teaching the subject.

I have a theory. These two books may be the source of the common view that Rust is difficult to learn. If you read a 600-page book in which every detail of the language is written to learn which language, you may think that the language is difficult. These two books are recommended for anyone who wants to learn about Rust. Think about the rest.

As a solution, I think there may be a light version of the book for beginners. This version will have the most important and widely used features of the language, but not abstract and elaborate theories.

Another solution would be to not recommend the same books to anyone who wants to learn Rust.

Many books and other resources can be recommended, with categories such as books for beginners, books for those who want to improve their knowledge.

As a final solution, it is left to the experts of the book writing business, only the focus can be on the documentation.

I am seriously considering this. If I had started Rust with these two official books, I might have postponed learning about Rust to a later date.

The Rust Programming Language Do not skip the guessing game in the 2nd part, which is called "you can read the other parts first, then come here" in the introduction, I think it was one of the most useful parts. The "Common Programming Concepts" and "Understanding Ownership" sections, in which the basic concepts of the language were explained, were also good. BUT in the book, every feature of the language is tried to be explained, but there is not much guidance on what is important, this leads to information crowd and scatter. That's why I only finished the first 10 chapters. On the other hand, the general opinion about the book is that it is good. The content in the online version I read covers Rust 2018, supports versions 1.55 and higher. The release date of 1.55 is September 2021, but this topic is left unexplained. (561 pages*****)

Rust by Example An online and interactive book on Github by Steve Klabnik and other contributors. You can run the sample codes without leaving the browser. Same problems here. That's why I passed some places quickly, even skipping, but I still completed them.

"Teaching a programming language" is not usually understood to additionally imply "teaching the very foundations of programming and computer science itself". For this reason, "General learning material for Language X" is a completely different scope from "Teaching the basics of programming using Language X". The former is suitable when you are a beginner to the specific programming language but not to programming in general, whereas the latter is required when you are a beginner to programming in general.

Unfortunately, the "Teaching the basics of programming with Language X" kind of material is, by its very nature, not suitable as a general language guide, and authoring it is a thankless job, because:

  • it will have to be significantly more detailed, more elaborate, incorporate a much broader body of knowledge;
  • meanwhile it will be able to cover only a very small portion of the most basic aspects of the language, catering to a much narrower audience.

As such, I don't think that an "introduction to programming using Rust" material should be regarded as the responsibility of the official Rust team. Writing this kind of textbook or beginner-level tutorial should probably belong to courses and contexts specifically tailored with pedagogy in mind. I would appreciate if teaching Rust at universities were a norm, for example, however, that is a very different set of responsibilities from those of an industrial language design, implementation, and management team.

7 Likes

Just to throw it out there, I teach a sophomore-level "introduction to systems programming" course at a fairly prominent university. We currently use C for all the programming exercises; we've talked in a hmm-that-might-be-nice sort of way about switching to Rust; one of the biggest obstacles to actually doing that is that "introduction to programming using Rust" textbooks don't yet exist.

I dunno what the right venue to start a "Rust for education" SIG would be, but -- I don't have time to write an entire textbook all by myself but I would be interested in collaborating on one.

9 Likes

Exactly.

By the way, I didn't mean this. :slight_smile:

1 Like

I would love to see what would happen with that, especially if it was people actually new to programming. I'm so curious if the ownership restrictions might just feel natural -- well, at least as natural as indirection ever is -- to people not primed to expect something else.

6 Likes

I think it will feel natural, but not because it is natural. Imperative programming is deeply unnatural, but people new to programming feel it is natural once they learn. (e.g. people do think x = 1; x = 2 implies 1 = 2 due to transitivity of equality. That's why syntax like x <- 1 is often proposed. But confusion is gone once it is learned.) It's just that anything feels natural if you learned it first.

I pretty much nodded when Hillel Wayne wrote about it:

https://twitter.com/hillelogram/status/1458249103364739073

1 Like

Another of the things we've vaguely contemplated doing is a formal study on exactly this. It's also gated on a good intro-to-imperative-programming-in-Rust textbook, because if you don't have solid and directly comparable teaching materials for both Rust and the control language, then you're only measuring the difference in quality between the two presentations.

My own experience when learning Rust was that ownership and lifetime were things I was already thinking about, and it was so nice to have the compiler help me track them -- but I came to it from the land of multi-million-line C and C++ codebases, which was also Graydon's background, so I don't find that surprising.

The median student in the course I teach has had one or two terms' worth of practice in one of C, Java, Python, or Scheme, which is unfortunately just enough practice to embed some serious misconceptions and not enough to sand them back out again. Plus, of course, if it wasn't C then the paradigm shift to unmanaged memory hurts.

Big research question #1 in my head: Might it be less of a painful paradigm shift to go from a Python-type interpreted language, to Rust (where you have to pay attention to the allocations but the compiler catches many mistakes and there are lots of stdlib conveniences to help out), than it is to C (where the compiler sits back and watches silently as you corrupt the heap, and the stdlib is actively malicious)?

Big research question #2 in my head: How much of the material covered in Computer Systems: A Programmer's Perspective (that's the primary textbook for my course) is easier to teach using Rust, and how much is harder? Alternative, narrower formulation of the same question: If you try to write a classic boundary-tagged malloc implementation in Rust, how much is the language going to help, and how much is it going to get in your way?

4 Likes

Yeah I'm nodding along with Wayne too. A lot of the inessential struggle in my course (that is, students having trouble but not because of something we are actually trying to teach) is down to either shitty 70s-vintage Unix tooling that we don't have time to cover properly (e.g. Makefiles) or students trying to reason about a C program as if it were a program in a garbage collected language. The latter is exactly the thing Wayne is talking about.

(If you're wondering why "how to reason about programming in an unmanaged language" isn't part of the formal teaching objectives for this course, it's because it's supposed to be covered in the immediate prerequisite, only that course seems not to make people really confront the nature of unmanaged memory the way mine does.)

Ah, yes, that's a classic. My university had the engineers take the intro to programming course in Java from the CS department, then expected them to know C from that for the microcontrollers course :roll_eyes:

1 Like

By the way, I'm curious about the opinions of the author of the book, Steve Klabnik. He's from Rust's core team. His thoughts on the subject would also be valuable.

Ever since I learned about Third Reich, every innocent use of the phrase "final solution" gives me a chuckle. In this topic, for example, it implies getting rid of all the struggling learners, which, I believe, is a strategy C++ committee adopted back in the day, judging by current state of C++.

On a serious note, I'm pretty much on the same page as @H2CO2. It could be especially hard to teach a total noob a language like Rust, which is a weird mixture of high-level and low-level concepts at the same time. A much as I love it, I don't think it's ideal for beginners yet, and it may never be (IMO that's ok). My idea of education for beginners is some kind of a reasonably powerful high-level language, e.g. Standard ML or Python, sprinkled by a little bit of assembly - just enough to give an idea of what makes all the bells and whistles work. As for Rust, it's best suitable for more seasoned programmers, that can deal with the official docs, which are wonderful, by the way.

Hi, I'm a co-author of The Rust Programming Language. Thank you for your comments! I agree that the book can't be all things to all people, and maybe it tries too hard to be that. I've also gotten comments exactly opposite to your comments: that the book doesn't go into enough detail, that it doesn't cover every topic (believe it or not, there's definitely still more about Rust that the book doesn't cover), and that Chapter 2 glosses over too much. There are people who would prefer that the official book would be more of a reference rather than a narrative introduction.

Overall, I'm not inclined to make major changes to the book at this time (I'm in the middle of a refresh for a print version including Rust 2021 Edition where I'm trying to fix issues that are bigger problems than typos but smaller problems than chapter rearranging). However, I am very much in favor of the creation of more resources aimed at different audiences, teaching in different ways given what we've learned about teaching Rust, etc. So anyone reading this considering the creation of new Rust learning resources: PLEASE DO!!! :heart:

15 Likes

Yes, there are many different aspects to consider. Thank you for the explanation.

one of the biggest obstacles to actually doing that is that "introduction to programming using Rust" textbooks don't yet exist.

Begin Rust by Michael Snoyman seems to fit what you're looking for. It's a Rust textbook with completely new programmers as its intended audience.

I have not read it though and have no idea how well it actually does what it attempts to achieve. Browsing its "What's Covered" list of topics, it seems to not cover more advanced topics such as smart pointers and concurrency primitives, among other things. But it might make for a good companion to The Rust Programming Language's treatment of these more advanced topics.

As someone who is very interested in seeing Rust become more widely adopted in programming education, I do wonder how much course time must be dedicated to focusing on teaching the Rust language itself before students feel comfortable enough with it to veer off into the actual intended topics of the course (whether that's systems programming, operating systems, compilers, etc.).

1 Like

The ultimate Rust lang tutorial. Follow along as we go through the Rust lang book chapter by chapter.

Now I like the book more. :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.