I spent the past few days working through the first 3 chapters and the first 23 sections of chapter 4 of the Rust book. Here are my initial thoughts on Rust:
- Cargo is pretty sweet. It’s an easy to understand build and dependency management system. Even though I’m only using it for simple things so far I’m really happy with it and have not run into any issues. I’ve also gotten very used to running
cargo new <project_name> [--bin]
to start new Rust projects.
- Compared to Go, Rust is a much larger language, with many more concepts to learn. Go is a simple language to learn. I feel that Rust has a steeper learning curve.
- Memory safety is one of Rust’s strongest selling points. It is one of the trickier concepts to understand and is unlike anything I’ve experienced in C, C++, Java, Go, Python, etc. I’d say the concepts that come close to resembling it are
unique_ptr
andshared_ptr
in C++11. Consequently I spent the most time on the three sections dedicated to references and borrowing, lifetimes, and mutability. Most of the bugs that I ran into while writing Rust code were also related to these concepts.
- At first glance strings in Rust seem pretty complicated.
- Rust has generics. This was something I missed in Go.
- I haven’t gotten used to writing functions without an explicit
return
yet.
- The Rust book is very well written but there are a few areas of improvement. My major gripe is that it introduces new language constructs but doesn’t explain what they do. For instance the chapter on trait objects introduces the
format!
macro for the first time without explaining what it does, the chapter on closures uses aBox
to return a closure from a function without going into what exactly aBox
is etc.
2 thoughts on “Ferric”