Rust first impressions
A recent blog post about Rust intrigued me enough to give Rust another go. I’m probably going to walk away from the language for now, but the process of learning really underlined how the philosophy of a language not only influences its design, but even its prose.
For instance, if I were to choose a word for each of the various languages I’ve learned:
Python’s whole vibe is empowerment. It’s so many people’s first language that it naturally has that tone in its community and documentation. You can do it! On the other hand, Golang is incredibly articulate. Their language is small, but sufficient for its use cases. The golang blog itself is incredible. Their posts tend not to just tell you about language updates or features, but to lecture you a bit about programming. I’m sure for people with computer science degrees, its all very redundant, but being self-taught, I’ve learned a lot.
Rust’s entire focus is on power and correctness.1 Every possible nob exists. But there’s very little thought given to a new user’s journey. Take strings. The difference between
&str is not clear. This Rust by example doc helps a bit: it has something to do with the difference between vectors and slices (which are also separate from arrays). Keep in mind, you don’t know what vectors are yet. And whether you’d use
&str isn’t fully clear: you’ll need to understand
lifetimes to fully get it. The whole tone of the book is (paraphrased from the book) is:
We'll discuss Rust [insert feature] in more detail in Chapter [insert number]. For now, you just need to know that...
Rust is verbose and the programming language’s verbosity bleeds into its tutorial.2
The main reason for using methods instead of functions, in addition to providing method syntax and not having to repeat the type of self in every method’s signature, is for organization. We’ve put all the things we can do with an instance of a type in one impl block rather than making future users of our code search for capabilities of Rectangle in various places in the library we provide.
Why not just:
Methods let us organize functions related to a type in one place.
That’s it. No conclusion. Just fascinating how much a perspective, even a technical one, can bleed into the non-technical prose.