About a year ago I bought some programming books and one of the books I bought was Rust in Action, by Tim McNamara. I chose this one because at the time I was considering doing what I’m doing now and I didn’t want to go in on my own with just free resources. Free resources while they often can be good on a technical level are generally full of proselytizing. They often do not want to call out the cons of the language or anything that may turn off a possible future user, and leave the user to find the foot guns, most books tend to be better about this.
Rust in Action does seem to be a bit better about this, even admitting in the “cons” section about the rust hype that lead to me digging in so hard to anti-rust. However it does still reek of the rust missionary scent. It sometimes feels unrealistic in recommendations such as with recommending rust for microcontrollers after admitting language size as a con. I do like that it leans into reminding you that rust is not a panacea for all bugs though.
A downside of Rust in Action is the errors. Every book will have errata, it’s just a reality of writing. Every book will also have things that just go out of date, but some of the errors are VERY obvious and should have been caught before publication. Errors like code that won’t compile, examples that are just plain wrong.
Lets actually talk about language and syntax now. What do i like:
- The promise of pattern matching
- The promise of higher-order functions
- deeper type-safety
- Immutability by default
cargo fmt
- Templates/Generics
I mostly write in functional programming languages, and elixir at that, for the majority of projects I write these days. I also used to write a lot of typed Racket. These features in a language actually designed to be useful would be killer.
Things I dislike so far:
-
- no dynamic casting for Number (or at least integer) types
- In my opinion, you shouldn’t have to cast numbers as other numbers, the compiler could cast smaller datatypes to bigger datatypes (of the same datatype). I understand wanting users to be direct in what they want but, this is a little over the top IMHO. I shouldn’t have to ask it nicely at the very least to treat a u16 as a u32. That said, I can understand having to ask it nicely to treat a u16 as an f16.
-
- cargo’s use of TOML
- It’s a mostly small nitpick, but I… really dislike TOML. if i wanted something like ini, which I don’t, I’d use ini. I don’t know what I’d replace it with exactly for rust, I’m a bit spoiled with elixir and mix I think.
- first order functions don’t work exactly as expected.
-
- do we… really need
unwrap()
everywhere? - okay so elixir has the same concept in some ways, but we tend to do
it with something like
{:ok, thingwewant} = called_function
instead, maybe using some guards as well. I just find.unwrap()
at the end of many lines to be supremely ugly
- do we… really need
That said, I dislike the language far less than I did last time around. Sort of surprised, This is not at all what I remembered it being like when I was playing around with those pre-1.0 builds. I still don’t know how it plays in the realms that I tend to work in though.
This post is part of a series: Previous Article Next Article