top of page

VISIONAIRY® Expert Talk with Sanket Shah, Spleenlab GmbH

  • Writer: janhartmann6
    janhartmann6
  • Oct 2, 2024
  • 4 min read

Sanket Shah, Spleenlab GmbH

In the VISIONAIRY® Expert Talk, our engineer Sanket Shah talk about how RUST can be used to significantly increase the safety of AI perception software in robotics compared to conventional methods.


1)  What is RUST? How is it different from the usual C++ and Python?

Rust is designed to help programmers avoid mistakes that could cause programs to crash or be unsafe. In contrast, C++ gives more control but also makes it easier to make dangerous mistakes. Python, on the other hand, is very easy to write but can be slower because it has a garbage collector that cleans up memory for you. Rust gives a balance: it’s fast like C++ but safer and more predictable, making it great for big, complex systems where both performance and reliability are important.


2) Explain what does RUST is safer mean using a simple example?

Imagine you’re building a large car factory. Using C++ is like giving workers complete freedom with powerful tools but no safety instructions—they can work fast but are more likely to make dangerous mistakes. Python, on the other hand, is like hiring workers with simple tools and clear instructions, making them less likely to mess up but slower to complete tasks, with a cleanup crew occasionally slowing things down. Rust is like designing the factory with tools that are both powerful and safe, allowing workers to be fast like in the C++ factory but with built-in checks that prevent accidents, making the process both efficient and reliable.


3) If you had to pick one feature of RUST that makes it safer than C++, and hence easy to certify, what would it be?

RUST has a lot of cool features, that makes it robust, but I had to pick just one, it would be “Memory Safety”. Memory safety refers to the ability of a program to safely manage and access memory without causing crashes, leaks, or unexpected behavior. Rust guarantees memory safety through its ownership system, which tracks how memory is used and prevents dangerous actions like accessing memory that has already been freed. Let’s understand it with an example. Consider a library that loans out books. In Rust, each book can only be checked out to one person at a time, ensuring it is returned before being loaned out again, preventing issues like a book being damaged or lost. In contrast, C++ allows multiple patrons to check out the same book simultaneously orforget to return it, leading to potential chaos in the library. There might be a scenario, where a student is allowed to issue a book which is borrowed by someone else or is discarded by the library. This analogy relates to memory: Rust’s ownership rules act like a diligent librarian who keeps track of which books are available, ensuring safe and organized access to resources. Meanwhile, C++ offers more freedom but relies on developers to manage their own memory responsibly, which can lead to errors and unsafe conditions.


4) Safety-critical domains like autonomous drones, demand real-time performance and precision. In your view, what makes Rust an attractive language for building robotics applications, especially in comparison to C++?

Rust is an appealing choice for safety-critical domains applications because it offers a unique blend of speed, safety, and efficiency. While languages like Python prioritize ease of use at the expense of performance, leading to slower execution times, Rust provides the performance characteristics of C++ without sacrificing safety. Its ownership model ensures memory safety and prevents common errors like data races and memory leaks, allowing developers to build reliable systems for real-time applications. This means that robots programmed in Rust can operate quickly and efficiently, making split-second decisions while avoiding the pitfalls that often come with managing memory manually in C++. Overall, Rust strikes an excellent balance, making it a powerful option for robotics where both performance and reliability are critical.


5) How does RUST handle concurrency similar to how C++ has concurrency mechanisms provided by C++ multi threading. How is it more safer and is the speed up similar?

Rust handles concurrency through its ownership model and type system, which help prevent common pitfalls such as data races, ensuring that multiple threads can operate safely on shared data. Unlike C++, where developers need to manually manage mutexes or locks to protect shared data, Rust’s borrow checker enforces rules at compile time that prevent data from being accessed simultaneously in conflicting ways. This means that if one thread is using data, another cannot access it until it’s released, effectively eliminating data races. As a result, Rust’s approach to concurrency not only makes programs safer but also reduces the likelihood of bugs that can be difficult to track down in C++. In terms of speed, Rust’s concurrency model can achieve similarperformance to C++ because it allows fine-grained control over system resources, enabling efficient parallel execution of tasks without the overhead of runtime checks. Overall, Rust provides a robust and efficient framework for concurrent programming, making it a strong contender for performance-critical applications like robotics and real-time systems.


6) As AI continues to grow in complexity, how do you see Rust being adopted in the field of deep learning and machine learning development? Do you think it could eventually replace C++ in this domain?

As AI continues to grow in complexity, Rust is poised to be adopted in the field of deep learning and machine learning development, especially for applications requiring high performance and memory safety. However, C++ remains well established in this domain, with mature and optimized backends like ONNX Runtime and TensorRT that facilitate efficient model inference. Despite Rust’s advantages, there is currently no scalable and well-maintained solution for deploying AI models on edge devices using Rust. At Spleenlab GmbH, we are addressing this gap by developing our in-house Rust library for inference on edge devices, which leverages Rust’s fast inference capabilities and memory safety. While Rust may not completely replace C++, its role is likely to grow asmore developers recognize the benefits it offers for safety-critical applications in the evolving landscape of AI.

bottom of page