In this article, you'll see why there's never been a better time to delve into the C++ alternative Rust programming
Rust is a programming language that offers the performance of C and C++ but with safeguards to stop developers shooting themselves in the foot.
Born out of a personal project by then Mozilla developer Graydon Hoare in 2006, the language, like the Rust fungus it is named after, is starting to spread, and today is used to build software for the web, embedded computers, distributed services, and the command line.
"The biggest strength of Rust is that it's an empowering technology," says Carol Nichols, from the Rust programming language core team and co-author of The Rust Programming Language book.
"To write extremely fast code with a low memory footprint previously meant using C or C++. However, using those languages in production code requires you to manage memory manually and know all the ways you might cause undefined behavior."
Nichols points out that the ever-expanding CVE database of code vulnerabilities is evidence that "even the best programmers" can struggle with this level of freedom.
"The Rust compiler is stricter and makes sure you're using memory safely so that you can concentrate on the problem you're really trying to solve," she says.
On top of this, Rust adds the quality of life features of some higher-level languages.
"I like to think of Rust as high level in the front, low level in the back," says Nichols.
"As far as the experience of writing Rust, I'd say it feels like a mix of Ruby, Haskell, and Scala. It has functional influences such as closures and iterators, and a rich type system similar to Haskell.
"As far as the programs created using Rust, they're the most similar to those created using C and C++ in their speed and memory usage."
Here's seven reason why now is a good time to start learning Rust.
"Now is a great time to learn Rust because the 2018 Edition, just released December 6th, has a lot of improvements to the idioms of the language to make Rust more ergonomic to read and write," says Nichols.
There are hundreds of companies using Rust in production, such as Dropbox, Yelp, and Cloudflare.
That said, use of Rust is generally still at an early stage, and employers aren't crying out for Rust skills at present, with the language not featuring in global job site Indeed's top tech languages for the US last year.
However, Raj Mukherjee, SVP Product at Indeed, said there were signs employers were starting to take an interest in Rust.
"We are beginning to see the programming language Rust appear in job adverts, albeit in a relatively small number of job openings globally," he said.
"Demand is outpacing supply here, as search outweighs the total available postings — but again, this is by a very small margin right now."
Writing software to run on the very underpowered embedded systems found in the likes of home appliances and industrial machines poses its own challenge.
Rust's very low overhead makes it well-suited to running on the extremely constrained resources of these weedy microcontrollers, says Nichols.
"The lack of a runtime in Rust makes it one of the few modern programming languages appropriate for extremely low resource environments," she says, adding there are plenty of options for compiling code to run on these devices.
"There's great tooling to cross-compile Rust to a variety of embedded devices. Rust also has C FFI support, so it can integrate with existing code in this and other domains."
The version of Rust available via its stable channel has also been reworked for Rust 2018 to include the necessary features for embedded development, reducing the need for developers to source these features from third-party libraries.
Rust can be compiled into WebAssembly, which runs in each major web browser at near-native speeds.
"WebAssembly is a really promising new domain to bring native application performance to the web," says Nichols.
"Rust has become the go-to language for writing code that compiles to WebAssembly.
Nichols has high hopes that Rust could soon rival established web-development languages for features.
"I'm also excited for the day we have a fully featured web framework in Rust. There are a lot of pieces of frameworks and exciting experimentation happening in the ecosystem right now, but there isn't something comparable to, say, Rails, in Rust just yet. I'm optimistic that we'll get there soon."
For networked services, Nichols says Rust's minimal footprint and ability to ensure memory safety across multiple threads make it a great choice for services that scale across distributed systems online.
"Rust also makes it harder to write code that leaks memory or other resources. These aspects translate to lower server costs and a lower operational burden," she adds.
Pulling data in from different online services should also soon be easier, with Rust due to implement support for the async/await commands, which will make it far easier to write asynchronous code that doesn't hang while waiting for data to be delivered.
"Cross-platform command line applications are another place where Rust really shines," says Nichols.
"You can cross-compile to the platforms you're targeting and get a single binary to ship to users. Ripgrep is a great example: it's a reimplementation of grep in Rust that works on Windows, Linux, and macOS, and is faster than any other text searching tool in its class."
A range of developer tools are now out of preview, including Rustfmt, a tool for automatically formatting code based on a default code style; Clippy for helping ensure idiomatic code style; Rust's linter for highlighting potential bugs; and support in IDEs via Rust Language Server and IntelliJ Rust.
Existing tools are also improved, such the borrow checker that helps ensure code is memory safe, which has been made more forgiving so it won't block other borrowers from using data if a variable is finished using that value.
Nichols says the time it takes to compile Rust code to software is still "slower than we'd like it to be".
"There's been work on incremental compilation that has improved the situation somewhat, and there have been ongoing refactoring efforts that should unlock further improvements in the near future."
Recent improvements for Rust 2018 made recompilation faster via several methods, including incremental compilation, where the compiler only recompiles parts of the code that have changed.
While Nichols says the ecosystem of community-built software libraries, known as "crates", has expanded a lot since Rust 1.0 in 2015, she says developers may still not be able to find a library that offers the features they are looking for.
"In other cases, there might be a library available, but it's incomplete or otherwise not as mature as it needs to be to be used in production," she says.
"We have a variety of working groups that are investing in the ecosystem and making improvements outside of the compiler itself, and we're likely to have more working groups form in the coming year."
Finally, she says that Rust can still be difficult to learn and to master, but adds a number of books have come out recently, including The Rust Programming Language that she wrote alongside Steve Klabnik.
In the longer term she says there are plans to work on more beginner learning resources and new intermediate-level books and tutorials.
"We want everyone to be able to learn and be productive in Rust," she says.
Thanks for reading ❤
If you liked this post, share it with all of your programming buddies!
Build your eCommerce project by hiring our expert eCommerce Website developers. Our Dedicated Web Designers develop powerful & robust website in a short span of time.
Best Mobile App Development Company India, WebClues Global is one of the leading web and mobile app development company. Our team offers complete IT solutions including Cross-Platform App Development, CMS & E-Commerce, and UI/UX Design.
Do you want excellent and world class web development services for your valuable projects? Contact **RB Genie **now, we have more than 8 years experienced team of web developers, which specializes in overall web design and website development...