Skip to main content

The Impact of Rust on Modern Software Development

· 11 min read

Introduction

In October 2022, the initial Rust infrastructure was merged into the Linux kernel, marking Rust as the first programming language to challenge C in Linux kernel development. This significant change has gained widespread attention and discussions in the software community due to the Linux kernel's role as the foundation for a wide range of devices and systems. The Linux kernel powers billions of servers, computers, smartphones, and even embedded devices, so that any change in the Linux kernel will have a huge impact on the software development industry.

The Rust language, known for its modern, safe, and high-performance characteristics, presents a new choice for software developers. By drawing on the strengths of other programming languages and combining them with its unique features of memory safety and concurrency, Rust plays an important role in operating system and software infrastructure development. Rust has no garbage collection mechanism, but instead it utilizes Ownership, Borrowing and Lifetime to ensure memory safety. Meanwhile, its unique syntax, compiler, and static checking tools like Clippy allows developers to create secure code with high quality and greatly improve development efficiency.

The long-term consequences of this programming language are still unknown, and the advantages and disadvantages are yet to be fully examined. This essay examines the improvement made by Rust based on software development experience in past decades, focusing on its claims about safety and performance and evaluates these claims as credible under certain premises. Through the analysis of the Rust language, this essay explores how it transforms the way software is developed and investigates its learning curve and applications. By offering insights into favorable conditions for learning and utilizing Rust, this essay recommends programmers consider potential application of Rust in their respective domains.

Memory-Safety and Rust

It seems that Rust is mainly invented to solve memory-safety bugs because when people are talking about Rust, memory safety is usually mentioned. Memory-safety bugs, especially in system programming languages, are common but critical software reliability issues. It was confirmed by Microsoft, known as the developer of Windows operating system, that this type of bugs is related to 70% of their security vulnerabilities (COSMIN, 2019). Meanwhile, system developers must treat their logic carefully because they are given almost unlimited permission to control memory, and, in this case, they could let the system communicate with hardware directly and get highest performance (Xu et al., 2022). This implies that the demand for high performance and low-level memory access is a huge obstacle to detecting and solving memory safety issues early on, potentially leading to security vulnerabilities.

Through the reality of recent decades, it may not be advisable to discard memory checks at language level so that developers are likely to make mistakes. A lot of losses could be reduced if the memory safety issues were solved in an early stage. That is an important reason for developers to pay attention to Rust language, as it claims can prevent memory safety bugs when compiling the software. More importantly, Rust can provide low-level memory access and equal performance at the same time, which was presented as the closest one to achieve “the holy grail of programming languages research” (Jung et al., 2018, p. 66:1). Even though practical applications may pose certain limitations, Rust’s potential to drive programming language advancements remains substantial.

Different from the C/C++ language, which places full trust in programmers, Rust pursues the concept of completely distrusting programmers. The rustc, which is the compiler of Rust code, applies a complex sort of static checks based on an ownership-based resource management (OBRM) model to avoid any unintended memory misuse (Xu et al., 2022). By this means, the Rust compiler can determine when a variable is declared, modified, and released without executing the code and point out any risk of bugs. This level of analysis is unachievable in other system programming languages (Xu et al., 2022). In the other word, the safety is ensured when the program is compiled, and the code whose safety cannot be ensured will not be compiled. This approach represents a noteworthy advancement in system programming that it offers a significant boost in robustness without relying solely on long-term developments and experience.

The Unsafe Rust

The “safe” Rust, in fact, is built on “unsafe” Rust. Rust successfully gets the high-level safety and low-level control in one language, but at a different time. “Unsafe” is a keyword in Rust code that identifies the transfer of responsibility to ensure safety from compiler to developer, which means the developer gains permission to control memory freely from the compiler and needs to treat their logic carefully as they do in other system programming languages. Unfortunately, this is inevitable due to the complex software developing conditions that Jung et al (2018) point out even if in Rust’s standard library and many popular libraries, the unsafe code is used widely to implement logic that deviates from the OBRM model but is still correct. This means, the OBRM model cannot cover all memory access requirements for now.

The unsafe part attracts a long-term debate on whether we can formally prove all the safety claims by Rust, which is also a valuable consideration to evaluate the migration to Rust (Xu et al., 2022). Migrating programming languages often comes with additional costs, especially the cost of establishing a knowledge system of new languages, and what matters is whether Rust is worth those extra costs. Xu, Chen, Sun, Zhou and Lyu (2022) examined all of the common vulnerability and exposures (CVEs) in Rust by 2020 and assert that memory safety issues can only be seen in unsafe code. Meanwhile, Astrauskas et al (2020) presents the Rust hypothesis that the safety of unsafe code primarily depends on programmers’ efforts to encapsulate and minify the unsafe part. However, programmers cannot provide a certain guarantee of safety like a compiler does. Although this debate may last for a long time, Rust does reduce memory safety issues compared to others and the research on migrating code from totally unsafe languages to this partly safe language is going on (Emre et al., 2021).

Performance evaluation

Memory-safety issues are not unsolvable as some programming languages like Java have applied many effective mechanisms. Although these mechanisms often come at the cost of worse performance or loss of ability to control memory at a low level, they are acceptable in common use cases. However, Rust claims that it can prevent performance from being a victim.

This claim should be carefully examined because there is a sense that safety and performance are two ends of the scale for a long time. Plauska et al (2023) evaluated performance differences between C/C++, Rust, TinyGo and MicroPython by running several popular data and signal processing algorithms on ESP32, which is a popular microcontroller that is widely used in academia and industry. Not surprisingly, C/C++ tends to have the best performance and often exhibits the lowest execution time. But the difference is not very significant compared to Rust and TinyGo, supporting that Rust indeed has high performance. This is consistent with statements made in other studies (Ardito et al., 2021). While performance comparisons may not cover all scenarios, there is currently no significant evidence of runtime performance flaws in Rust.

The Rust language, in fact, does not break the balance between safety and performance. When turning to its compile time, the significant poor performance could be seen, and it is the truth of its “performance” magic. Regrettably, it is hard to formally measure Rust compiler’s performance. There is some data from the community: (1) In 2011, Rust took 1 hour to compile itself for the first time, according to Mozilla. (2) In 2020, PingCAP reported that the Rust compiler needed half an hour to compile TiKV, their popular database management system product. (3) In 2023, programmer Strager implemented an experiment in which it seems that the Rust compiler's compilation time increased significantly compared to C++ as the amount of code increased.

It appears that Rust is designed to have poor compile performance to ensure its significant runtime behavior. Nevertheless, this is not a concern for most developers since they can get guaranteed runtime performance and memory safety in return.

Learning Curve and Use Case

A well-known aspect of difficulty to promote Rust is its steep learning curve. It is commonly suggested that it may take about half a year for a programmer to become capable of programming with Rust, even with experience in C/C++. Blanco-Cuaresma and Bolmont (2017) represented this challenge. They also mentioned that it is worth the effort and the learning curve will flatten out after the initial stage.

Even so, the Rust language has gained a lot of applications in academia and industry. Koster (2016) built a general purpose bioinformatics library with Rust, and for astrophysics, a simulator named Mercury-T was re-implemented with Rust (Blanco-Cuaresma & Bolmont, 2017). Hardin (2023) proved that Rust could help implement Zero Trust Architecture tenets system because this kind of system takes security very seriously, which is exactly what Rust guarantees. Moreover, some popular complex software projects such as the Linux Kernel, Firefox, and Android are absorbing Rust code (Emre et al., 2021). In view of these applications, it appears that Rust is more of a choice for writing new projects or new parts of old projects than for completely replacing other languages.

In general, the learning curve is still a barrier to increase influence but the work to flatten it has been announced in Rust language roadmap for 2024. Even with a steep learning curve, the adoption of Rust has been in progress for many years in infrastructure and system development areas.

Conclusion

In conclusion, this essay analyzed the Rust language in terms of memory safety, performance, learning curve, and use cases, and clarified the importance of drawing attention to the development of Rust language. First, Rust delivers its promise on memory safety by applying a well-developed memory model with strict static code analysis in its compiler (Xu et al., 2022). However, the complex and less-than-ideal realistic development environment prevents Rust from being perfect in memory safety, as it still requires unsafe code to reach high usability. Thirdly, Rust has a poor compile performance that helps it get a high runtime performance in return, which is also related to its choice on memory safety (Ardito et al., 2021). Lastly, while widespread promotion of Rust may not be feasible due to its learning curve and usage cost, the Rust language should be considered a potential new first choice replacing C/C++ in the development of core components of software or systems. Considering all the points mentioned in this essay, Rust's involvement in real-world projects has become a reality, highlighting the importance for programmers to pay sufficient attention to Rust and avoid missing crucial developments in the software industry. Since the Rust language develops rapidly in recent years, it may address some of the shortcomings mentioned in this essay in the future, which requires continuous attention and information updates.

References

[1] Xu, H., Chen, Z., Sun, M., Zhou, Y. & Lyu, M.R. 2022, "Memory-Safety Challenge Considered Solved? An In-Depth Study with All Rust CVEs", ACM transactions on software engineering and methodology, vol. 31, no. 1, pp. 1-25.

[2] Hardin, D. 2023, "Hardware/Software Co-Assurance for the Rust Programming Language Applied to Zero Trust Architecture Development", ACM SIGAda Ada Letters, vol. 42, no. 2, pp. 55-61.

[3] Ardito, L., Barbato, L., Coppola, R. & Valsesia, M. 2021, "Evaluation of Rust code verbosity, understandability and complexity", PeerJ. Computer science, vol. 7, pp. 1-33.

[4] Astrauskas, V., Matheja, C., Poli, F., Müller, P. & Summers, A.J. 2020, "How do programmers use unsafe rust?", Proceedings of ACM on programming languages, vol. 4, no. OOPSLA, pp. 1-27.

[5] Plauska, I., Liutkevičius, A. & Janavičiūtė, A. 2023, "Performance Evaluation of C/C++, MicroPython, Rust and TinyGo Programming Languages on ESP32 Microcontroller", Electronics (Basel), vol. 12, no. 1, pp. 143.

[6] Jung, R., Jourdan, J., Krebbers, R. & Dreyer, D. 2018, "RustBelt: securing the foundations of the rust programming language", Proceedings of ACM on programming languages, vol. 2, no. POPL, pp. 1-34.

[7] Koster, J. 2016, "Rust-Bio: A fast and safe bioinformatics library", Bioinformatics, vol. 32, no. 3, pp. 444-446.

[8] COSMIN, C. 2019, "Rust – The Programming Language for Every Industry", Economy informatics, vol. 19, no. 1/2019, pp. 45-51.

[9] Emre, M., Schroeder, R., Dewey, K. & Hardekopf, B. 2021, "Translating C to safer Rust", Proceedings of ACM on programming languages, vol. 5, no. OOPSLA, pp. 1-29.

[10] Blanco-Cuaresma, S. & Bolmont, E. 2017, "What can the programming language Rust do for astrophysics?", Proceedings of the International Astronomical Union, vol. 12, no. S325, pp. 341-344.