3 ms·
The pros/cons of rust add up better than other languages. The people who I hear (recently: Jon Blow) throw spears are usually correct, but what they're missing
by the__alchemist 2y ago
The pros/cons of rust add up better than other languages. The people who I hear (recently: Jon Blow) throw spears are usually correct, but what they're missing is that you could throw pointier ones at the alternatives. Some examples:
- Best mutability ergonomics of any language. E.g. `&mut` in a function parameter means the funciton can mutate it; `&` means it can't. This might be my favorite part of rust, despite sounding obvious. Few languages have equivalents. (C++ and D are exceptions).
- Easy building and dependency management
- No header files
- Best error messages of any language (This is addressed explicitly in the article)
- Struct + Enums together are a fantastic baseline for refactorable, self-consistent code.
- As fast as any
- Great overall syntax tradeoffs. There are things I don't like (e.g. Having to manually put Clone, Copy, and PartialEq on each simple enum, and having to manually write `Default` if I need a custom impl on one field), but it overall is better than alternatives.
Rust enthusiasts online are often unpleasant, and it's perhaps their fault people are put off by the language. They repeat things like "fearless concurrency" "if it compiles, it works", and "that code is unsafe/unsound" without critically thinking. Or, they overstate rust as a memory-safety one-trick, while ignoring the overall language advantages.
Tangent: Async rust is not my cup of tea for ergonomics and compatibility reasons. I have reason to believe that many people who like it think Async is synonymous with concurrent processes and nonblocking code.
- iknowstuff 2y agoI like async rust because its an engineering marvel. There are other ways to do it, but they are all worse, slower, and less versatile: https://embassy.dev/ https://embassy.dev/ https://without.boats/blog/why-async-rust/ https://without.boats/blog/why-async-rust/
- the__alchemist 2y agoI do lots of embedded; not an Embassy fan for the classic Async reasons. Disagree on being worse, slower, and less versatile. That is wrong on slower; the other two traits are subjective. The embassy creator is a great programmer, and we see eye-to-eye on typestates and HAL unification, but not async.
- wavemode 2y ago> There are other ways to do it, but they are all worse, slower, and less versatile I would disagree with this, personally. Due to being tacked onto the language after the fact, the design of Rust's async made a number of concessions in order to fit into the language (for example, it had to work around the pre-existing restriction that all types are moveable by default). But you're correct that no current popular language has yet developed anything better.
- deleted 2y ago[deleted]
- Thorrez 2y ago>Few languages have equivalents. (C++ and D are exceptions). I would say Rust is still better than C++ here, because in Rust const is default. In C++, people often either forget to write const, or intentionally don't write const because writing it everywhere clutters up the code.
- berkut 2y ago> or intentionally don't write const because writing it everywhere clutters up the code I don't often like being judgemental (at least publicly!), but I'd argue that's just people being very bad developers... You could argue having to add '&mut' at call sites everywhere (i.e. opposite to the way C++ does const in terms of call site vs target site) also clutters up the code in terms of how verbose it is, but it's still largely a good thing.
- huijzer 2y ago> Rust enthusiasts online are often unpleasant, and it's perhaps their fault people are put off by the language. I guess this is also a bit in the eyes of the beholder. It seems that any group that is enthusiastic about something new is “unpleasant” nowadays.
- tonyedgecombe 2y ago>Rust enthusiasts online are often unpleasant The Ruby community seems the nicest, I wonder why that is.