Why Rust?

16 February 2023 | Product Development

If you have spoken to me recently about software development, chances are I've mentioned Rust.

Rust is a relatively young language that aims to usurp some older languages with new language concepts to eliminate whole classes of bugs and modern development tools.

So what does that mean for you?

Catch Problems Early

Rust provides language features designed to cause problems when writing the software instead of when you run it. This concept fits nicely with my approach of choosing approaches that reveal problems early.

Some of these features are due to its type system. Like LabVIEW, we specify the type or the structure of all the data, and it tells us if there are incompatibilities before we ever run the software. This is in contrast to Python or Javascript, where you can (and I have) have parts of the software assume the wrong structure and cause bugs once the system is deployed.

One strength over many other languages I find is the error system. It makes it hard to ignore a possible error scenario. Whilst this can impact productivity for a quick demo, it greatly increases confidence in the system once deployed. There is nothing worse than debugging an unknown runtime error that only happens every now and again. With this proper handling and logging, this is a rarer case in Rust.

This leads to a much higher confidence in the software once it is built.

High Performance, High Productivity

Rust is a language that lets you get "close to the metal". It has a lot of productivity-enhancing abstractions, which are designed to have little or no overhead. When you need to get every last drop of performance, it lets you drop down to work at a very low level and write code that is very sympathetic to the hardware.

This lets it run efficiently on low-power systems, run fast on powerful systems, and can be used to provide performance to other environments by wrapping the Rust code for use in Python or Javascript.

This means no requirements for overpowered computers and no rewrites in faster languages because we hit a performance limit.

Portability

Probably the most exciting in terms of new capabilities over LabVIEW is portability. Where LabVIEW is generally limited to Intel-powered PCs, Rust can run on various hardware and operating systems. From embedded chips to large servers. You can even run it in a web browser or serverless cloud.

Compared to LabVIEW, this means we can explore more hardware options allowing you to manage your system's size, power and cost.

What's the Catch?

OK, I'm an engineer. I know there is no such thing as a free lunch.

The main downside is that Rust is a young language, meaning there is less support (in terms of developers, vendors and integrations) than in something like C++. The good news is it is quite easy to take C-supported tools into Rust, which is common in the measurement world.

This will improve over time. Rust is being adopted by all the major technology companies and is one of the fastest-growing languages in the world right now.

Productivity may not match higher-level languages for fast, throwaway prototyping as well. There is a cost to reliability and performance, which is a lot more considerations for the developer. If the code is deployed in a production environment, this pays off over time in terms of robustness and ease of change.