Rust is not a revolutionary language with new cutting-edge features, but it incorporates a lot of proven techniques from older languages, while massively improving upon the design of C++ in matters of safe programming.
The Rust developers designed Rust to be a general purpose and multi-paradigm language; like C++, it is an imperative, structured and object-oriented language. Besides that, it inherits a lot from functional languages on the one hand, while also incorporating advanced techniques for concurrent programming on the other hand.
The typing of variables is static (because Rust is compiled) and strong. However, unlike in Java or C++, the developer is not forced to indicate types for everything; the Rust compiler is able to infer types in many cases.
C and C++ applications are known to be haunted by problems that often lead to program crashes or memory leaks, and which are notoriously difficult to debug and solve. Think about dangling pointers, buffer overflows, null pointers, segmentation faults, data races, and so on. The Rust compiler (called rustc) is very intelligent and can detect all these problems while compiling your code, thereby guaranteeing memory safety during execution. This is done by the compiler, retaining complete control over memory layout, but without needing the runtime burden of garbage collection (see Chapter 6, Using Traits and OOP in Rust). Of course, safety also implies much less possibility for security breaches.
Rust compiles to native code like Go and Julia but, in contrast to the other two, Rust needs no runtime with garbage collection. In this respect, it also differs from Java and the languages that run on the JVM, like Scala and Clojure. Most other popular modern languages, like .NET with C# and F#, JavaScript, Python, Ruby, Dart, and so on, all need a virtual machine and garbage collection for their execution.
Rust provides several mechanisms for concurrency and parallelism. The Standard Library gives a model that works with threads to perform work in parallel, where each thread maps to an operating system thread. They do not share heap memory, but communicate data through channels and data races are eliminated by the type system (see Chapter 8, Organizing Code and Macros). If needed in your project, several crates provide an actor-model approach with lightweight threads. These mechanisms make it easy for programmers to leverage the power of the many CPU cores available on current and future computing platforms.
The rustc compiler is completely self-hosted, which means it is written in Rust and can compile itself by using a previous version. It uses the LLVM compiler framework as its backend (for more info, see http://en.wikipedia.org/wiki/LLVM), and produces natively executable code that runs blazingly fast, because it compiles to the same low-level code as C++ ( see some benchmarks at http://benchmarksgame.alioth.debian.org/u64q/rust.php).
Rust is designed to be as portable as C++ and to run on widely-used hardware and software platforms. At present, it runs on Linux, macOS X, Windows, FreeBSD, Android, and iOS. For a more complete overview of where Rust can run, see https://forge.rust-lang.org/platform-support.html.
Rust can call C code as simply and efficiently as calling C code from C itself, and, conversely C code can also call Rust code (see Chapter 9, Concurrency - Coding for Multicore Execution).
Rust developers are called rustaceans.
Other Rust characteristics that will be discussed, in more detail in the later chapters are as follows:
- Variables are immutable by default (see Chapter 2, Using Variables and Types)
- Enums (see Chapter 4, Structuring Data and Matching Patterns)
- Pattern matching (see also Chapter 4, Structuring Data and Matching Patterns)
- Generics (see Chapter 5, Higher Order Functions and Error-Handling)
- Higher-order functions and closures (see also Chapter 5, Higher Order Functions and Error-Handling)
- An interface system called traits (see Chapter 6, Using Traits and OOP in Rust)
- A hygienic macro system (see Chapter 8, Organizing Code and Macros)
- Zero-cost abstractions, which means that Rust has higher-language constructs, but these do not have an impact on performance
In conclusion, Rust gives you ultimate power over memory allocation, as well as removing many security and stability problems commonly associated with native languages.