Rust has been around for a little while now since it was born in 2006. Originally developed at Mozilla Research and has ever since seen lots of growth with an adoption by major tech companis such as Amazon, Discord, Dropbox, Facebook, Google and Microsoft.

But what exactly is Rust?

Rust is a low-level statically-typed multi-paradigm programming language that’s focused on safety and performance.

Rust solves problems that C/C++ has been struggling with for a long time, such as memory errors and building concurrent programs.

It has three main benefits:

  • Better memory safety due to the compiler;
  • Easier concurrency due to the data ownership model that prevents data races;
  • Zero-cost abstractions.

Syntax

A basic "Hello World" program in Rust looks like this:

fn main() {
    println!("Hello, World!");
}

So why should I even consider Rust?

Well. based on Stack Overflow's 2021 survey; Rust reigns supreme as the most loved language for the sixth year.

Source: https://insights.stackoverflow.com/survey/2021

The Tiobe index also shows an upward trend for Rust: https://www.tiobe.com/tiobe-index/rust/

Where is it already being used?

  • In System76's new desktop environment for Pop!_OS named Cosmic.
  • DropBox uses Rust in its file synchronization engine.
  • Coursera uses Rust for their programming assignments feature where students need to write and run a computer program to solve a problem.
  • NPM is a package manager for JavaScript. Its engineering team chose to rewrite their main service in Rust because they saw that the service’s performance would soon be a bottleneck if user growth kept up.
  • Microsoft has recently been experimenting with integrating Rust into its large C/C++ codebases.
  • Cloudflare uses Rust in their core edge logic and as a replacement for C, which is memory-unsafe.
  • Facebook used Rust to rewrite its source control backend, which was written in Python.
  • AWS has used Rust for performance-sensitive components of services like Lambda, EC2, and S3. In addition, the company openly supports and sponsors the development of the language and its ecosystem.
  • Discord uses Rust in multiple places of their codebase, both on the client- and the server-side.
  • Support for Rust Linux kernel drivers was recently added to linux-next, which is the staging area for inclusion into the release kernel. The Linux project has only ever accepted C code, so this is a big deal.

Did I mention Android support for Rust?

Yes! Android will introduce developing native OS components in Rust (https://source.android.com/setup/build/rust/building-rust-modules/overview).

Rust and WebAssembly

If you haven’t yet heard about it, WebAssembly is like… Assembly for the Web.

Historically, browsers have been able to run HTML, CSS, and JavaScript, with HTML responsible for the structure, CSS for the look, and JavaScript for the interactions. If you didn’t like writing plain JavaScript, you could transpile it from various other languages that added types, Haskell- or OCaml-like code, and other things.

But, JavaScript does not have the predictably fast performance necessary to run computation-intensive applications like games. (This is due to the garbage collector and dynamic typing.)

WebAssembly helps with that. It is a language for the browser that can serve as a compile target for any language, such as Rust, Python, C++. This means that you can take code in basically any modern programming language, and put it in the browser.

In comparison to other languages, Rust is ideally suited for writing code to compile to WebAssembly.

  • Minimal runtime. WebAssembly doesn’t have its own runtime, so it needs to be shipped with the code. The smaller the runtime, the less stuff the user needs to download.
  • Statically typed. Since Rust is statically typed, it can compile to a more efficient WebAssembly since the compiler can use the types to optimize the code.
  • We have a head start. Most importantly, Rust has embraced WebAssembly wholeheartedly. Rust already has a fantastic community and tooling for compiling to WebAssembly, which, to be honest, is the most significant advantage out of these three.

Ok. But how difficult is it to learn?

To be honest, there is a steep learning curve but it has many benefits once you get the hang of it.

What benefits?

  • The community is getting bigger and bigger, which includes tools (called crates), frameworks and libraries.
  • Rust is fast and very flexible. It can run considerably faster than Scala in performance-critical tasks. In some areas it may run even three times faster tha Scala or Java.
  • The package manager. Rust is one of the few programming languages that has a built-in package manager. The package manager is called Cargo and is valued by developers due to its comparatively simple usability. With TOML, it uses an easily understandable syntax that can be learned thanks to its precise semantics quickly.
  • Industry Support. The future of Rust is bright. The Rust Foundation manages the project and ensures that core contributors are fully supported in order to keep the Rust project active and in constant development. Microsoft is a founding member, along with Amazon, Google, Huawei, Facebook, and of course, Mozilla, who helped initially create the Rust language.
  • Proven Track Record. Rust has already been integrated into large projects and is either running in production or being prepped for production, right now. You probably haven't heard many Rust success stories, and that's likely because Rust's interoperability allow it to slowly chip away at existing codebases.

Conclusion?

If you haven't noticed already. Rust is popular, efficient, new and also being widely adopted in the tech industry as a replacement for other languages. It's here now, and it will have even more adoption in the future. So, if you're a programmer, and you're interested in having a low-level language under your belt, Rust is definitely a good investment.