I have been trying out Rust in contests and I'm curious about other people's impressions of the language, in comparison with C++. In particular I am interested in the possibility for building higher abstractions, and for better error detection.
C++ definitely has the potential to be error-prone, but I became much more consistent with it once I started using an LSP that shows me warnings/errors as I type. That plus avoiding global variables. Now I feel like almost all of my errors are logic-based rather than due to the unsafety of the language.
Here are some of my first impressions from using Rust to solve some contest problems.
Things I enjoyed:
iterators, map, filter, etc. I feel like the syntax is often cleaner than C++, where I would almost always default to mutable variables instead.
Type inference is usually good
Lightweight tuple and array syntax
Ranges
"const" is default
Automatic error tracing when compiling in debug mode
Dislikes/annoyances:
Recursive functions. This is the big one. In C++, recursive lambdas (with a Y combinator) are very convenient and allow for things like DFS without passing in a million parameters (and without global variables).
Index has to be usize
Casting to and from references
The borrow checker doesn't seem to be that useful for contest problems
I'm interested in what else the language can offer! Looking forward for Egor to weigh in.