Grey Neurons
Experience the wisdom
7 reasons to learn Rust
Rust is a general purpose programming language with goals to produce fast, memory efficient natively code with an emphasis to eliminate memory safety and thread safety related issues at compile time.
It started as a hobby project in 2005 and was officially adapted by Mozilla Foundation around 2009. In 2015 with the release of Rust 1.0, it started getting serious attention & around 2019 Rust Foundation was formed with biggies like Microsoft, AWS, Google joining Mozilla as founding members of the new foundation.
Rust had remarkable 2022 and looks like it is all set to challenge C/C++ as defacto standard for system programming for following reasons.
1. Rust has finally made it to the Linux kernel. Linux Kernel has been a C posterboy all along & Linus Torvalds has for long time even opposed C++ entry into Linux kernel. Under such situations, Rust making into Linux kernel is a really big breakthrough for Rust.
The Rust in Linux debate is over. The implementation has begun. In an email conversation, Linux's creator Linus Torvalds, told me, "Unless something odd happens, it [Rust] will make it into 6.1."
2. Google claims 70% of security bugs found in chrome can be attributed to memory safety issues. Android Open Source Project (AOSP) already supports Rust for developing the OS itself. Overall Google is going all out to support Rust.
Google says that since March 2019, 125 of the 130 Chrome vulnerabilities with a "critical" severity rating were memory corruption-related issues, showing that despite advances in fixing other bug classes, memory management is still a problem
3. Microsoft has made similar claims stating 70% of security defects in its products can be attributed to memory safety. Recently Microsoft Azure CTO Mark Russinovich urged software industry to leave behind leave behind C/C++ & instead adapt Rust for all new development.
The reason for this high percentage is because Windows has been written mostly in C and C++, two "memory-unsafe" programming languages that allow developers fine-grained control of the memory addresses where their code can be executed. One slip-up in the developers' memory management code can lead to a slew of memory safety errors that attackers can exploit with dangerous and intrusive consequences --such as remote code execution or elevation of privilege flaws.
Speaking of languages, it's time to halt starting any new projects in C/C++ and use Rust for those scenarios where a non-GC language is required. For the sake of security and reliability. the industry should declare those languages as deprecated.
— Mark Russinovich (@markrussinovich) September 19, 2022
4. At AWS Rust has quickly become a preferred language for infra development and used in its various technologies & services like Firecracker, Lambda, Fargate, Amazon S3, Amazon EC2 etc .
At AWS, Rust has quickly become critical to building infrastructure at scale. Firecracker is an open source virtualization technology that powers AWS Lambda and other serverless offerings. It launched publicly in 2018 as our first notable product implemented in Rust. We use Rust to deliver services such as Amazon Simple Storage Service (Amazon S3), Amazon Elastic Compute Cloud (Amazon EC2), Amazon CloudFront, and more. In 2020, we launched Bottlerocket, a Linux-based container operating system written in Rust, and our Amazon EC2 team uses Rust as the language of choice for new AWS Nitro System components, including sensitive applications, such as Nitro Enclaves
5. Internet security research group, folks behind Let's Encrypt have started a new initiative called Prossimo to port many critical libraries & protocols like openSSL, NTP written in C/C++ to Rust.
Our first goal is to move the Internet's security-sensitive software infrastructure to memory safe code. Many of the most critical software vulnerabilities are memory safety issues in C and C++ code. While there are ways to reduce the risk, including fuzzing and static analysis, such mitigations do not eliminate the risk and they consume a lot of resources on an ongoing basis. Using memory safe languages eliminates the entire class of issues. We recognize the amount of work it will take to move significant portions of the Internet’s C and C++ software infrastructure to memory safe code, but the Internet will be around for a long time. There is time for ambitious efforts to pay off. By being smart about our initial investments, focusing on the most critical components, we can start seeing significant returns within 1-2 years.
6. Rust is making all the right moves in the programming language survey and indexes. In the Tiobe Index of programming languages, Rust has moved from 26 to 18 in last one year. Also Rust is on its seventh straight year as the most loved language as per the latest Stack Overflow Developer survey.
7. Any programming language needs a minimum 10-15 years to make it to the main stage. Many modern and popular programming languages ( invented in 1990s or later and currently in Tiobe Top 20 index like Java, Python, JavaScript, Golang ) use automatic memory management (aka garbage collection). Except for Golang, rest all seem to have some kind of virtual machine/interpreter to support multiple platforms making all these languages unsuitable for system programming leaving Rust as the only language to be considered as suitable for system programming.
C has been around for 50+ years & almost powers the entire universe of software. It has been a language of choice for writing operating systems, databases, embedded systems where you need to operate at hardware level, have flexibility on how memory is allocated / deallocated, produce native binaries for platform with emphasis on performance. Rise of Rust does not mean putting an expiry date on C as there may be billions of lines of code written in C which can not replaced or rather should not be replaced. That said, you now have have a viable option to refactor some of your critical C code in Rust and for sure consider Rust as your primary choice for new projects.