Rust is a relatively new and promising language that offers improvements in software in terms of safety and speed. We'll cover if adopting Rust into your organization makes sense and where you would want to add it to an existing software stack.

Advantages of Rust

Background

Rust was originally created by Mozilla in order to replace C++ in the Firefox browser with a safer alternative. C++ is not a memory safe language, and for Mozilla memory safety issues were the main culprit for numerous bugs and security vulnerabilities in the Firefox browser.

To replace it Mozilla needed a language that would not require a runtime or a garbage collector. No language existed at that time which reasonably met those requirements, so instead Mozilla worked to implement their own language. Out of that endeavor sprung Rust.

Adoption and use beyond Mozilla

Since its creation the language has gained widespread adoption and use far beyond Mozilla and the Firefox browser. This is not surprising, as the language is generally considered to be superbly well designed, adopting many programming language advances that have been made in the last 20 years. Add to that it's incredibly fast - on the same level as idiomatic C and C++ code.

Language Design

Another reason for its popularity and growing use is that Rust doesn't re-implement bug-causing language design choices.

With Rust, errors induced by missing null checking and poor error handling, as well as other classes of coding errors, are ruled out by the design of the language and the strong type checks by the Rust compiler.

For example instead of allowing for things to be null or nil, Rust has enum types. Using these a Rust programmer can handle failure cases in a reasonable and safe way with useful enum types like Option and Result.

Compare this to a language like Go which doesn't provide this and instead implements the null pointer. Doing so essentially creates a dangerous escape door out of the type system that infects every type in the language. As a result a Go programmer could easily forget to check for null and overlook cases where a null value could be returned.

So if you have a Python 2 code base and you're trying to decide whether to re-implement it Go, use Rust instead!

Rust in the wild

Rust Adoption Success Stories

In 2020 Rust was once again (for 5 years running!) the most loved programming language according to the Stack Overflow developer survey.

Just because software developers love a language though, does not equate to success if you adopt the language into your organization.

Some of the best success stories for companies that have adopted Rust come from those that isolated some small but critical piece of their software and re-implemented it in Rust.

In a large organization, Rust is extremely useful in a scenario like this where a small but rate limiting piece of the software stack can be re-written in Rust. This gives the organization the benefits of adopting Rust in terms of performant, fast software but without requiring them to adopt the language across the board. And because Rust doesn't bring its own competing runtime and garbage collector, it fits this role phenomenally well.

Large Companies that count themselves as Rustaceans

Large companies like Microsoft now expound on Rust being the future of safe software development and have adopted using it. Other companies like Amazon have chosen Rust more and more for new critical pieces of cloud infrastructure software.

Apple, Google, Facebook, Cloudflare, and Dropbox (to name a few) also all now count themselves as Rust adopters.

Cost and Tradeoffs of Rust

Fighting the Rust Compiler

One of the key reasons to use Rust is to limit (or completely eliminate) entire classes of runtime bugs and errors. The drawback is that with Rust's strong type system and compile time checks, you will end up seeing a fair bit more compile time errors with your code. Some developers find this unnerving and become frustrated. This is especially true if they're used to less safe languages (like Javascript or C++) that ignore certain categories of programming mistakes at compile time and leave them as surprises when the software is run.

For some organizations, they're okay with this trade-off and the associated cost of discovering errors in production. In these scenarios, it may be the case that the code being written is not incredibly critical and shipping buggy code to production is tolerable (to a certain degree).

Development Time

Rust also brings with it a certain cost in terms of the time it takes to iterate on and develop. This is something associated with all compiled languages and it's not exclusive to Rust, but it's worth considering. Rust might not be a good fit if your organization's projects are comprised of relatively simple codebases where the added compile time is not worth it.

Is Rust Right for Your Organization?

Rust is well suited to situations where having performant, resource efficient code makes a huge difference for the larger overall product. If your organization could benefit from isolating critical pieces of its software stack that meet this description, then you should consider adopting and using Rust. The unique qualities of Rust mean that you don't need to adopt Rust across your entire organization to see a meaningful difference.

In addition to that, Rust is seeing major adoption outside its original target use case as a systems language. More and more it's being used for web servers, web dev via Web Assembly, game development, and general purpose programming uses. Rust has become a full stack language with huge range of supported use cases.

If you'd like to know more about Rust and how adopting it could make a difference in your organization, then please reach out to FP Complete! If you have a Rust project you want to get started, or if you would like Rust training for your team, FP Complete can help.

Subscribe to our blog via email
Email subscriptions come from our Atom feed and are handled by Blogtrottr. You will only receive notifications of blog posts, and can unsubscribe any time.

Do you like this blog post and need help with Next Generation Software Engineering, Platform Engineering or Blockchain & Smart Contracts? Contact us.