Rust is a programming language developed by Mozilla and which, among other things, has a very solid memory management. The language means that the developers do not have to think about memory management and therefore this type of bug is significantly fewer.
One of our customers has recently started using Rust as a complement to C. We thought it was really exciting and took the opportunity to ask our consultant Robin Carlsson some questions to find out how the change worked. Robin has previously run a lot of C, Python and a bit of Java.
How come you started programming in Rust?
The possibility of switching from C to Rust appeared when the customer was developing a new electronic card (for signal processing) with associated software. For embedded systems, C is a standard choice, but Rust has emerged in recent years as a strong candidate. One of the developers in the project saw the potential in using Rust for parts of the functionality.
What positive effects have come with the change?
A common problem with C is manual memory management, and the number of features in the language is relatively few. Rust addresses both of these issues (it’s more like C ++ than C in terms of functionality), and also has a very strict compiler (much thanks to the way the language is designed). This leads to quick feedback and bug fixing during development time. It is also possible to call C-code from Rust, and vice versa, so you can integrate the languages instead of making a sudden change. In this particular project, parts of the Rust Code also proved to be faster than an equivalent in C. During the project, several areas have also been found in the existing code base that has been improved by rewriting in Rust. C is still the customer’s primary language, but Rust is now available as an alternative.
Have you encountered any problems with Rust?
One problem with starting to use Rust is precisely that it is so new. Both the language and several of the libraries are updated quite often, and although the language itself should be (virtually) backwards compatible, it has happened that you have had to back up some version on some library, as it has not worked with other libraries. Sometimes you have also lacked a specific function, which has not been implemented in the language yet (a fairly small problem, as there is usually some other similar way to solve the problem). There is also significantly less information from other developers online (compared to eg C). However, this is balanced by a really well-written and easily accessible documentation by Rust, and also most of the libraries.
Since the language was also new to several of the developers in the project, it also took a while to learn.
Do you have any tips for those developers who are curious to start working in Rust?
Check out the official website! There is information on how to set up your development environment, documentation of the language, tutorials, news and much more. Above all, the documentation is very well written, and very helpful for finding your way around the language. If you want to get started and code, I think you should start with a limited area. Try to find some part of the code (new or existing) that has a clear and preferably small API, to minimize limitations and hassles that it can mean to jump between programming languages. If you just want to experiment a bit, you can try to rewrite an existing code block in Rust, and see if you can integrate it. If you want to write some code without having to set up your development environment, there is also a “playground” on the website to write smaller blocks of code directly in the browser. Rust is also not limited to built-in systems, so regardless of developer background, I recommend that you at least read a little about the language, to see what it can add.
About the author:
Jonas Karlsson, System Developer