Hello, Rust!

So, why Rust?

Ownership is Rust’s most unique feature and has deep implications for the rest of the language. It enables Rust to make memory safety guarantees without needing a garbage collector… (Klabnik)

Wedson Almeida Filho recommends adopting Rust for kernel development, declaring:

We feel that Rust is now ready to join C as a practical language for implementing the kernel. It can help us reduce the number of potential bugs and security vulnerabilities in privileged code while playing nicely with the core kernel and preserving its performance characteristics.

Reading about Rust and its “ownership” concept reminded me of C++’s move semantics, which were introduced in C++ by ISO/IEC 14882:2011. It is possible to implement C++ code that mimics Rust’s ownership concept, but this requires skill and effort similar to implementing inheritance and polymorphism in C. Furthermore, C++ code can continue to be implemented without the ownership concept, which is proving to be an effective approach to resource management and addressing a huge class of security vulnerabilities. C++ tools do not enforce the ownership concept, leaving software implementers without active support from compilers for adopting that concept.

Ownership is a core feature of Rust. All Rust programs are implemented around ownership, and compilers are implemented to enforce consistency with ownership rules. Ownership can be borrowed and it can be passed around. When an owner goes out of scope, resources are released. Ownership of a resource and who is responsible for their release is enforced by Rust. Explicit invocation of free() or operator delete is avoided, and this reduces a class of security vulnerabilities that are embodied by stale pointers and memory exhaustion. Python’s with statement and C#’s using statement are not needed, allowing resource ownership to be ergonomically returned by a function to its callers. Rust’s compiler is capable of determining when resources are released and when resources are used after they are released. Rust’s tools enforce the ownership concept. Ownership and resource management are the cornerstone of the Rust programming language.

The Rust programming language allows for implementing performant software, which does not need a virtual machine, explicit release of resources, and garbage collection for resource management. Being performant and rivaling C’s proximity to the hardware, Rust is a fine addition to an embedded software engineer’s toolbox.

Work Cited:

Questions, comments, and responses are welcomed and appreciated.

Leave a Reply