2023-04-05 Update: We updated the article to include the most recent information.
Rust, Graydon Hoare’s creation, is the famous language for creating fast and secure applications. The language is also universally well-liked, earning the top spot in the Stack Overflow Survey 7 years in a row!
It’s no wonder, then, that many major companies, such as Discord, 1Password, Dropbox, and Toyota decided to embrace Rust, the language developed in 2010.
What Makes Rust Different?
Rust’s design is unique, and crucially, it aims to answer the oldest existing question: how to eat a cake and still have that cake when it comes to building safe, yet highly efficient applications.
In the simplest terms, the language solved the challenge of having a tool for designing apps that do not compromise on performance while at the same time, save you from potentially dangerous flaws.
Of course, if you need to escape some of that safety, you may. Even though it is highly discouraged, a simple unsafe statement will do the trick.
Another key feature that many programmers always appreciate, is how easy it is to generate documentation. If somebody published a piece of code for others to reuse, you may find documentation for it on docs.rs. Frankly, there are few languages that even match that functionality (Go is one of them, of course).
Of course, claiming that something is without flaws is delusional. The designer of the language, and the team behind it now, had to make trade-offs.
One of them is the language’s excessive wordiness. Writing option.as_ref().unwrap().borrow() is a Rustacean’s (that’s how Rust programmers call themselves) constant companion for better or for worse.
The editor support used to be poor. Luckily, lately it improved. It became quite good. For example, the Visual Studio Code extension works as expected, providing a ton of helpful features.
Overall, there are definitely more shortcomings, and we can’t pretend there aren’t. The optimistic accent is how the wider project handles flaws and challenges, and that there are usually attempts to solve wider issues. One example is how the community handled one highly requested feature: asynchronous programming.
See for yourself at https://areweasyncyet.rs/. In short, there was a popular movement of programmers to co-create the necessary foundations for the feature.
Rust’s Use Cases
Specifics aside, there are use cases In the same way that we won’t see a supercar making deliveries, or a delivery van race on a track - programming languages have their use cases that they're built for.
Rust excels in all the (most frequently) multi-platform, high-performance scenarios, where security cannot be an afterthought:
- Operating Systems
- Cybersecurity Products
These all successfully use the airtight language to improve their offering.
There are some scenarios, however, where we have to resort to using C, or C++ instead. Embedded development is one such area. In this case, engineers have to apply solutions that are sometimes older than they are. It’s a sad necessity since memory and CPU speed are a luxury. Though that might be for worse. As a matter of fact, C may have been indirectly responsible for a series of car crashes, and billions of dollars of losses for one automotive company (pages 36, 38, 40, 43).
Sadly, the affair happened before 2010, therefore the only way to produce better code back then was to voluntarily adhere to standards.
Did you know that Figma allows people to create their designs using the super safe language under the hood?
If you are looking for a way to get started with Rust on the front-end, take a look at Yew.
Blockchain projects running based on Rust
Safety, easy multi-platform development, speed, and quality is just what blockchain developers need - and where Rust excels.
For all the enthusiasts out there, you may even find a dedicated newsletter updating everybody on advances of “Rust in Blockchain”. The amount of high-profile projects in this area alone is impressive, just to mention Zcash, and MobileCoin.
We want to highlight different projects, however. Some higher-profiles ones are:
The project started in November 2017 and had one goal from day one. They wanted “a blockchain built from the ground up for scale.”
The story began in 2017, with a scientific paper by Anatoly Yakovenko. Few years down the line, and we have a top project with numerous contributors, and a strong community. Solana and Polkadot are fighting Ethereum on their quest to become the choice for Web3. Will they be successful? Only time will tell.
Question: how do you build something extremely fast, and safe at the same time? The Clear Answer: You develop it in Rust.
Engineers from Geneva, Switzerland, use the programming language to ensure the highest levels of safety and speed. To achieve higher efficiency, the team even restricted the language features available.
The effect? “710,000 transactions per second on a standard gigabit network if the transactions are, on average, no more than 176 bytes.”
Note: The name Solana is “a nod to a small beach town North of San Diego called Solana Beach, where Anatoly, Greg and Stephen [the founders] lived and surfed for three years when they worked for Qualcomm.”
Polkadot, a London-based organization, “envision[s] a Web where our identity and our data is our own – safely secured from any central authority.”
That’s not their only goal either. The team sees their mission being “connecting private and consortium chains, public and permissionless networks, oracles, and future technologies that are yet to be created” as well.
How do they want to do all that? You guessed it: build a solution on top of Rust.
While the team, primarily based in London, explicitly highlights the foundation is Hoare’s child, the project also states that Go and C++ are among the languages in use “making Polkadot accessible to a wide range of developers.”
If you played “spot the odd one out”, then here is the correct answer. A little different from their colleagues, Hyperledger solves other problems altogether. While the former two are public blockchains, Sawtooth is an “enterprise solution for building, deploying, and running distributed ledgers.”
The company, based in San Francisco, USA, uses Rust to “to give application developers and administrators more control, more flexibility, and greater security for their blockchain networks.” The team switched to Mozilla’s language from… Python.
Guido van Rossum’s creation had one purpose: to facilitate prototyping. After a year, in 2019, the team decided to rewrite the project to Rust, enabling them to ship better code. Teams have “account for all possible error and edge cases”, thus low-quality code will not get a pass from the compiler.
Comparing that to C++, or even Python, the solution will be of higher quality, due to the strictness of the language and its compiler.
Whatever you are using Rust for, should you want to have a conversation about your project, don't hesitate to get in touch with us here to talk about our Blockchain Development Services. We would love to talk to you.
Disclaimer: this material has not been reviewed or endorsed by the Rust Foundation