DEV Community

Cover image for Exploring Rust in a Professional Setting: A C++ Engineer’s Perspective
Richard Zampieri
Richard Zampieri

Posted on

Exploring Rust in a Professional Setting: A C++ Engineer’s Perspective

With over 23 years of experience as a C++ engineer, I’ve seen a lot of programming languages and technologies evolve. I’ve always been eager to explore new tools, and recently, I decided to dive into Rust. My current role as a Principal Engineer at a tech company gave me the perfect opportunity to try Rust in a real-world, professional setting.

The Project: System B Communication Layer

We recently started developing a robotics system, and I was tasked with building the architecture for communication between the system A and the system B. This involved creating a layer that interfaces with the System B using ROS2 and delivers messages to a desktop application.

For this layer’s API, I decided to give Rust a try. I bought a book, went through the entire tutorial, and got up to speed fairly quickly. For the UI, I chose Tauri as the framework for the desktop application, using Vue for the front-end.

First Impressions: A New Development Pattern

Rust’s programming paradigm is quite different from what I was used to with C++. If you come into Rust with an OOP mindset, you’re likely to struggle at first. Rust encourages a different way of thinking about memory management, ownership, and concurrency.

One of the biggest challenges I faced was dealing with the compiler. Rust’s compiler is notoriously strict, and you’ll spend a lot of time wrestling with it until you understand how it works. However, this is also one of Rust’s strengths. The compiler forces you to write safe, reliable code, which leads to fewer runtime errors.

The Crate Ecosystem: A Mixed Bag

Rust has a vast ecosystem of crates (libraries), which can be both a blessing and a curse. On one hand, there are millions of crates available for almost anything you can think of. On the other hand, many of these crates are low quality, and it can be challenging to find the ones that are truly useful.

If you’re serious about using Rust in a professional setting, you’ll need to be selective about the crates you rely on. The good news is that once you find the right tools, Rust’s ecosystem can be incredibly powerful.

The Turning Point: Embracing Rust’s Philosophy

After a while, I started to get the hang of Rust’s philosophy. I stopped fighting with the compiler and began to enjoy the coding process. One thing that really stood out to me was how reliable my code became. In C++, I’m used to dealing with warnings and errors during compilation, but with Rust, my code compiled cleanly and just worked.

The sense of security that comes from knowing your code is stable and reliable is one of Rust’s biggest advantages. It’s not something you often experience with C++.

Rust in Production: A Balanced View

In my experience, Rust is absolutely production-ready. It’s a joy to work with, and the language’s emphasis on safety and reliability is a huge plus. However, the ecosystem still has some catching up to do. I found myself building a lot of tooling and writing my own libraries to fill in the gaps for my specific project.

If you’re considering Rust for a professional project, be prepared to invest some time in building out your own tools and libraries. The language itself is fantastic, but you may need to do some extra work to get everything you need.

Final Thoughts: A Positive Outlook

Rust has a lot to offer, especially for developers who value safety, performance, and reliability. While the ecosystem is still maturing, the language itself is rock solid and ready for prime time. If you’re up for the challenge, Rust can be a rewarding addition to your toolkit.

In conclusion, Rust is a joy to program in, even if it requires some adjustment and a bit of extra effort. As the ecosystem continues to grow, I’m confident that Rust will become an increasingly popular choice for professional development. It’s already proven itself in my experience, and I’m excited to see where it goes from here.

Top comments (5)

Collapse
 
thiagomg profile image
Thiago Massari Guedes

Awesome article!
One thing I liked a lot about the cargo experience is that, by having a default package management solutions, many things that are super painful with C++ are trivial with rust. For instance:

  1. You need to decide if you are going to use cmake, make, meson, vcpkg, etc. They don't integrate with each other nicely (it at all). You are likely to face yourself writing a build script for a 3rd party dependencies. Some build tools like xmake try to fill this gap, but when they fail, the complexity to fix is far from trivial
  2. It's simple to perform some tasks such as "retrieve the license of all dependencies, inclusing transitive ones"
  3. Build your solution and all dependencies using Release with Debug Info (if you think that's easy, imagine that using cmake one of your dependencies does not have RelWithDebInfo. All imports will be broken).

After also over 20+ years working with C++ and liking it, I am delighted to use Rust.

Collapse
 
irfanghat profile image
Irfan Ghat

I agree, cargo is extremely useful.

Collapse
 
rsaz profile image
Richard Zampieri

Indeed you're right, I agree.

Collapse
 
thiagomg profile image
Thiago Massari Guedes

Let me add something I found this morning (the first link):

Not a solution to your problem, but a helper for those starting.

Collapse
 
rsaz profile image
Richard Zampieri

That's great resources, thank you for sharing.