Foreword
Claus and I share a common history in the Rust project. We are both members of the Rust community, and we are both Rust teachers – Claus as a book writer, and I as a trainer. We spent hours and hours thinking about where Rust can be useful and how to motivate people to apply the language to their problem domain.
Rust is a surprisingly flexible language with huge potential in all domains. From server-side distributed systems down to tiny embedded devices, Rust can be your language of choice. This can be great, but also daunting. To a beginner or even to those switching domains, this can make the language harder to approach. Cookbooks are one way to deal with this problem. They give you a small glimpse into a number of different domains and somewhere to start. These examples are not meant to be used as-is. They are a starting point to iterate away from.
Rust is, in all its perceived complexity, a language based on a strong core principle: keeping reasoning local. You don’t need much context to read a Rust function. This makes small examples, like the ones in this book, the perfect starting point: whether you are using them as a reference for learning or as a basis to steadily iterate towards the solution to your problem.
To write cookbooks, you need a tinkerer that wants to play across multiple domains. Claus is such a tinkerer while also being excellent at explaining! Finding the “motivating example” is his core skill. Every time we speak, there is something new he has tinkered with. Not only that, he’ll tell you the why, the how, and the what of the bit he played with along with what the bit embodies. The examples in this book are well-researched and reasoned. This gives them longevity, even if minutiae might change.
Cookbooks differ from the usual introduction book in that they don’t pick a path or a story through their subject. They invite the reader to look around, find something of interest, and play with it. They are perfect for cross-reading and browsing. The metaphor of the cookbook is a strong one.
Programming language cookbooks are not for the restaurant kitchen. Restaurant kitchens need to ensure that every meal is of the same high quality, which is why they cook exactly by numbers. This book is for the home kitchen: you use an example once, to figure out how it works. Then you modify it or combine it with others. Sometimes, the result is pleasing, sometimes not. But you will have learned in the process. This exploration style of learning is strong and pleasing. A good cookbook sparks this process and the one in your hands is no exception.
Florian Gilcher
Managing Director at Ferrous Systems