Beginning Rust Programming

Beginning Rust Programming

 Save me from another “hello, world” book. Don’t make me have to skim or skip through a half dozen chapters before I can get to something that’s going to be useful to me. Or you, in this case. I can’t tell you the number of programming books I’ve purchased over the decades, hoping to actually learn the language, only to end up just not using the book because it wasn’t presented in a way that made a lot of sense to me. Instead of a dry explanation of how the language is constructed so you can try to put it all together in meaningful ways yourself, the purpose of this book is to jump straight into writing hopefully interesting or useful programs. Once we have the program, we can take a look at how it’s constructed. You’ll be learning by doing—or learning by example, if you prefer. I hope you’ll find this a more useful and practical way of learning Rust.

 Rust is an interesting language, as it turns out. Like so many other languages, it claims a C-like syntax, which is roughly correct but misses out on many important elements. Where Rust really shines is where C has introduced bad behavior in programming practices. This is more apparent as more have been using C as a language. Where C provides you with the gun and the bullets to shoot yourself in the foot, Rust provides you with necessary protections to keep you from injuring yourself or, from the perspective of the application, keeps the application from crashing. Rust is focused on protecting the memory space of the program, in part to provide a better ability for concurrent programming. After all, Rust is considered to be a systems programming language, meaning it is intended for applications that are lower level than those that a user directly interacts with.

 In addition to protections provided to the programmer, Rust has a reasonably active community that can be used not only for support but also to get additional functionality for your programs. There are a lot of third-party libraries. These libraries can make your life easier by introducing you to functionality without you needing to write it yourself.

 The idea behind this book is to introduce you to Rust in context, rather than via snippets that, by themselves, don’t work. You need all the surround to fully understand what is happening in the program. You’ll find this out when you are looking at example code sometimes. This is true with the Rust documentation: it’s like you need to fully understand the language to understand the examples you are looking at. This book doesn’t take that approach. It assumes that you don’t know the language, so every line in every program is explained in as much detail as is necessary to pull it all apart, since Rust can be a dense language in some ways. This means single lines can pack a lot of meaning and functionality.

 The one thing this book does not assume, though, is that you are coming to programming completely fresh. You will see examples for the programs written in Rust also presented in other programming languages. This may be helpful if you come from another language like C or Python, for instance, but want to learn Rust. Seeing the approach in a language you know before translating it into Rust may be beneficial. If you don’t know those other languages, you can skip through those examples and jump to the explanation of how to write a program for the problem under discussion in Rust. You can still compare the other languages to Rust as you are going through so you can better understand Rust and how it is different from other languages.

If you liked this book, share it with your friends, thus you help us develop and add more interesting and necessary books for you!