Yes, Rust is beginner-friendly
BLUF—Rust, the programming language and technology is beginner-friendly; the official and recommended learning materials, on the other hand, aren’t. Unfortunately, a confused conflation here makes one attribute the badness of the learning materials to the object they try to teach.
Among other things, Rust is notorious for being unfriendly to beginners1. Many people have struggled with its steep learning curve and have given up before seeing any benefits (patience is a resource in short supply, after all). Even experienced Rust programmers agree that it can be tough to get started with the language. In fact, Rust’s directors seem to agree with this evaluation (of rough first encounter) and so they have committed quite a lot of resources towards preparing high-quality learning materials for the language. The official (& free) book, The Rust Programming Language, for example, is arguably the best introductory material to Rust. This is the material that the DevCongress Rust Study Group uses.
One careful look at the beginner-unfriendliness notoriety, and it becomes obvious that one thing, and one thing alone, is to blame. You see, Rust’s key feature is memory safety. It achieves that through a largely novel memory management technique publicly known as ownership2. If you’re learning Rust through the official book, you encounter it in chapter 4. The importance of grokking this subject matter is mildly but sternly emphasized at the start of the chapter (bold emphasis mine):
Ownership is Rust’s most unique feature and has deep implications for the rest of the language. It enables Rust to make memory safety guarantees without needing a garbage collector, so it’s important to understand how ownership works. In this chapter, we’ll talk about ownership as well as several related features: borrowing, slices, and how Rust lays data out in memory.
The implications are deep, indeed: at all times the Rust programmer must keep their mind fixed on ownership since the compiler rejects programs that violate the laws of ownership. Politely, but firmly. Although it tries to provide ample help to relieve any pent-up anger, unless you made an obviously silly mistake, the rejection, and the surprise it usually evokes, can mean just one thing: you don’t know what you’re doing! The feeling could easily be one of defeat. A feeling to be avoided by all means necessary. And so when we (the Study Group) arrived at the first chapter on ownership, we determined to spare no resources to make it make sense. We even invented and played several rounds of ownership-themed games. Well, three weeks of individual studies and 9 hours of group meetings later, I’m here to tell you that we really aren’t sure we have this beast under control. Worse, we’re not even sure we can ever put it under control.
Is ownership, by nature, difficult to understand?
Our own experience, and that of many other people on the internet, seem to discourage spending more than regulation time on trying to understand ownership. They say that the extra time is better spent playing whack-a-mole with the compiler. You’re going to play it anyways, and, for the rest of your life so you better get the practice in now. It would seem that experienced Rust programmers are just extremely quick at hanging some apostrophes here, a few ampersands there, and shuffling them around until voila! a permutation that satisfies the laws of ownership. But I’ve watched a few videos of Jon Gjengset at work and this doesn’t seem to be his modus operandi. If anything, Jon appears very at home. He makes mistakes, of course, but these are largely restricted to syntax and mistaken implementations. Mistakes he makes in his English language as well. He barely confronts an unyielding borrow checker. So what’s amiss here? How did these masters slay the hydra?
Well, I don’t have a data-driven answer. All I have is an anecdotally derived hypothesis that the Rust book could be accidentally making life difficult for newcomers to the Rust programming language.
In a follow-on post, I’ll lay out my constructive feedback (read: criticism) of the Rust book. While it strives to remain pedagogical, I’m convinced that the effort has been in a wrong direction so far. I’ll try to persuade you to the same conclusion in the next post in the series.
Draft reviewed by Rasheed Muhammad. All errors mine.
-
it’s important to distinguish between the two classes of beginners: the first, is a beginner to programming overall. the second type of beginner has pre-existing programming experience. they may even be professional programmers. which means they’re familiar with popular programming concepts. when rust is accused of being unfriendly to beginners, both classes are implied. ↩
-
this is not to suggest that there’s a private & different name. i’m not a computer scientist and so i’m not well-versed in the language of the field. but i’m an attentive listener, and i’ve heard rumors that ownership indeed has a different (formal?) name/vocabulary in academese, the language of academics. ↩