Tales from a Rust Developer

Facebook
Twitter
LinkedIn

With the Rust programming language becoming ever more popular among the developer community, and tech companies with a rapidly increasing demand for Rust skill sets, I decided to do a Q&A with Simon Chen; a Senior Software Engineer with more than 15 years professional experience and an avid contributor to the Rust Open-Source community, who’s been working with the language over the last 2 years, to see why it’s causing such a buzz!

Below, we delve in to how and why he got in to Rust, the benefits of using it on projects, what he loves about the language and helpful tips for anyone who wants to get started with it. 

Q: Where and when did you first hear about Rust?

A: “I think it was around the beginning of 2021. I tried to look into any new technology that can help improve memory safety, of a production system, and I came across an open-source community that mentioned about a new language that is memory safe by design.”

Q: When did you first try it out and why?

A: “The first time I tried Rust was because we had a legacy C/C++ system that acted as a service layer for an underlying embedded system. This component had complex logic and concurrency, requiring us to use various tools to detect memory issues and prevent faults. Writing concurrent-safe and memory-safe code in C/C++ was challenging, and the static analysis and dynamic analysis of the code required a significant amount of time.

We decided to use Rust to prototype a port of the legacy component to see the benefits of using Rust in production. During the process, we faced challenges due to language boundaries between Rust and C/C++, as the software layers depended on each other. However, one major advantage we gained was that if we wrote “safe code” in Rust, we didn’t need to run sanitise tools. Rust has two modes: “unsafe code” and “safe code.” When using “safe code” we were confident that it would work properly, eliminating concerns about concurrency and memory safety. This was a significant benefit.”

Q: What was your first personal project in Rust?

A: “It was part of an Open-Source project, developing a distributed messaging backend service to support a large-scale CI/CD system. At that time, we were mainly using Python and Java but the performance of the python service component was shortcoming, so we rewrote the core component (hot path) of the Python service using Rust to improve the performance of the system.”

Q: What do you like about the language?

A: “I’ve had this question several times, even during job interviews, and there are several key features that have made me fall in love with Rust. I’ll try to explain them, in no particular order…

Firstly, I come with a background in Python and C/C++, mainly. The pain point that I had in working with C/C++ is that, if we talk about C first, C is unsafe. You need to be very good at understanding how to properly use it to write safe code. But for Rust, you have the guaranteed memory safety. That is one key feature I love. And then comparing with C++, although modern C++ has new support in the standard library – like smart pointers can provide memory safety to manage the memory, they are built on top of the library compared to Rust which has the memory safety built into the compiler and not provided by the Standard library. 

Finally compared with Python, Python is flexible and easy to learn but there is a performance penalty, especially in large distributed systems. Rust can provide very good performance and memory safety, all together. So, the many problems that I struggled with in other languages, seem to have been solved by the Rust ecosystem.

There is another very important aspect I should mention, if you walk into the Rust open-source community you really see it’s a very nice community. You’ve got a lot of good, warm hearted engineers and contributors that are willing to answer your questions and respond very promptly. It’s the kind of spirit that can spread throughout. So, when I started to engage in the Rust community, I also felt that I had the responsibility and happiness to share my knowledge. It’s really great compared with other communities I have encountered”

Q: What don’t you like about the language?

A: “I would have to say nothing major to mention, at least so far!”

Q: What type of projects do you see it being most suited for?

A: “I think the first thing will be for Embedded systems because it provides a very low memory footprint, comparable to C, with embedded systems dominated by the C language. So, Rust will definitely be a strong competitor. The second thing is with distributed systems, which I like to work with, where you can’t avoid concurrency. You have to use a lot of concurrent techniques and by using C, if you really care about performance, it’s quite painful and quite difficult to master. Rust will solve many basic problems for you.”

Q: Why should developers learn Rust?

A: “Firstly, I’m not a businessman so I’m not trying sell anyone on learning Rust.”

“But I would say that for a developer who likes learning and really growing their knowledge about computer science, learning Rust is a really rewarding experience. You can understand a lot of underlying design choices and why it’s beneficial. You can see, for example, after Rust has become popular, there is also some research projects that tried to add another layer on the C language to provide a similar kind of lifetime annotation mechanism, in the existing C language, to provide a similar memory safety guarantee.

When you learn Rust, the language itself and the standard library has very good documentation. So, when you really dig into that, you can also learn quite a lot of niches in the compiler. And, of course, with a very helpful community, if you have questions, it’s easier to understand the new concepts in the language design.”

Q: What best tips do you have to get started with Rust?

A: “Well, me personally, I actually have a learning Road map when I try to learn a new language which I followed when learning Rust.

In short, I started with a tutorial (which Rust has a very good one for) then I went on to two things; The first is to start searching open-source projects that are popular and have a good reputation among the community. Then I try to join that community and look at any kind of issues they need help with that’s good for beginners to get started on. In parallel, I started to think about what kind of project I can create by myself, to solve a real problem, which related to my own work and interests. That’s very important!

Then I started reading all kinds of tutorials that were recommended by the Rust community, both on ‘safe code’ coding guidelines and ‘unsafe code’ coding guidelines.

Also, if you choose a topic, for example you choose async network programming. There is a dedicated async book from Rust, so you can really get in to that area if you choose to. I personally started with ‘Tokio’ because, at that time, I found it to be a good project and I needed to write a library that heavily uses networking.

Finally, I always try to follow the top voices in the community. In Rust, you have David Tolnay, Niko Matsakis and Alex Crichton, which all do great work and very good to listen and learn from.”

Q: What do you think about the future of Rust?

A: “I believe it will continue to grow and be more widely adopted as time goes on. Firstly, if the community can keep the same spirit as now e.g. helpful, approachable for new beginners etc. that will key in its growth. Secondly, Rust has gone into several key, OS kernel. Windows, for example, have rewritten some parts of the Windows kernel using Rust and also Android have migrated parts of them system to it as well. So, both desktop and mobile systems are already adopting and setting a good foundation for the future.”

Q: Are there any other languages that you are learning / would like to learn alongside Rust?

A: “I haven’t considered learning anything new, right now, because I still think I have a lot to learn in Rust. For me, I can use Python and Rust to solve most of the technical problems I face. Python is very good for doing prototyping and Rust is used for production. So far, I’m happy with that.”

In conclusion, my talk with Simon shed a lot of light on the fact that Rust has been developed to solve a lot of the problems that are usually faced with other programming languages. Hence, the reasons why it’s so popular among developers – it saves a lot of headaches!

In addition, it’s a language that has many use cases; whether it be embedded, backend, web etc. with a high focus on performance, which many tech businesses need in this day an age.

To top things off, it seems like the language is truly rewarding to learn, with a great community around it and welcoming to beginners, and recommended for anyone with a thirst for knowledge!

Thanks for reading. If you have any thoughts or feedback then I’d welcome your comments below.

Best Regards,

Roger Hickford

Founder – Futuris Recruitment