Watercooler
February 22, 2021
5
min read

4 reasons why you should learn Rust in 2021 – and maybe even have fun doing it

Thomas Limbüchler

Rust is considered complex and a programming language with a steep learning curve. That's one side of the medal. We mention four points that Rust has ahead of other programming languages in terms of user-friendliness.

Rust is a modern programming language that focuses on thread-safety and performance. Unlike in many higher-level programming languages, there is neither a garbage collection nor a virtual machine in Rust. Instead, Rust addresses known problems of long-established low-level programming languages such as C or C++. At the same time, the programming language is known for its steep learning curve, which makes many developers shy away from delving into Rust. We provide four reasons to show that Rust, despite its complexity, has benefits that will make your work (and live) with the language easier.

Rust: low-level language with abstractions from higher-level languages

The low-level language Rust is so efficient that it can do without automatic garbage collection. Nevertheless, it offers the performance of C and C++, but without the pitfalls that developers have to know and consider at work.

The developers behind Rust wanted to create a language that would make system-level programming more secure and concurrency, i.e., the simultaneous execution of several calculations, instructions, or commands. Both memory security and concurrency errors occur when code accesses data that shouldn't be accessed at the time.

The package manager

Rust is one of the few programming languages that has a built-in package manager. The package manager is called Cargo and is valued by developers due to its comparatively simple usability. With TOML, it uses an easily understandable syntax that can be learned thanks to its precise semantics quickly.

[package]
name = "project"
version = "2.0"
authors = ["WeAreDevelopers"]
[dependencies]
image = "0.23.5"

In Rust, unlike in JavaScript, for example, developers do not need to set up build scripts; the package manager automatically compiles and links libraries and programs. Production and development builds do not have to be configured in Rust, and Rust developers do not have to worry about platform compatibility.

The fact that you don't need build scripts doesn't mean that they aren't possible. Build scripts are used, for example, when linking to C or C++ libraries and can be customized where necessary. Cargo has integrated unit and integration testing. In contrast to other languages, in which developers often have many testing suites at their disposal, which themselves have to be learned, this is a great advantage.

The compiler

The Rust compiler is well-conceived and has a lot of features that other compilers lack. On the one hand, the output is color-coded, which contributes significantly to its readability. The error output is very detailed – the compiler provides a lot of context, making it easier for developers to find the cause. In many cases, it tells you what causes the error and where you can find the cause – by highlighting the relevant code and displaying it directly in the terminal, accompanied by further explanations. In many cases, it even provides a fix for the error. If that is not possible, it will at least suggest a command – rust --explain [error-code], which you can use to display further explanations. Unlike in other languages, this command doesn't just show you a URL; instead, the documentation is opened directly within the terminal.

In general: the programming language design

Rust is a young programming language designed with today's requirements in mind – a luxury that many other programming languages ​​lack. Old languages ​​such as C or C++ are so complex that modern features have been re-implemented in both over the years, while support for legacy code has been retained. There is no such legacy in Rust. Rust has methods like map (), filter (), and find (), and Clojures in Rust are more reminiscent of the callback workflow in JavaScript than the one in C ++. The fact that the programming language has these features is all the more impressive, given that it can still achieve the performance of C or C++.

Rust's safety-first approach makes life difficult for learners. Still, ultimately there is only positive to be gained from it, and yes, concerning the developer experience: Rust forces programmers to deal intensively with memory usage. This contributes to Rust having a steep learning curve, but it also means that Rust applications are very safe and less prone to errors, which ultimately means less debugging for you. Rust's memory security is likely to be one of the main reasons for the growing interest in the programming language supported by Mozilla.

It was only in October 2020 that AWS invested heavily in Rust. According to the latest reports, Microsoft is also showing great interest in Rust, contributing to further developing the language and using it for its products in the future. According to a blog post by the in-house security team from 2019, around 70 percent of security problems that the Microsoft Security Response Team assigns a CVE number – the acronym stands for Common Vulnerabilities and Exposures – are directly related to storage security. If program languages like Rust were in place, these problems would probably not arise, the blog's authors concluded at the time.

Want to start learning Rust now?

GitHub user Dhghomon has created a repo that explains the programming language’s basic concepts and offers help to get started. Dhoghomon writes that while Rust already has many useful resources for learning the language, most of them are written in English, which could be a hurdle, especially for non-native speakers. For this reason, the Rust developer and linguistics enthusiast has created a repository called Rust in easy English, where he explains central programming concepts in simple language. 

The repo reads a bit as if the individual features and code snippets were verbally explained by a patient colleague, whom you can watch over the shoulder for a day. Only one question remains: Why is this not available for all programming languages?

TL; DR: Anyone who works with Rust needs to think about memory usage. Smart pointers and references are practically the basis of Rust's memory management. Anyone who comes from C++ should be able to familiarize themselves with this relatively quickly. If you come from Python or JavaScript, it will likely take a little longer to become familiar with the concepts. The resulting code is quasi "clean by default". As far as the memory is concerned, with Rust, you have exact control options with more security than C.

If you want to explore other programming languages, take a look on this year's top programming languages to watch out for. And thanks to Dzuk for the emojis!

4 reasons why you should learn Rust in 2021 – and maybe even have fun doing it

February 22, 2021
5
min read

Subscribe to DevDigest

Get a weekly, curated and easy to digest email with everything that matters in the developer world.

Learn more

From developers. For developers.