by jmcomets · 9y ago · 0 comments
Sorry to say this but a lot of unsafe code has been written in Java or C#, putting aside the NPEs and such. In Rust safety isn't only about eliminating SEGFAULTs and buffer overflows, but also preventing data races and most concurrency issues. It's common to add threading to cpu-bound code, without worrying about deadlocks or race conditions.
Rust also allows some very high-level code. Some of my favorite options out there:
- option (std): https://doc.rust-lang.org/std/option/index.html
- serde: https://github.com/serde-rs/serde
- docopt: https://github.com/docopt/docopt.rs
Some more features: generics (traits!), immutability by default, type inference, first-class functions, operator overloading, conversion between related types.
But again, it's not a generally good solution for CRUD-y business applications, webapps, mobile apps, etc where this sort of work is generally rare if it's present at all.
I definitely don't think it makes Rust seem like an appealing option. Between the limited community library selection, the verbose syntax and the borrow checker's extreme complexity to new users, I wouldn't suggest Rust to say, someone working on a web application currently because they will gain few if any advantages, but suffer many risks.
You're right that it isn't appealing to those who're looking for fast results and don't worry about maintaining a large codebase for years. For those like me, many of the features Rust provides solve issues we face on a day-to-day basis.
Yes the borrow checker is a pain for a while. Yes the libraries are still immature. Syntax is much more verbose than say Ruby or Python.
But IMO the benefits you reap from strong typing and borrow checking outweigh the steep learning curve. It's not just about memory management, it's also about controlling mutation (because mutation is a hard problem).