I spent an afternoon messing about with Rust and found it infuriating. The compiler kept (quite rightly) telling me how crap my code was and wouldn't compile it for me. I found it frustrating but thoroughly educational.
For systems programmers, Rust looks a fantastic option. For line of business apps, it is inaccessible and the safety dial is turned up too far. But then I guess that is because Rust isn't intended to be a general purpose language for writing line of business apps?
I can see it being useful for writing platform neutral, gnarly code and offer easy hooks for popular, managed languages such as JavaSript, C#, Java et al to hook into.
Outside of systems programming, I wonder if Rust will be part of a silent revolution?
I am a volunteer who works on Rust & I do almost all of my open source work in Rust. I am paid as a Ruby web developer. I personally have little interest in systems programming & want Rust to be a productive language for application development.
I frequently witness this rush to judge Rust as too complex to be used for business applications based on a few hours of hacking. For this to be a valid judgment, I would think one of two things would need to be true: a) Rust remains this difficult to use once you have experience with it, or b) most business applications are worked on for only a few hours.
In my experience, neither of those premises hold.
I believe that the rules of Rust not only give you exceptional performance without memory issues (as this article tries to demonstrate), but also that its rules engender a higher degree of correctness and 'well-factoredness' than most languages. I believe Rust is an excellent language for writing applications at every level of the stack when 'craftmanship' matters.
Well it might be that businesses don't want to invest in anything with a high learning curve if there are tools with a low learning curve that can solve the same problem.
Indeed! I don't believe that there are tools with a lower learning curve that solve the same problem Rust does - in particular my belief is the way that Rust is able to perform deep type analysis on imperative code (which is really what the dreaded borrow checker is all about) enables proficient users to write well-factored systems with a high degree of confidence in their correctness.
If you want to onboard people to your code base with no familiarity with the language or your system and have them be 'productive' (for some definition of productive) within the week, Rust is probably not the right choice for you. In my experience projects for which that is a high priority (and the languages which enable them) also deal with a great amount of technical debt.
You can definitely use languages that are just as safe, but higher level. You could make that argument with many functional languages like Scala or Clojure, you could even make an argument that even many imperative languages are also that solid - like C# or Java. Perhaps not quite as safe, but at least that they deliver the important parts of that safety without the cost of the learning curve. If you want something more precise - you can use Scala in a way that it's almost an imperative language with additional safety guarantees.
The only gain you get going to Rust is really in the performance department. Rust is what you use if you want C-level performance combined with that safety, it might replace C and C++ as the OS, browser, high performance server and game development language.
For anything else I find it hard to suggest Rust as a serious option when there are many high level languages that seem like better answers.
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.