Piloting Rust🦀 from Earth🌍 to Space🛰️
A special collector's edition of the newsletter for programmers working with or curious about the Rust language
Welcome to this special collector’s issue on the Rust programming language.
The urgency for memory safety has escalated dramatically since the February 2024 report from the White House. But even before the White House announcement in early February, Google committed $1 million to improve C++ and Rust interoperability, aiming to ease the transition to Rust for enhanced memory safety in Android apps and then also published white paper detailing its investment. By May, Microsoft had also donated $1 million to the Rust Foundation.
Rust's versatility spans a spectrum of applications, from web and network programming to game development and AI. Major technology giants such as Dropbox and Cloudflare are already harnessing Rust to bolster performance and security. Additionally, the Rust Foundation’s efforts, such as the Security Initiative, aim to continue to strengthen Rust’s role in securing critical infrastructure.
Developers like you, love the language too. Rust's ascent in the TIOBE index to a peak position of #17 in March 2024, up from #211 in 2012, reflects its increasing relevance. The language’s foundational design significantly curtails the likelihood of bugs, earning it accolades as the "most admired" language in Stack Overflow’s 2023 survey, with over 80% of developers keen to continue their engagements with Rust, lauding its superior memory safety attributes that drastically reduce security vulnerabilities.
The popularity of Rust is surging to the point where it is shooting off into space, quite literally. A recent paper, "Bringing Rust to Safety-Critical Systems in Space" advocates for the adoption of Rust in aerospace systems, traditionally dominated by C.
This special edition delves into the qualities that establish Rust as a cornerstone of contemporary programming. From its intrinsic safety features to its strategic applications in high-risk environments, our aim is to furnish you with a resource that you can use as a ready reference while you are learning Rust, mastering it, or working with it in a professional setting.
We really enjoyed making this for you and would love to hear what you think. Do reply to this email or fill out this short survey once you finish reading, to let me know what you thought of this issue and what language or concept you would like us to tackle next.
Stay Awesome
Divya Anne Selvaraj
Editor-in-Chief
🛡️Memory Safety and Rust🗡️
The concept of memory safety is what has largely led to the recent surge in Rust’s popularity. Let’s explore the concept in detail.
What is it?
Memory safety ensures that each data access is well-behaved, preventing errors like buffer overflows and use-after-free, and is a crucial aspect of secure programming. Rust achieves this through its borrow checker, strict type system, and runtime checks, making it ideal for high-assurance software. Read the following to learn more:
🛡️Memory Safety in Rust: Discusses how Rust meets memory safety challenges with its borrow checker, enum type mechanism, and compile-time checks.
🛡️Rust memory safety explained: Highlights Rust's native memory safety features, ownership rules, and lifetimes that prevent common programming errors.
🛡️In Rust we trust? White House Office urges memory safety: Examines the White House's recommendation for using memory-safe languages like Rust to avoid severe vulnerabilities seen in other languages.
Code Examples
🛡️🎥Ep. 2 - Mastering Memory Safety: Rust's Defense Against Use After Free & Use After Move: Explores Rust's ownership system and its effectiveness in preventing "use after free" and "use after move" memory management issues compared to C++ and Go.
🛡️Rust vs. C/C++ - Ensuring Memory Safety & Security: Explains how Rust ensures memory safety and security through its ownership and borrow checker systems, unlike C/C++'s manual memory management which is prone to vulnerabilities.
Criticisms
Because it is always wise to hear both sides of the story.
🛡️Rust is memory safe, but at what cost?: The borrow checker and rules around references can make Rust difficult to use in complex, non-linear scenarios, and this article questions if its strict safety guarantees are worth the performance and usability costs.
🛡️Why the Rust Programming Language Is Not a Silver Bullet for Automotive Security: Explores Rust's benefits and limitations in automotive security, emphasizing that while it reduces memory-related vulnerabilities, it isn't a complete solution due to learning curves, potential misuse, and non-memory-related issues.
Now that we have covered that, let’s pan out and focus on our next important subject. Rust's memory safety is intrinsically linked to its design patterns, which utilize ownership, borrowing, and lifetimes to prevent common bugs like null pointer dereferencing and data races, ensuring safe concurrency and memory management.
🧩Rust Design Patterns📐
In Rust, design patterns serve as crucial blueprints for solving common software design problems, especially given the language's emphasis on safety and concurrency. A fundamental pattern is the Iterator, which allows for safe, efficient looping through collections without risking runtime errors. The Builder Pattern is particularly adapted in Rust to construct complex objects step-by-step, enhancing readability and maintainability, especially when configuring objects with many optional parameters. For managing shared resources, Rust utilizes the Arc and Mutex types to implement the Thread-Safe Singleton pattern, ensuring that mutable data can be accessed safely across multiple threads.
Each pattern leverages Rust's unique features, like ownership and types, to ensure that solutions are both safe at compile time and efficient at runtime, embodying Rust's guarantee of memory safety without needing a garbage collector. The following resources delve into Rust’s design patterns and its elements in more detail.
📑Open Access Book | Rust Design Patterns by the rust-unofficial authors: Provides reusable solutions to recurring software engineering problems, specifically tailored to Rust's unique features such as its functional elements, strong type system, and borrow checker.
🧩Rust ownership model and the borrow checker: Explains how Rust's ownership, borrowing, and lifetimes work together to provide safety and efficiency, making it a valuable read for those seeking to understand Rust's core features.
🧩Understanding Smart Pointers in Rust - A Comprehensive Guide: Provides a comprehensive guide to smart pointers in Rust, detailing their use cases, including Box, Rc, Arc, RefCell, and Mutex.
🧩Rust Concurrency Patterns for Parallel Programming: Covers threads, data sharing, synchronization mechanisms like mutexes and channels, and advanced topics such as error handling, parallel programming with Rayon, and async programming with Tokio.
While Rust's memory safety features significantly and undeniably enhance software security, “Rust is not (just) about memory safety.” Language traits such as strict compiler checks and a robust type system are equally important to ensure program correctness. However, these very traits can present unique challenges that are distinct from those typically addressed by design patterns, primarily due to the language’s stringent safety guarantees and system-level control. Let’s look at dealing with some of these next.
🧗Dealing with Typical Challenges in Rust🏔️
Mastering asynchronous programming, integrating with other languages through FFI, and managing dependencies with Cargo, each require a deep understanding of Rust's unique paradigms and tooling and can prove challenging.
Asynchronous Programming
While Rust's async/await syntax has matured, mastering asynchronous programming in Rust can be complex due to the nuances of executor models, pinning, and ensuring efficient, deadlock-free code. Here are some resources that can help including an excellent Packt title:
📘Asynchronous Programming in Rust by Carl Fredrik Samson. Published by Packt: This hands-on guide simplifies asynchronous programming concepts with functional examples, covering goroutines, fibers, futures, and callbacks, and culminates in the creation of a custom runtime to build proficiency in Rust's async ecosystem. Read now.
🧗Getting Started with Async Rust: Introduces asynchronous programming in Rust from the basics and covers closures, threads, the use of the move keyword for thread safety, and the Arc type for shared ownership among threads.
🧗🎥1 Hour Dive into Asynchronous Rust: Provides an in-depth exploration of how Asynchronous Rust can be utilized to build high-performance servers using minimal resources.
Integration with Other Languages
Interfacing Rust with other programming languages in a system can introduce complexity, especially around the Foreign Function Interface (FFI) boundaries where Rust’s safety guarantees must be carefully managed to prevent issues.
🧗Overview of foreign language interop options for the Rust: Covers interoperability options for Rust in C, C#, C++, Dart, Elixir, Erlang, Java, JavaScript, Julia, Lua, PHP, Python, R, and Ruby.
🧗Exploring Seamless Rust Interop for Newer Languages, Part 1: Provides insights into the technical possibilities and challenges of integrating Rust with newer programming languages.
🧗🎥Fortifying Rust's FFI with Enscapsulated Functions - Leon Schuermann: Talks about innovative mechanisms designed to facilitate safe cross-language interactions and the impact of these mechanisms on system safety and programming efficiency.
Dependency Management
In Rust, dependency management via Cargo is mostly efficient but developers can face issues with complex dependency resolution, version conflicts, increased binary sizes, and outdated dependencies. The following resources provide some best practices to cope with these issues.
🧗On Dependency Usage in Rust: Authoritatively explains the advantages and mechanisms of Rust's dependency management system, including built-in tools for ensuring security and stability.
🧗Dealing with Dependencies in Rust: Comprehensively explains the complexities of dependency management in Rust, particularly regarding distribution through Linux systems, and the importance of careful selection and maintenance.
Now that we have dealt with these prominent issues let’s look at a fresh round up of learning resources on other Rust application areas from around the web including one from the house of Packt.
🎓Other Recent Learning Resources👩🏫
👩🏫💼Case Study | Highlights from "I spent 6 years developing a game in Rust and it just shipped, AMA": Talks about the real-world application of Rust in game development, including its strengths in safety and built-in tools, and challenges with compile times and memory management practices.
📘Rust Web Programming - Second Edition by Maxwell Flitton. Published by Packt: This practical Rust book teaches you how to build high-performance, secure web applications using emerging Rust frameworks, configuring HTTPS on AWS, automating infrastructure with Terraform, and implementing advanced async systems, culminating in best practices for packaging Rust servers in lightweight Docker images. Read now.
👩🏫Enter paradis — A new chapter in Rust's parallelism story: Paradis, a Rust library, introduces a new low-level abstraction for parallel data structure access, simplifying the writing of complex parallel programs in Rust.
👩🏫Types and self-documenting code in Rust: Discusses the implications of Rust's type system on code clarity and maintenance, specifically regarding how data types and trait implementations are presented in method signatures and suggests using more abstract return types, like impl Iterator<Item=char>.
👩🏫Latency at the Edge with Rust/WebAssembly and Postgres - Part 1: Guides you on the integration of Rust, WebAssembly, and Postgres within the Cloudflare Workers environment, focusing on setting up and measuring baseline performance.
👩🏫Cloud Performance on a "Toy" Computer - From Python to Rust: Discusses a successful migration from an outdated Python stack to a modern, efficient Rust-based system, enhancing performance and user experience in web applications.
👩🏫🎥Blazingly fast UDP server using #rust! Road to 1 million clients, XDP and more!: Briefly discusses advanced server setup techniques, performance optimization for high-load environments, and the use of Rust for network-heavy applications.
Now let’s explore some of the new frontiers that Rust is moving into including AI/ML and aerospace.
🤖Rust in AI/ML🧠
The Rust AI/ML ecosystem is still young and experimental, but it offers promising performance and control, with emerging projects and meta-crates like linfa and smartcore providing bundled solutions; there are many opportunities to explore. Here are some resources to start you off on your journey.
📑Open Access Book | Rust Machine Learning Book: A resource for developers familiar with either machine learning or Rust who want to apply ML techniques in the Rust programming language and require insights into algorithms and practical code examples.
🤖Are we learning yet?: A work-in-progress to catalog the state of machine learning in Rust featuring emerging projects, and opportunities for contribution, while providing support through an unofficial Working Group and various educational materials.
📑Open Access Book | The Burn Book: Burn is a deep learning framework designed to work seamlessly with Rust, offering a modular approach to creating and training neural networks. This book is a comprehensive guide to working with the framework.
🤖Awesome-Rust-MachineLearning: A repository including a comprehensive list of Rust machine learning libraries, resources, and tools, compiled for developers transitioning from Python or exploring ML in Rust.
🤖VERT - Verified Equivalent Rust Transpilation with LargeLanguage Models as Few-Shot Learners: Introduces VERT, a tool that utilizes LLMs for transpiling code into Rust with formal correctness guarantees. VERT significantly enhances the accuracy and safety of Rust transpilations, outperforming traditional methods in producing reliable and maintainable code.
🚀Rust in Space🛸
Page 9 of the White house report included a discussion on Rust's potential in space systems, but highlighted a gap between theoretical safety and practical application. Despite Rust meeting essential programming requirements for space—interaction with the kernel, deterministic outputs, and no garbage collector—it was yet untested in aerospace. This hesitance, the report stated, reflects the sector's slow adoption of new technologies due to the high risks associated with space missions.
But, change appears to be on the way. In a recent paper titled, “Bringing Rust to Safety-Critical Systems in Space,” the authors discovered that incorporating Rust into established safety-critical aerospace systems, which predominantly use C, can substantially improve both safety and security. Their research also offers viable strategies for Rust's adoption, including a phased approach to transitioning from C to Rust and the creation of a Rust compiler for PowerPC architectures, enhancing its applicability in space projects.
And beleive it of not, there is already some Rust in space!
🛰️Are we in space yet?: Showcases a catalog of Rust libraries (crates) specifically for aerospace use. The list, sourced from the official Rust crate registry crates.io, is tailored exclusively to aerospace and space applications.
Rust’s future seems rocketship bright, but there is still work to be done, so let’s get back to Earth for the time being.
📚 Reading List 📖
Here is a list of some more open access books 📖 and courses on Rust, some of which we have covered in earlier ProgrammingPro issues, collectively presented here for your convenience.
Beginner
📑 The Rust Programming Language by Steve Klabnik and Carol Nichols, with contributions from the Rust Community: An introductory book.
📑Rust-101 by Ralf Jung: A short, interactive hands on course
📑Rust By Example by Steve Klabnik: A collection of runnable examples that illustrate various Rust concepts and standard libraries.
📑Easy Rust by Dave MacLeod: A Rust textbook in simple English.
Intermediate
📑Comprehensive Rust by the Android team at Google: A current comprehensive course for Rust programmers of all levels.
📑Rust Atomics and Locks - Low-Level Concurrency in Practice by Mara Bos: A book for programmers of all levels who want to understand and correctly implement low-level concurrency, including atomics, memory ordering, and synchronization primitives.
📑The Little Book of Rust Macros by Daniel Keep: A book for Rust programmers seeking to understand and effectively use Rust macros.
Advanced
📑The Rustonomicon by Gankra, Steve Klabnik, and Yuki Okushi: A detailed book on writing unsafe Rust programs, intended for those with a strong background in systems programming and Rust who want to explore the potential pitfalls of the language.
📑Effective Rust - 35 Specific Ways to Improve Your Rust Code by David Drysdale: A book for programmers who have already learned the basics of Rust and are seeking deeper understanding and proficiency in writing fluent, idiomatic Rust code.
That’s all for today. We hope you enjoyed this special issue.
We have an entire range of newsletters with focused content for tech pros. Subscribe to the ones you find the most useful here. Complete ProgrammingPro archives can be found here. Complete PythonPro archives are here.
If your company is interested in reaching an audience of developers, software engineers, and tech decision makers, you may want to advertise with us.
If you have any comments or feedback, take the survey, or leave a comment below.


