| I have some time between contracts and I've found myself learning rust. Pros: - Sum types. I am an OO apologist, but trying to use classes in C++ is an exercise in frustration. Sum types map very well to union types and are a better fit for systems programming. - Unit tests built right into the language - it seems like a small thing but it's a hassle in most languages to choose a library, set it up etc. - The above, combined with cargo-watch [0]. With the right flags, you hit save, and your tests all run. It's a god-send. - Ecosystem is pretty big. I can find most things I need. - Discord channel is nice. I was put off a bit by the Rust Evangelism Strikeforce back in the day, but so far everyone is pretty chill. - Options & Results in the standard library. All languages should have this Cons: - I find it hard to transfer knowledge of C to rust, because they use different terminology. - Docs can be confusing to read because every method on collections like `map` or `filter` returns its own Trait. People have explained why this is to me a couple of times but I still haven't gotten it through my head. - You still have to think about memory and pointers. Not always a bad thing, but it is an extra dimension when solving a problem. Overall I'm powering through. I'm hoping to get to a point where Rust is an obvious choice for anything that involves finer control of memory. [0] https://github.com/watchexec/cargo-watch |
It's a tool for encapsulation: you can get into trouble with it, but I'd argue the same is possible with many things - it's how well you use it. You can easily use state composition in C++ if you want, and generally (multiple inheritance can cause issues in some cases) you can use interface classes as well.
And as someone who's been learning Rust for the past 6+ months, I've found that of the three new projects I started which I started in Rust instead of C++/Python over the past 4 months, Composition actually worked quite less well (it's quite verbose due to all the plumbing needed to connect things up) than if I could have used OO interitance in many situations where I wanted specialisation - i.e. hierarchy behaviour traits that had both common shared state and functionality AND specialised state and functionality. Thankfully Traits can at least have default implementations - if not, things would have been a bit worse.
To be clear: there's a lot to like in Rust though.