When thinking about programming languages in embedded engineering, most people immediately think of C or C++. This is often the default programming language used in embedded, and also the language that most developers are familiar with.

The biggest disadvantage of C, is obviously its memory management (pointers, anyone?). Because developers are responsible for this themselves, mistakes are often made. And many bugs occur because of memory issues. How can we fix this?

About 11 years ago, the good people at Mozilla were sick and tired of the errors that frequently occur in programming languages such as C or C++. That’s why they started developing a new programming language that’s just as high-performing as the existing languages, but also guarantees safe coding: Rust.

what is rust?

Rust is a programming language, but it’s not a traditional programming language such as C or C++. Rust prevents errors in memory use without the overhead of a garbage collector, and provides concurrency without data races - which makes it a safer language. What’s more, Rust is at least as fast as traditional programming languages, in some cases even faster.

man and woman talking behind computer screen
man and woman talking behind computer screen

Okay, we can hear you thinking, but is Rust also as high-performing as the other programming languages? It sure is! You can build just as many and just as extensive applications with Rust as with any other language. A few examples of software and applications for which you can use Rust:

  • firmware
  • embedded software
  • websites (and web assembly)
  • games
  • (device) drivers
  • operating systems
  • applications

who uses rust?

Rust has been gaining popularity in the last few years. Currently, there are many big companies that have switched to this language. For example:

the history of rust.

Rust was initially developed to fix 2 problems:

  • make programming safe
  • simplify concurrency

The biggest cause of bugs in memory or in concurrency, is code that reads or adapts data when it isn’t supposed to. Rust tries to prevent these bugs with the help of ownership: a discipline for access control that systems programmers try to follow, but that Rust’s compiler checks statically for the developers.

When it comes to memory, Rust also uses ownership. It allows developers to program without the overhead of a garbage collector, and without the risk of segmentation errors. Rust catches your mistakes when compiling the code, and gives you the opportunity to fix problems before the bugged code can be executed. This is great, because the sooner you find and fix a bug in the development process, the less money it will cost you.

For concurrency, Rust lets you code without data races, and lets you choose from a huge amount of paradigms such as shared-state, lock-free … Rust will help you prevent frequently made mistakes.

Male and female colleague talking while sitting at a table.
Male and female colleague talking while sitting at a table.

advantages of rust.

If you’re used to other programming languages, you might be hesitant to switch to a new language such as Rust.

Even more so because migrating from one language to another isn’t always easy. But Rust’s creators also took this into consideration: Rust is interoperational and is easily combined with C, C++, Python … You don’t need to rewrite your entire codebase when you want to switch to Rust. You can start with those parts that contain high security and memory risks, and continue with the less critical parts when you are ready.

general advantages.

Rust is a programming language with many advantages. Rust’s compiler checks for errors in memory management, which makes it safer than for example C and C++. Moreover, Rust is fast, at least as fast as C and C++. The language can also be used for quite a few different applications. If you work with Rust, you’ll become part of a growing community. And last but not least: Rust offers a strong build system and package manager.

advantages as compared to other languages.

Rust will offer different advantages depending on the programming language you are used to. We’ll list a few advantages compared to other languages for you.

c.

  • rust guarantees a 100% safe memory
  • you don’t need to worry about segfaults
  • the rust syntax is more comparable to high-level languages

c++.

  • rust offers built in test support
  • you can easily manage the different parts of your project thanks to cargo: the rust package manager

java.

  • guaranteed thread safety
  • no race conditions

c#.

  • guaranteed thread safety
  • no race conditions

python.

  • possibility of interoperability via pyo

disadvantages of rust.

Of course, it’s not all sunshine and roses. This (relatively) new programming language also comes with some disadvantages. The programming itself isn’t too fast, or at least not as fast as for example Python or Ruby. There’s also a steep learning curve, unless you already have thorough knowledge of C++ or another object-oriented programming language. But if you take everything into consideration, you’ll soon see that the benefits of this new language outweigh the disadvantages. 

about the author
Portrait of Kris van der Stappen
Portrait of Kris van der Stappen

devon kerkhove

senior account manager

Working on the (invisible) technology of tomorrow, together with our clients, that's what gets us going. Bitten by embedded systems, driven by innovation.