Recs.
Updated
Rust is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety.
SpecsUpdate
Pros
Pro Threads without data races
Unique ownership system guarantees a mutable data to be owned and mutated by only one thread at a time, so there's no data race, and this guarantee is checked at compile time statically. Which means easy multi-threading.
Of course, immutable data can be shared among multiple threads freely.
Pro Emphasis on zero-cost abstractions
Programming is all about abstractions. The more powerful abstractions you can use, the more efficiently you can program. Rust, bucking the trend from most languages in its niche, has aspired to take a hint from functional languages, moving away from low-level thinking, and included powerful abstractions for getting work done. To make things better, these abstractions come with no overhead.
Pro Supports cross compilation for different architectures
Since Rust 1.8 you can install additional versions of the standard library for different targets using rustup/multirust
.
For example:
$ rustup target add x86_64-unknown-linux-musl
Which then allows for:
$ cargo build --target x86_64-unknown-linux-musl
Pro Built-in concurrency in the standard library
Rust has built-in support for concurrency in the standard library.
Pro Expressive error handling, no having to catch exceptions
Errors are propagated through functions in the program and can be handled at any level.
Pro Makes developers write optimal code
Rust is a modern programming language written around systems. It was designed from the ground up this way. It's language design makes developers write optimal code almost all the time, meaning you don't have to fully know and understand the compiler's source code in order to optimize your program.
Furthermore, Rust does not copy from memory unnecessarily, to give an example: all types move by default and not copy. Even references to types do not copy by default. In other words, setting a reference to another reference destroys the original one unless it's stated otherwise.
Pro First-class sum types
Sum types (i.e., tagged unions) are a very expressive way of representing state. The simplest example of this is Rust's Option<T>
type which has two variants Some(T)
and None
. One can use an Option
to represent a computation that may or may not have a meaningful result (e.g., retrieving a value from a hash table, the element is there, Some(element)
, or it isn't, None
). Rust allows the programmer to pattern match (destructure) these sum types in a very ergonomic way.
Pro Easy to write understandable code
While not as verbose as Java, it still is much more verbose than languages like Go and Python. This means that the code is very explicit and easy to understand.
Pro Excellent learning resources and documentation
With the Rust Cookbook, Rust by example, Rustlings, and "The Book", there are many comprehensive tutorials to get started and understand each piece of the language one at a time. Once you do understand the language, the documentation present on doc.rust-lang.org is very helpful.
Pro Object-Oriented alternatives
Many people complain about object oriented programming, and Rust manages to have most of the usability benefits of OOP without having to tie yourself in knots. There's no inheritance, but enums and traits can fill most of that functionality with added transparency.
Cons
Con Difficult learning curve
Learning curve of the fairly complex rules for Ownership, References and Borrowing, and Lifetimes required. Their use must be internalized in order to become reasonably fluent in Rust.
Con Not as useful or productive as advertised.
If really out here wanting to use something besides C/C++, in 98% of use cases, would do just as well or be better off using something other than Rust. Will complete the project faster, would be easier, will be happier, and nearly as safe (use newer language with optional GC).
Con Error handling
Rust uses algebraic data types(Option, Result) instead of exception.
Con Certain syntax may be confusing for new programmers
Rust's lifetime notation and application can be difficult to understand.
Rust's trait system may be intuitive at first for programmers who use object oriented languages.
The macro system syntax is entirely different from the rest of the language and there are many different types. E.g. derive and tag macros use #[] syntax while function macros have a ! after the name.
Con Rust not as safe as it pretends to be
Rust problems:
1) Massive undisclosed usage of unsafe.
2) Massive amounts of memory safety CVEs - see details.
3) Large bloated Rust binaries increase attack surface for exploits.
4) Many corporate types claiming Rust is safe, don't actually program or use it (have some quiet financial interest to push it).
Recommendations
Comments
Flagged Pros + Cons
Pro Functional Programming
Very easy to create functional with some additional from structure application.
Out of Date Pros + Cons
Con Hard to find learning resources or libraries
Because it's still a relatively new language, Rust does not enjoy a following as large as other languages/environments. Rust development has also been rather volatile for a long time during the beginning of the development of the language adding to this issue.
Because of the small community, it's harder to find useful libraries for projects or any other kind of resource.
Con Poor compile times
Compiling rust is slower than most other languages, however cargo check
can be used as an alternative to build during development (most ide's will do this for you)
Con Asynchronous I/O is not (yet) a part of the core language
The issue of asynchronous I/O is still being discussed as a language feature, and not yet in the implementation phase.