This article was written in collaboration with Digant Kasundra, a production engineer at Facebook.
For today’s interview, we have Digant Kasundra who is a production engineer on the Production Engineering Security team at Facebook. Specifically, Digant’s team works on secure access infrastructure. While working on this team, Digant has been using Rust as one of the main languages for development. Most of his work these days centers around safer command execution by automation services. Let’s hear from him about how his experience with Rust has been and learn more about his work.
I'm building a new widely deployed binary for safer command execution by automation services. I'm also looking at migrating some of our other services from Python to Rust.
Our team is mostly Python based, and while Python is great for a lot of things, it also comes with a lot of resource costs on the system. Since we're working on a widely deployed binary, we wanted to make sure we kept the footprint as small as possible. We also saw the benefit of Rust's strict compiler as an essential tool in avoiding lots of the common mistakes one can make in other compiled languages like C++. When a language like Rust comes along, that can give you a higher level of assurance at runtime by helping you catch almost everything at compile time, you can't help but be excited by it. As production engineers, reliability is crucial, as is performance and minimal resource usage. Rust can give you all of those things.
I'm very new to the Rust ecosystem at Facebook. I've helped here and there by bringing in some third party libraries and I have aspirations of doing more. There is quite a lot of room for impact!
I'm excited to see Rust gaining a lot of adoption. I know everyone has their own "favorite" languages, and fan clubs abound. To me, this isn't about any of that. Rust objectively adds a lot of value and from an engineering standpoint, it makes a lot of sense for Facebook to move more of our services and infrastructure in this direction.
Rust is growing and expanding into new areas and engineers at Facebook have a lot of experience in many of these niches. I think we'll see a lot of contributions from Facebook engineers into existing open source Rust projects, and that's a good thing for everyone.
I think there are a lot of work streams on Rust, but I'm most excited to see the improvements around FFI (Foreign Function Interface) and async. We have so much exceptional C++ at Facebook, and any ergonomic improvements around FFI would help us leverage existing code. While I think async is already pretty good, it could always use more love. I also hear the compiler workstream is making big gains, which is awesome!
What I'm going to say is probably controversial and I'll probably get a lot of flack for it, but to me, Rust is like a do-over in programming languages. It absolutely borrows from a lot of existing features and ideas that have been around for some time, but, in my opinion, having the ability to "start clean" lets you rethink how things should work, and that's exactly what Rust has done. My favorite feature is probably the borrow-checker (and my greatest nemesis, at times). Some would argue that this isn't a new idea, but that really isn't the point. How Rust implements this critical part of thinking about memory and ownership is a big step. Many other languages either let the developer ignore it altogether (and have some garbage collection that cleans up after them) or put it all on the developer to manage every aspect of it. With Rust, it's different. It can handle the low level parts of creating and freeing memory, but you have to clearly and directly specify exactly how you're going to use it every step of the way. This is actually critical if you want to avoid hard-to-impossible to debug issues in any kind of threaded application. To me, the approach of the borrow checker is refreshing.
I'm sure by now everyone has heard of the Rust Book, but I always tell people that immediately following that, do the Rustlings exercises. I learn best by doing something hands on, so Rustlings was great. Following that, I wrote my own client/server application which was a simulator for robots with various abilities hunting for resources in a maze and battling each other. It was a great little side project. I recommend everyone come up with some kind of fun side project to learn Rust.
We would like to thank Digant for taking the time to do this interview. It was very interesting to learn how Rust is being used as a primary language for secure access infrastructure, and how we are learning from all the things we build here and contributing back to the Rust community. We hope you found this interview useful and it gave you some insight into how and where Rust is being used at Facebook. Follow Digant on Twitter at @dckasundra.
Check out our previous blogs from the Meet the Rustaceans series:
Meet the Rustaceans: Chris Konstad
Meet the Rustaceans: Pedro Rittner
Meet the Rustaceans: Neil Mitchell
Meet the Rustaceans: Daniel Xu
Meet the Rustaceans: Eric Kuecks
Meet the Rustaceans: Gus Wynn
Meet the Rustaceans: Brendon Daugherty
Meet the Rustaceans: Hasnain Lakhani
Rust has consistently been ranked as the “most loved” language for the last 5 years and we at Facebook believe that Rust is an outstanding language that shines in critical issues such as memory safety, performance, and reliability, and is being used widely over a large range of projects here. We joined the Rust Foundation to help contribute towards the improvement and growth of Rust, which not only strengthens our commitment towards the Rust language but also towards a sustainable development of open source technologies and developer communities across the world.
This blog is a part of our Meet the Rustaceans series, where we invite the engineers and developers who use Rust on a regular basis to share their experiences and tell us about the amazing products that they are building using Rust here at Facebook. Look out for more interview blogs where we meet with many more engineers and hear their thoughts on this topic.
To learn more about Facebook Open Source, visit our open source site, subscribe to our YouTube channel, or follow us on Twitter and Facebook.
Interested in working in Production Engineering at Facebook? Check out our job postings on our Production Engineering career page here.