Why Rust is Better

What is Rust?

Rust is a general-purpose, multi-paradigm, compiled programming language that competes with C++ in speed* while guaranteeing memory safety and zero cost abstractions.

 

Design Choices

Crates Ecosystem

Rust has a purposefully minimal standard library. You can specify crates as dependencies with one line in the Cargo.toml file in your project directory.

The Cargo Tool

While Rust comes with a standalone compiler, it's main strength is the Cargo tool. You can create a new project with a Cargo.toml where you can specify many many options, such as dependencies, project name, project version, build profiles, etc. It also comes with a number of built-in commands like cargo build, cargo test, and cargo run. You can also run cargo build --release or cargo run --release (since run just builds and executes). Building in release mode applies a number of extra optimizations that make your code run anywhere from 5-30x faster than it already does. The Cargo tool also makes managing a larger project much easier.

What Makes It the Best?

(Comparatively)

Rust is a systems language, like C++. It is also Turing complete, meaning it can theoretically do anything. However, a lot of languages are said to be "Turing complete", but not all of them are actually feasible to do everything. Rust's standard library, while mimimal, provides a lot of very useful abstractions. On top of that, the rich crates.io system provides an incredibly easy way to have access to virtually unlimited libraries for just about every purpose. Rust's FFI abilities ensure these crates aren't just limited to pure Rust code either.

Syntax

Rust has a clean and relatively minimal syntax, avoiding extreme verbosity while still implementing an impressive amount of features. The best example of this a for loop in Rust vs. C++ (same or similar in C, Java, and JavaScript as well):

Borrow Checker

This is one of the most frequently complained-about features of Rust. However, this is actually a great feature. Not only does the Rust compiler catch a lot of mistakes and explain them in great detail (other compilers just say it errored, not very helpful), the borrow checker ensures your memory management remains bug free. While it might be annoying at first, you quickly learn how to write better code. In fact, mistakes like these are a very common pitfall of C/C++ and are often the cause of very dangerous bugs and exploits. If you didn't have the borrow checker, you wouldn't ever learn how to write better, less buggy code.

Speed

I mentioned before that Rust competes with C++ in speed. This is impressive because C++ and C are the fastest languages by a wide margin. However, the speed difference in C++ and Rust is so minimal that it's always down to the programmer, and never the language. In fact, in some cases, Rust compiled in release mode is even faster than C++.

Freedom

Rust, like C++, allows ultimate control over the hardware. At first, you may think that this is a BS point. How can a language that enforces memory safety be ultimately free? Well, with Rust, you can use inline assembly, link external C functions, and use unsafe mode with the unsafe {} keyword, or even mark whole functions as unsafe fn func() to be able to use and dereference raw pointers instead. Note that unsafe mode does not disable the borrow checker. The borrow checker should never be disabled, because if it's going off, that means you're writing a bug in your code, and the ability to disable the checker still means your code won't work.

Ok. So Rust is the best compiled language. But what about scripting languages?

Obviously, if you want to write small scripts, something like Python or Lua is the way to go. But most programmers, once they start getting more serious about programming, learning more advanced concepts, and so on, they move on from scripting languages to lower level languages which are closer to the hardware, faster, and allow for more complexity, flexibility, and creativity. If you're a scripting language person, that's fine, Rust isn't for you. But if you're one of those programmers who wants to move to a lower level language, whether it be for more freedom, more power, or just for a large scale project which needs ultimate flexibility, Rust is probably the top contender out of all the languages.