Thoughts On The Rust Book Guessing Game Tutorial

January, 2023

The Problem

The Rust Book doesn't work for me. I wrote an initial post about that here. I was going to write a more details post, but it largely boils down to this. The book starts with a basic hello world and then moves to Chapter 2 "Programming A Guessing Game".

The code for the guessing game ends up being 35 lines. It includes a random number generator, a comparison module, and gathering user input from the command line. It demonstrates the difference between mutable and immutable variables, different data types, references, Result values, enum types, the Ok and Err variants, using .expect(), the {} Display formatter, installing and updating crates, the Cargo.lock file, matches, chained methods, and loops with continue and break, and notes about the prelude of the standard library that's loaded in by default.

That's too much stuff for the first program after Hello World. I can't keep track of it and that makes me feel like I can't do it. Worse, I waste the precious little mental energy I have trying to figure things out without anything to show for it.

Context Notes

I wrote in the earlier piece that there was too much context or prose and not enough code.

To clarify that. I don't mean context about why you want to do something. Lots of posts and tutorials start off with "I got tired of this so I came up with this solution" prefaces. I've got no problem with those (as long as they don't turn into a life's story like recipe sites) The context I'm referring to is more like this snippet:

"As mentioned earlier, read_line puts whatever the user enters into the string we pass to it, but it also returns a Result value. Result is an enumeration, often called an enum, which is a type that can be in one of multiple possible states. We call each possible state a variant. Chapter 6 will cover enums in more detail. The purpose of these Result types is to encode error-handling information."

That introduces a bunch of concepts but tells me I won't learn about them for another four chapters. More mental energy gone with nothing to show for it and I feel worse about myself for it.

There's More

I could go on about frustrations and difficulties. It wouldn't serve much. I think about this stuff a lot and there's nothing here I haven't hit before.

My current thinking about how to make things better is here if you're interested: Tutorial Thoughts