In this series, we look at the most loved languages according to the Stack Overflow developer survey, the spread and use cases for each of them and collect some essential links on how to get into them. First up: Rust.
Despite its relatively tiny userbase—roughly 5% of programmers use it—Rust has consistently come in number one as the most loved language in our developer survey for the past few years, thanks to its small but devoted community.
Rust was first created by Graydon Hoare. What began as a side project later got picked up by Mozilla, who remain one of the sponsors today.
Since its first release in 2009, it has seen a steady ascent in popularity. Over 5000 people have contributed to the Rust codebase. Some enthusiasts wonder if it could replace C++. While it might not be a beginner's language, Rust is gaining ground in the software industry and can be a valuable tool in any developer’s skill set.
The rise of Rust
Just how popular is Rust? If you look at the spread of questions around Rust, you can see it has grown continuously through 2020, although it’s still far from common.
Most loved languages in 2020 in the Developer Survey
With recent layoffs at Mozilla, some worry that this might threaten support for Rust. But the Rust Core Team addressed this in an update announcing the creation of an independent Rust foundation. In their statement, they point out that “many Mozilla employees in Rust leadership contributed to Rust in their personal time, not as a part of their job” and that they have “leaders and contributors from a diverse set of different backgrounds and employers.”
Many companies sponsor Rust with infrastructure resources, including ARM, Microsoft Azure, Integer32, 1Password, Google Cloud, Mozilla, Sentry, and Amazon Web Services.
AWS has affirmed their commitment by stating “at AWS, we love Rust, too, because it helps AWS write highly performant, safe infrastructure-level networking and other systems software.” And more recently they followed up with an outline of their plan to contribute with a dedicated Rust team.
Rust doesn’t look to fade away anytime soon, so learning it now won’t leave you with a useless skill and wasted time.
Who is using it?
Many companies are using Rust—according to the official Rust book, the use cases include “command line tools, web services, DevOps tooling, embedded devices, audio and video analysis and transcoding, cryptocurrencies, bioinformatics, search engines, Internet of Things applications, machine learning, and even major parts of the Firefox web browser.”
Amazon first used Rust for Firecracker, which launched in 2018. In the above-mentioned post in November 2020, Shane Miller, senior software engineering manager at AWS, said “Rust is a critical component of our long-term strategy.”
The team at Dropbox wrote about betting on Rust as one of the best decisions they made. “More than performance, its ergonomics and focus on correctness has helped us tame sync’s complexity. We can encode complex invariants about our system in the type system and have the compiler check them for us.”
Some people have spotted Apple hiring for Rust roles. And as people in the discussion on Hacker News point out, it is likely that most large companies experiment with it. Still noteworthy, Google’s new OS Fuchsia is built with Rust. Others using it include npm, Discord, and Figma.
It’s worth noting that only 5% of developers are currently using Rust. Even though it is loved, it’s not widely used, and low adoption could factor into consideration of its long-term prospects.
Who’s it for?
Developers looking for safety and speed
First and foremost, Rust is written for speed and stability. The process of writing code is usually slowed down when you run into issues. Steve Donovan describes this as safe by default. According to him, Rust principles work as guardrails. Read more on those five principles here.
Rust can also work for a team of programmers with varying systems programming knowledge by leveraging the strictness of the compiler. This way, less experienced programmers don’t need to rely on senior developers to catch their bugs and allowing more people to work together on the same codebase without having to worry about keeping track of all the moving parts, a huge help on larger code bases. Furthermore, `rustfmt` improves consistent coding style across a team.
Programmers of embedded systems
Embedded programmers praise the sophisticated type system, its easy cross-compiling, and Rust as a modern, zero-overhead language, offering a real alternative to C/C++ in the embedded space.
While many say it is not a beginner language as such, the community makes an explicit commitment to answering student and beginner questions.
The goals and motivations for Rust’s creators include better compile-time error detection and prevention, clarity and precision of expression, run-time efficiency, high-level zero-cost abstractions, and safe concurrency. Rust has some great compiler error messages; users stress that they are not only friendly in tone and worth reading the entire message since it is full of great information.
Rust is suitable for anything from work with high-performance servers, command-line utilities, operating system modules, web browsers or embedded applications. A recent keynote discusses industrial, automotive, and avionics use cases.
Why you shouldn't learn it
Rust is not a beginner’s language, and as such, most learning materials build off of previous programming skills. Knowing at least one language helps, but some developers have Rust as their first introduction to a systems programming language. Most guides recommend prior C or C++ knowledge. Many Rust tutorials are about rewriting tools previously written in another language. While learning it as your first programming language might be a brave endeavor, it might not be for everyone.
If you are new to programming, Rust might not be for you. There are many other languages that are considered better beginner languages. For those already familiar with C++, it’s worth noting, it is considered syntactically similar to Rust. Also see: Why is Rust difficult?
What are some of the key concepts?
Well-defined semantics make Rust easy to understand.
- Abstraction. In Rust, generics and traits allow reusing one piece of code. The compiler then generates multiple independently optimized pieces of native machine code. However, Rust has zero-cost abstraction as one of its core principles.
- Functions. As in many languages, functions allow us to containerize sections of our code into reusable units. Rust allows functions to both pass-by-value and pass-by-address.
- Mutability. Rust’s variables are immutable by default and the compiler guarantees that only one section of code can mutate a value at a time, which provides an additional layer of safety compared to other popular languages such as C++. While primarily aimed at improving memory safety in multi-threaded applications, this also provides valuable guarantees in complex single-threaded programs.
Rust allows some flexibility here, for those situations where mutating in place may be more efficient: it allows you to explicitly declare that a variable will be mutable. By requiring you to clearly state your intent, Rust nudges you to make the code’s purpose clearer - both for other programmers reading the code, and for the compiler itself.
- Polymorphism. Many popular languages – including C++ and Java – use ‘inheritance’ to create code that can work with data of different types. Rust takes a rather different approach – instead of subclasses and inheritance, Rust uses generics to abstract types, and traits to guarantee that those types will be able to behave in certain ways.
- Ownership. Rather than using garbage collection or needing the developer to allocate memory, Rust solves the problems by giving the compiler a set of rules to check. This also affects borrowing and slices.
Part of the Rust community’s reputation for being welcoming comes from the wealth of material provided for learners by the Rust community and the Rust Core Team.
Official Rust materials
- The official Rust Programming Language book is the primary introduction to the language. It covers everything you could want to know about the language. If you love paper, it is available in print too. Note, if you are learning or teaching and English is not your strong point, it’s available in 20+ other languages.
- If that’s not enough, rust-lang.org/learnprovides a thorough starting point. Here you can find everything from a comprehensive guide to the Rust standard library APIs, to a guide to the Rust editions, a book on Rust’s package manager and build system, or in-depth explanations of the errors you may see from the Rust compiler.
- Look through the official Rust Youtube. This channel publishes videos from Rust conferences as well as talks and lectures from other places.
- ctjhoa/rust-learning: has an extensive collection of blog posts, articles, videos, etc. for learning Rust, many by Rust team members.
- The official Twitter account is also active and shares interesting projects and other useful resources.
- Rust By Example is a collection of runnable examples that illustrate various Rust concepts and standard libraries.
- Dave Herman, co-founder of Mozilla research, has his own short series of videos on Rust programming.
There are Rust lovers out there documenting their own journey into Rust in an effort to create bite-sized guides to the basics, as well as learning by example use cases:
Entry-level resources and tutorial series
- Not that you can cover Rust in one lecture, but if someone should try, it’s Mozilla Research team member, Emily Dunham, with Rust 101.
- Hello Rust! Good production value of a “lighthearted journey to become fearless, more effective programmers.”
- Rust Programming 01 - Hello World channel with 38 videos, as it’s creator says dedicated to the “visual learner.”
- There’s the New Rustacean: A Podcast About Learning Rust
- intorust.com offers under 30-minute tutorials about some of the basic concepts. Like ownership, shared borrows, mutable borrows as well as an 10 min intro on Why Rust?
- rust-lang/rustlings. ‘Small exercises to get you used to reading and writing Rust code!’
For devs familiar with other languages
Tutorials geared towards programmers of specific other languages.
- From Python to Rust
- Rust for High-Level Programming Language Developers
- A Rust tutorial for experienced C and C++ programmers.
- Live coding YouTube channel for intermediates. Includes a starting point about his setup too.
- Not for learners, but for users, there’s a well-maintained cheat sheet, which links to much of the canonical documentation.
- Introduction - The Rustonomicon – “the deepest and darkest arts of Rust”
Learn from specific use cases, demos, talks.
- RustConf 2020 - Rust for Non-Systems Programmers by Rebecca Turner
- Ashley Williams - How I Convinced the World's Largest Package Manager to Use Rust, and So Can You!
- RustConf 2020 - Error handling Isn't All About Errors by Jane Lusby
- R-Evolution: A Story of Rust Adoption - Ryan Levick
- YouCodeThings – Fun bright game animation tutorials
- “Cataloguing the Rust community's awesomeness” wins for best logline, and has some great resources. If you prefer, there is a newsletter. And an archive going back to 2013.
- How to complete the Advent of Code 2018 challenges with Rust
- The Rust FFI Omnibus is a collection of examples of using code written in Rust from other languages.
Talk: On stage after the Stack Musical at !!Con
- Looking to talk to other adventures on your journey into Rust? As with documentation, the official Rust user forum is a great place to start—including a code review section and places to ask for help.
- If you are looking for debugging help on Stack Overflow. Make sure you read the section. “Producing a Minimal, Reproducible Example (MRE) for Rust code” on here. There is also a chat room on Stack Overflow.
- Find other Rustaceans to follow
- The Rust Programming Language subreddit is fairly active.
- The #rust-beginners IRC channel.
- Many also recommended Exercism.io, a free code mentoring program.
- Rust also has an active Discord channel at https://discord.com/invite/rust-lang. Don’t forget the “-lang” or you’re going to end up, confused, on a channel for nudity-heavy multiplayer survival game Rust!
Interesting Stack Overflow questions:
- What are the similarities and differences between C++'s concepts and Rust's traits?
- Why does the Rust compiler not optimize code assuming that two mutable references cannot alias?
- What is the difference between traits in Rust and type classes in Haskell?
More about Rust, or in fact any other technology tag you can find on the Rust wiki page.
Interested in job opportunities with Rust? Check out those on our job board?
Learning or teaching Rust and got a recommendation for our list? Add yours in the comments section!