If you are a techie person, you, of course, know the tradition to write a little program to print the text “Hello, world!” to the screen when learning a new language. So today I would like to say “Hello, Rust!” to relatively new system programming language that runs blazingly fast, prevents segmentation faults, and guarantees thread safety.
Rust gives many of the same benefits as traditional systems languages while being highly reliable, more approachable, safer and often more productive.
Although Rust development is sponsored by Mozilla, it is an open community project that strives to be a warm, welcoming and inclusive network of people, who act together to build something awesome. Today, Rust has a worldwide audience with its users in Europe, Japan and Australia. And what is more, Rust jumped to the first place in Stack Overflow annual survey for being Most Loved Programming Language of 2016.
Now we’ll go a little bit deeper into Rust and find out why this programming language grows in popularity and stays focused on three main goals: safety, speed and concurrency.
Mozilla employee Graydon Hoare started developing Rust as a personal project in 2006. In 2009 Mozilla began sponsoring the project. In 2010 Rust was officially announced on Mozilla Summit 2010. After several years of active development the first stable version (Rust 1.0) was released on May 15, 2015. Thereafter the release of new version is available every six weeks.
Nowadays we see more companies dealing with Rust. Each one has its own reason to do this.
- Mozilla. The company has developed Rust code to replace the C++ code that currently handles complex media formats.
- Dropbox. While much of Dropbox’s back-end infrastructure is historically written in Go, some key components were rewrote in Rust.
Aside from above mentioned tech giants, the other companies that use Rust in production are Skylight, Terminal and MaidSafe.
Let’s review how Rust can solve the problems and what type of solutions best flow from it.
- The goal of Rust is to be a safe language that means ‘doesn’t do anything unsafe’.
- Rust lets us control the costs and guarantees of a program. Rust is a compiled language. Its compiler adheres to strict safety rules, thanks to which additional costs for code execution are missed. As a result of that it’s needed minimum time for implementation or in some cases this time isn’t required at all. So Rust can be used in a real time mode or as an add-in project.
- There are only two kinds of statements in Rust: ‘declaration statements’ and ‘expression statements’ and everything else is an expression. So Rust is primarily an expression-based language.
- It is also important to have a well-defined interface, so that some of your functionality is private, and some is public. To facilitate these kinds of things, Rust has a module system.
- Like most programming languages, Rust encourages the programmer to handle errors in a particular way. That’s why return values are responsible for error handling here.
- If you know C, C++ or even Java, you will become familiar with the language without any problems.
- The Rust project uses a concept called ‘release channels’ to manage releases. It’s important to understand this process to choose which version of Rust (Nightly, Beta or Stable) your project should use. New ‘Nightly’ releases are created once a day. Every six weeks, the latest ‘Nightly’ release is promoted to ‘Beta’. Six weeks later, the ‘Beta’ is promoted to ‘Stable’, and becomes the next release of 1.x. Generally speaking, unless you have a specific reason, you should use the stable release channel. These releases are intended for a general audience.
- Rust is a good solution for: middle and large-size developers team; long-term usage in production; a code with regular support and/or refactor; a great number of existed unit-tests.
Rust was developed with aim to work on various programming platforms. And now it operates on Linux, Mac OS X, Windows, FreeBSD, Android, и iOS. Thanks to Rust wide functionality this language can be used for diverse tasks, such as:
- front-end applications and interfaces;
- device driver, games and signal handlers;
- server-side applications;
- real-time mode systems (e.g. operating system kernel);
- embedded systems;
- large-scale, highly-productive, resource-intensive and complex software systems.
What’s the difference between Rust programming language and the other ones?
1) Rust is a safe alternative to C++ to make systems programmers more productive, mission-critical software less prone to memory exploits, and parallel algorithms more tractable.
2) The syntax of Rust is similar to C and C++. But despite the syntactic similarity, Rust is semantically very different from C and C++.
3) Rust object orientation isn’t as obvious and advanced as in Java, C#, and Python. Since Rust has no classes.
4) Rust’s more sophisticated than Go. In comparison with Go, Rust gives you larger control over memory and resources. This equates to writing code on a lower level.
5) Swift and Rust are both considered as substitution of C, C++ and ObjectiveC. Swift developers spend more time to make the code readable adding majority of syntactic sugar into the language. While Rust is more distant, it deals with minimum things.
Let’s observe how the competition of mentioned above languages can improve technical picture in the future. And we hope it will do a power of good.
It’s impossible to imagine any programming language without drawbacks. If it was so, we’d live in an ideal world. So, let’s back to reality and quickly determine the gaps in Rust.
- Rust cannot prevent all kinds of software problems. Buggy code can and will be written in Rust. These things aren’t great, but they don’t qualify as unsafe specifically.
- As a systems language, Rust operates at a low level. If you’re coming from a high-level language, there are some aspects of systems programming that you may not be familiar with.
- It’s a pretty new language. So using it in development still brings the risk that Rust won’t survive for long and in a few years you need to rewrite it.
- Considering the previous point, Rust tutorials are quite poor. But Rust’s still a comprehensive language. You can’t become familiar with it quickly and start writing professional code in just several weeks. It’s often needed to peruse RFC, blogs and even GitHub comments to find out necessary information. And still there is no dead certainty in it.
- Rust isn’t as fast from the beginning as it is often told to be. You can write a fast code, but this still needs good optimization of your algorithms and program structure.
- Rust compiler is rather strict. People call it a disciplinary language. Everything that isn’t obvious for Rust compiler you should specify on your own. Interestingly enough, when start coding with Rust you can be not aware of your intentions at all. So this learning barrier (altogether with the other ones) leads to the fact that the first Rust impression turns out to be frustrating.
And yet Rust itself hasn’t been standing still. So I’m pleased to mark an important milestone: with Firefox 48, Mozilla’s shipped its first Rust component to all desktop platforms in August, 2. Ralph Giles and Matthew Gregan implemented the component. For the Rust community as well, this is a real achievement: Rust code shipping to hundreds of millions of Firefox users. Seeing Rust code ships in production at Mozilla feels like the culmination of a long journey. But this is only the first step for Mozilla. For instance, Android support’s coming soon. And more to come! The latest ‘Stable’ version of Rust, 1.11 was announced in August 18, 2016.
There’s a lot more to say about what’s happened and what’s coming up in the Rust world. I however tried to dwell on the most essential and valuable details.
Now that you have Rust introduced, Altabel Group will help you start your first Rust project. And I personally would encourage you to play with this programming language. It’s a great time to get started, and increasingly, to get involved with something safe, speed and concurrent.
So are you ready to give Rust a try? We’d love to hear your comments!