Medtech devices - choosing tech stack

Hello,

I am CTO in a company where we are going to begin develop a proof of concept implementation to a finalized product related to medtech devices within a year. We have no legacy code to take into consideration so this is a clean slate.
The choice will be essential and remain as a long term commitment to the product line in question. I like Rust but will of course have to weigh in a lot of different aspects for this company before I commit to it in production.

The choice for our performant code will stand between C/C++ or Rust.
The core tech stack includes OpenGL and Vulkan, CUDA, Tensorflow, PyTorch, specific computational libraries numpy, and scipy. The software will interface specific NVIDIA cards that are approved to be used with medical devices.

My questions to this community are:
How would you rate the support in Rust for the named core technologies?

How hard would you estimate it to find great Rust developers (I live in Sweden)?
Assume I have to hire some senior engineers with background in C or C++, how much downtime would you expect me to include for training so they can deliver professional Rust code?
How much would an expert Rust developer cost this company?

How would you rate Rust with respect to deployment-integration?

Thanks in advance for anything!

2 Likes

When interfacing with external libraries with C APIs, whether Rust helps or not depends on how much Rust code you're going have beyond just interaction with the APIs.

The downside is that you will need Rust bindings, which are Rust equivalents of .h header files, and keeping them up to date and usable for complex C APIs is a hassle. For C++-only APIs it's a big challenge. If you're doing very little work other than calling 3rd party APIs, that's extra effort for little benefit.

The upside is that Rust wrappers for such libraries can improve safety and ergonomics, even when wrapping C code. That's because Rust's type system can express more information about the interface, and e.g. ensure data is always initialized and handles are freed correctly. Rust bindings can encode libraries' thread-safety constraints in a way that the compiler understands, helping to use them safely in multi-threaded programs. So if you plan to have a lot of custom code, you can benefit from the extra correctness and productivity that Rust adds.

Rust has mature Python bindings PyO3 that people successfully use to extend and accelerate their Python programs.


Regarding hiring:

There's a catch 22 situation where many programmers want to switch to Rust, but don't see any serious Rust job openings, and companies that would like to use Rust, but don't see "Rust" candidates. You have to take a risk to break that loop.

It's ok to hire C or C++ programmers who want to learn Rust, and they don't have to be senior in C/C++. You can also hire programmers with experience in your domain who have little Rust experience. That's because Rust does a lot of "hand holding", and you can tell inexperienced programmers to avoid writing unsafe code, so they will at worst write code in a suboptimal/non-idiomatic way, or get stuck on compiler errors, but they won't break the software in some painful way (like memory corruption or threading heisenbugs).

It's very helpful to have some experienced Rust users in the company to help others get unstuck, and help guide what architectures are a good fit for Rust. Rust has some gotchas that are very difficult to novice users, but are easy to solve for someone who knows the right approach. Rust is productive when you write things "the Rust way". With guidance from someone experienced in Rust, others can become productive pretty quickly.


Rust produces native executables, which are pretty self-contained, and don't require Rust installed. The executables are compatible with a lot of C and C++ tooling (debuggers, profilers, sanitizers, etc.). It has good support for mainstream platforms. It can also target WASM and 32-bit embedded platforms. Rust's standard library adds about 300KB to executables, so tiny devices need special care — it's possible to write Rust without its standard library, with code as small as you'd get from C++ and clang.

7 Likes

A small data-point to consider... In a previous life I was tasked with teaching Rust to our engineers and helping to hire a Rust developer. The folks who used TypeScript daily picked up Rust faster and the candidates who had TypeScript experience were the ones most interested in learning Rust. In other words, please don't dismiss a good TypeScript (frontend) developer as unsuited. You would be doing them and yourself a disfavour.

3 Likes

Rust has adequate bindings for both Tensorflow and PyTorch. While they both seem pretty complete, I've personally found the PyTorch option to be the better to work with, at least for how I'm using it.

For scientific computing there's nalgebra and ndarray. Both crates are quite mature and cover a lot of the same functionality, but nalgebra offers nice stack-allocated options for physics/graphics with fixed-size vectors and matrices while ndarray is tailored specifically for large "dynamic" arrays. I also just saw an announcement for a CUDA extension for ndarray, which I'm looking forward to trying out soon.

I recently started back in on PyO3 and have been very impressed by the latest updates to the API. And there are dedicated crates to for working between numpy and ndarray/nalgebra.

If your product is safety-critical, Ferrocene is an option for compliance with IEC 61508.

Beyond just TypeScript I'd guess that anyone with strong functional programming experience would pick up Rust quite well; not just Haskell for generics/traits but anyone that is good at designing architectures around immutable state. Lifetimes are usually one of the biggest challenges with Rust, and anywhere you can avoid mucking about with mutability you can pass around all the shared references you want.

And maybe just one final note - while I can't comment on the full range of deployment/integration, the Rust toolchain is an absolute pleasure to work with.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.