What is Rust?
In this part, there are a few insights here about Rust; if you’re not very familiar with it, or probably you want to refresh your memory. If not, feel free to go to the next section.
A brief history
Rust just celebrated five years of stable Rust. Thus, if you look back at the archives, you will realize that the project started much earlier than that – it takes a while for the software to evolve into something stable!
The first release label on the GitHub repository is over eight years old (release-0.1). And the first on this repository celebrates ten years today (I wasn’t indeed at university!). Before that, there was a Rust repository, which dates back to 2006.
It is also evident that two versions of Rust have been released within the five years: edition 2015 (Rust 1.0) and edition 2018 (Rust 1.31). Though the new edition was not a significant breaking change – one can use 2015 and 2018 packages in a Rust application – it shows a good velocity in the development of Rust.
Why Rust? Reliability, performance, productivity: choose three
Rust makes itself a practical programming language focusing on all of the reliability, performance, and productivity.
The downside of collected languages with manual memory operation is that, traditionally, C and C++ have been the primary source of security vulnerabilities because manual memory operation is complex. However, around 70% of severe vulnerabilities in software such as Chromium, Firefox, or Microsoft products are memory safety issues.
It is where Rust comes into existence; with a more potent model of memory power and borrowing ignited into the type system, Rust enables you to write dependable programs even with manual memory operation. It is the essential novelty of Rust, but as regards this series of posts, Rust has more benefits than that.
The next pillar of Rust is productivity. It comes by giving access to both low-position primitives – as we’ve seen with efficient memory operation and high-position abstractions – made possible with a robust type system. This ability to span the entire abstraction spectrum enables software development in Rust productive. If you write code and software performance as one, being more effective in writing reliable code increases the software performance.
In this talk, Bryan Cantrill discusses that a program written in Rust without applying all possible optimizations was 35% faster than an original well-optimized C program. The reason was that Rust enforced sorted maps as a B-tree under a good abstraction. While B-tree maps are very efficient, it is much harder to write a generic B-tree library in C than in Rust because of the type system, so C programs usually end up with few optimized structures like red-black trees. Another illustration is the Hash Map structure of Rust, which now implements a harborage of Google’s Swiss Tables, and is thus more efficient than stud::unordered map in C++. Relatively insightful! A good illustration is the following which compares the productivity of C and Rust to two languages that should not be compromised on performance.