Non-Rust books to learn Rust

Hi all! I'm very sure I'm not the only, who just learned programming by it self.

A major difference between learn ourself from a formal way is the methodology, for example a full good course will be organized to present and teach you from the basics and needed knowledge and going up step by step, this causes to the ones who learn by them selves to have holes in the knowledge, which is very hard to fill, because how you don't know it, is hard to know what or where to look.

Think that is also usual to mostly know high level languages, which directly lacks of very basic things like Stack or Heap and more things.

From there, I have fall in this several times, Rust is very technical, we need at least some understanding of C/C++ to understand the challenges, but this is not enough to be able to understand Rust in a deep way.

I think, the language it self do not needs much of non-rust things, but if we add implementations this opens the door to memory management, cpu cache, stack, heap, hardware and even more things that I don't know!

So, what is good to learn, that is not directly related to Rust, but it helps a lot to use it? obvs try to avoid to apply this go inside C/C++, but maybe is hard find a book which handle this on Rust, and I don't know if all this follow the same logic, like makes sense in WASM?

Thx!

I see no reason one should know C or C++ before tackling Rust. What would be the benefit?

Back in the day, 1974, us youngsters were introduced to computing with BASIC and in that same year were expected to be somewhat proficient with assembly language. The former gets you into the general idea of what a program actually is and the latter starts to give one an idea of how computers work a few layers down under the hood. All that registers, memory, stack, heap, instructions stuff.

So presuming one has already experience of something like Python, or Javascript or Java, I propose a little study of assembly language. I'm sure one can find books and tutorials about that on the net.

Of course every programmer should be familiar with the Lewis Carroll's book: "Alice in Wonderland".

Another non-Rust but computing related essential book is Douglas Hofstadter's Gödel, Escher, Bach: An Eternal Golden Braid.

1 Like

The point is, that for someone already familiar with some C (or a similar language, like Zig, Pascal, Modula, Nim) it should be possible to learn Rust from the official book or other resources.

For absolute beginners, its is also possible to learn Rust. Some weeks ago we had someone in this forum, who tried hard, and made a lot of progress. But I am unsure if most people will be able to do it.

For the learning resources, most of the books published around 1980 for languages like C, Pascal, Modula where designed for self-study. So one could start with one of these, and switch after a few weeks to Rust. In this route, I would start with C -- it might be an ugly language, but it is useful to know its fundamentals. Pascal has not really survived, and the tiny languages like Zig or Nim might be later not that useful.

Actually, the official Rust book has already a lot of detailed explanations addressed to beginners. Perhaps a beginner should just create a list of all the points that are still missing from the official book, so maybe someone could create some form of a chapter zero introducing all the missing foundations?

My personal feeling is, that for many beginners today the problem are their expectations: When we started as young boys some decades ago on the C64, Atari ST, or Amiga 500, we were happy when we were able to print some lines of texts on the TV-tube, read in some numbers, and make some basic arithmetic calculations. Sorting some numbers, moving an object on the screen, or using a few basic assembly instructions was for us already something that made us feel like advanced nerds. Today the expectations are often much more advanced, the desire is to create a great video game or another larger application after a short learning period.

1 Like

Actually it is not too difficult to find free material. A short Google search for "introduction to computer science free book" gave me the following page:

Introduction to Computer Science

One of the listed titles is Computer Science I with the PDF https://cse.unl.edu/~cbourke/ComputerScienceOne.pdf

I think this is not a bad start for a free book, but you might also study the other resources.

Of course, instead of books, one could also search for "beginner programming tutorial" but whenever I do that, I typical get pages with a lot of advertising, so I instantly close that pages. And I think such "tutorials" have often only a few dozen pages or even less, which is a bit too short.

1 Like

Hi, sadly is not that easy, if you look like.. the table content and you know, you can know what you need from there, is we have holes in our knowledge, we can't recognize if is useful or not, from there is not practical to read a lot of books that could possible tech us something.

And thx for the book! can be hard to know how much "computer science" is, and what involves.

So the best here, would be try to say content that is not from rust but is needed, some aligns that help us to find thins :3

I have looked in programming things, the issue is that is very usual to that books cover mainly the language it self, they pick as assumption you already know computer science.

@ZiCog I had some experiences talking to ppl about Rust, and one of the challenges is the next one "why should I use Rust instead of python if I can do the same and a lot easier in python?"

Rust solves a loooot of things, but to recognize and know the value of Rust, you need to know that challenges, how heavy they are, why and how they impact, so this also causes to ppl who underestimate computer science makes hard to choose Rust.

I don't think this is the case. In general, learning Rust demands from the learner to know about CS concepts such as heap, stack, references, and so on. You only need to know about C concepts if you're doing FFI, but then, that should be an obvious requirement.

In my journey learning Rust I've had to go deeper than ever before on CS terms, but to be honest it's only needed on very specific ocasions. Most of the time you can write Rust code with higher-level abstractions just fine :slight_smile:.

1 Like

Right! we have closer experiences in that, a is there suggested CS books which helps in rust that does not go deep on C/C++? or maybe we can't avoid that!

I have not needed to read any books. Just focus on one concept at a time, and there's tons of learning resources: blog posts, videos, stackoverflow answers, and so on.

I would even argue to stay away from approaching such concepts from a C/C++ point of view, since that will only induce noise in the learning process.

As a not-one-language-specifically book, I quite like The Practice of Programming - Wikipedia -- the comparison of how a bunch of different languages handle the same problem in there is a good look at how you might pick the right thing for whatever concrete thing you're trying to do. While there's lots of places where Rust is better than Lua, there's also a bunch of places where Lua is way better than Rust, for example.

1 Like

That would still cause issues and holes in the knolodge, so the main question keeps open about what to know to learn better Rust, which concepts, where are well explained.

I have seen a lot of videos for example one topic, and the time to reach the video, or the videos that finally explain a concept can be very high, is not very practical. A good book, with concept, methodology can save a lot of time

You might be a bright one. I saw some people trying that -- some years later they were asking the same basic questions in forums, having made zero progress.

For most people good books are very helpful, when that people are able to read. Finding good books might be difficult -- at Amazon there is now a lot of pure garbage. But I agree, with AI detailed books are not any longer that important. When one is able to ask the right questions, AI can help a lot in the learning process.

right, and for that we also need a minimum to know, at least enough to know what is good and what is bad to change the question it self, which also do not prevent to tech you something very bad... I have used it for things I know to look, is nice! but seems risky for someone who is starting.

TBH, I think some of their detailed explanations are unnecessary, depending on the intended audience. I'm thinking of chapter 4 in particular, which I just reviewed (for the official Book and the Brown book).[1] It heavily overemphasizes the "stack vs. heap" perspective, making it seem like Copy is a "stack data"[2] property and like borrow checking is solely concerned with dangling (heap) pointers and the like.

(The Copy conversation came up in another topic with the OP a couple weeks ago.)

If one understands when local variables drop and that owners like Vec<T> drop what they own recursively, I think a lot of the details on the level of "here's how the call stack and global allocator work" could be replaced with a higher-level "got destructed and cleaned up resources" presentation. This would also have the benefit of getting away from saying "free heap memory" as if it was the only ownership and resource management concern, "popped off the stack" as if it was the only time a destructor ran, etc.

It could be an interesting exercise to rewrite the chapter to eliminate a lot of the low-level details and mix in non-heap examples (like say File).


It is my suspicion that a lot of this material, and similar other learning material, was written by people with a C/C++ background. There are a lot of examples that amount to "If you wrote this in C, you might do this, but oops see how that leads to a UAF or w/e. That's why Rust's borrow checking is great!" But if your audience doesn't have a C background with all the knowledge and background that entails, the examples are far less effective.[3] You wouldn't necessarily think about the problem from the same perspective at all.

The Brown Book does this repeatedly with exercises like "Imagine this compiled. Is there undefined behavior? If so why?". But then they only consider certain types of undefined behavior! You, the reader, have to read the instructor's mind and infer what point they were trying to make (usually something about reallocation double frees, etc).

First of all: That's not only misleading, it's dangerous, as it gives the impression that if you could reason enough to avoid allocator related problems / write it correctly in C,[4] you could sidestep the borrow checker with unsafe and have a sound program.[5] But aliasing &mut _ are automatic UB, as is writing through a &_ without an UnsafeCell. And these show up in answers to their quizes which they claim are not UB.

But second of all, if the reader doesn't have a C background, it's going to be challenging to make all the same assumptions implicit in those questions. It's almost like you have to learn a subset of C in order to make sense of the material that's supposed to be teaching you Rust.

Given that the Book is not intended to be "Rust for C Programmers", I think it would benefit from some rewriting to present things in a more general or higher-level way. And a more accurate, Rust-specific way! For example, if you internalize "aliasing a &mut _ is UB", a lot of the low-level details[6] become somewhat moot. (How that helps ensure memory safety is great for understanding the motivation, and should still be pointed out, but memory safety need not take the center stage everywhere while we pretend other considerations and other types of UB don't exist.)


  1. Maybe I'll write it up sometime. ↩︎

  2. there is literally a subtitle that says "Stack-Only Data: Copy" ↩︎

  3. And/or have to be preceded by a sidebar explaining how the heap works, etc. ↩︎

  4. perhaps a -fno-strict-aliasing dialect ↩︎

  5. They also make many assumptions about how things outside of their control are implemented (iterators, indexing, methods more generally); the reader is implicitly expected to make the same assumptions. ↩︎

  6. and the assumptions you have to make about what goes on behind the public API ↩︎

Generally, The Book was written from a Ruby/Python perspective, and Programming Rust was written more from a C/C++ perspective. (Stated at a vague overall level, so not true for all parts, but that's generally my understanding.) The Book would talk way less about the heap and stack and pointers and such if it could assume C experience.

Many good programming books - this one is not language specific:

John Ousterhout, A Philosophy of Software Design

Ousterhout is the author of Tcl - many other achievements.

It is certainly not necessary to know C. But, in my opinion, knowing C helps you greatly appreciate Rust (in my head, I see Rust as a "much better C"). Note that you can get a general idea of C in a few days: the language is actually very simple; it suffices to follow this excellent book: The C Programming Language - Wikipedia. Unfortunately, only with some practice (e.g., when you hit your first segfault) you may understand C's limitations. The raison d'être of a memory-safe system programming language like Rust may then become apparent.

I do appreciate what you say there. But I feel everything one might want to demonstrate to a student of Rust by having them start with C can be done in Rust anyway. The C step is redundant and time wasting.

I wrote some notes as to why here:

1 Like

Actually I fully agree -- that is why I wrote my book, and that is why The Rust Book (Abridged) | The rs Book has been created a few years ago.

But we have to admit, that the original and the one from Brown University have strong fans -- the rating at Amazon is very high, and some call both books "excellent". I just call them good enough, enabling most people to learn Rust. What is indeed also nice for a free book. For the intended audience, that is not that clear. The book has a lot of detailed explanations, which are boring for most, but might be useful for absolute beginners. But my feeling is that for absolute beginners the explanations are still not sufficient. For the Brown book, the pictures with the stack frames and these "permissions" are not easy to understand, do not help that much, and are not really necessary. For the quizzes, some are a bit difficult, some trivial. I think the Brown book makes the learning process much slower, harder, but delivers a slightly deeper understanding, which is not necessary in the early learning process.

And finally, my "Rust for C-Programmers" might have a misleading title. It has not too many C comparisons, and is fine for all with a minimal understanding of system programming. For most people it is a much better introduction to Rust than the official books and most other books available, including the one from Jim Blandy. Note that I have recently added an appendix linking to your advanced lectures as first reference, and also links to other useful resources.

1 Like

Well. all this started with a question in other thread, about generics, which after peel layer by layer was mainly a confusion about the Copy Trait, all ppl helped a lot clarifying all the points, and was mainly split the logic to what Rust wants, its own layer of abstraction, for example remove Heap/Stack from the concepts and put them in the right place.

That Rust clarifications opened a new door, what do we need to know, when we want to use Rust with other topics that are not Rust?

If we want to implement a custom Vector with Memory Management, probs would be good a book or resource that explains Stack/Heap, and we also need how to manage Heap from Rust.

If we want to handle CPU Cache and do optimizations there, what I need to know and which resources helps to do it in Rust?

The first questions a those, but there is something odd about them, you first need to know something low like "CPU Cache" to then try to find resources, while we don't know this concept we will can't find nor learn!

So, what is missing here a link from Rust to Other Concept, or in reverse from Other Concept to Rust, we need a way in the docs to find and know this, so books which shows "Other Concepts" are very valuable, because they will tell us where to find the rust resource, like if the book tell you "Heap" for "Memory Management", now we can find a lot of resources!.

So, there should be CS books that teach you concepts that can be implemented in Rust, that helps us to learn more about this.

This, and many other optimizations, are done by the compiler's "back end", which in the case of Rust (clang, swift, and others) is LLVM. So to understand these optimizations, you do need to understand LLVM to some degree. And you can look at the assembly to see the final result.

1 Like