This article was written in collaboration with Neil Mitchell, a Software Engineer at Facebook.
For today’s interview, we have Neil Mitchell who is a Software Engineer on the Build Infrastructure team at Facebook. The Build Infrastructure team works on build systems such as Buck. While working on this team, Neil has been using Rust as one of the main languages for development. Let’s hear from him about how his experience with Rust has been and learn more about his work.
I'm Neil, a Haskell programmer at heart, who has been doing a lot of Rust recently. I did a PhD in Haskell which included making Haskell programs shorter, faster and safer. I joined Facebook 18 months ago to work on developer tooling, which has involved a transition to more Rust.
I'm a strong believer in having the compiler check your work for you - with enough programmers, and enough code, no one can possibly remember all the subtle properties that make your code safe. However, by enforcing certain rules, the compiler can. The Rust compiler ensures mutability is tamed, concurrency is safe and memory is not leaked. That safety gives us the ability to aggressively refactor as we learn. Combined with advanced abstraction that makes for a powerful language.
I've worked on two Rust projects at Facebook that have been open-sourced:
Gazebo is a library of little utility functions for Rust. Nothing it provides is earth-shattering, but having all these little helpers, refined, documented and tested, can prove a real boost. For example, there are functions for splitting strings, annotating cheap versions of clone, the Any trait with lifetimes.
Starlark is an implementation of the Starlark configuration language, in Rust. This project provides a parser, implementation, linter, IDE tools and debugger for the Starlark language. The Starlark language is a deterministic version of Python, often used for configuration. For more information on how Starlark works, check out this blog on our Facebook for developers page.
I think Rust has all the properties to grow into a major language at Facebook. It's a safer C++. It's a faster Python. It offers compelling benefits compared to most of the alternatives in this space.
Facebook has a large number of programmers, and the more people you have programming a language, the more incidental benefits you get. Beyond that, Facebook often releases open-source libraries, including those in Rust, e.g. Gazebo and Starlark as mentioned above.
Rust continues to grow in terms of users, and the IDE experience with Rust Analyzer continues to improve rapidly. I think this period of Rust's growth will be characterised as the age after async got stabilized - lots of great work was put into the language side to get async working. Now it's a question of getting those changes propagated through the library side - there are plenty of libraries that still rely on older versions of libraries such as tokio, and they need to be moved forward so everyone can benefit.
Rust has loads of features I like, but my favourite feature in Rust are constructors. In a language like Java, a constructor has lots of special rules, must call super-type constructors, must return an instance of the class - it's restrictive and annoying. In Rust, a constructor isn't special - but by convention, it is a static method usually called new, and usually returns Self (the type of the struct). But since it's a by-convention thing, it feels like a constructor, but all the rules can be tweaked, and it's much simpler because it isn't special. This isn't a big thing, but it's my favourite feature because it epitomises Rust - a bunch of well-thought-out simplifications that together have a huge impact.
There are many resources for learning Rust. I particularly liked Learning Rust With Entirely Too Many Linked Lists. I don't really recommend any books, because Rust is somewhat resistant to learning through reading - you have to write code. Spend some time setting up your editor and IDE of choice, as much of starting out with Rust is learning to have a conversation with the compiler and borrow-checker. To contribute, start writing some code, and follow wherever your heart takes you.
We would like to thank Neil for taking the time to do this interview. It was very interesting to learn how Rust is being used as a primary language for build systems 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. Look out for more interview blogs where we meet with many more engineers and hear their thoughts on this topic.
Check out our previous blogs from the Meet the Rustaceans series:
Meet the Rustaceans: Chris Konstad
Meet the Rustaceans: Pedro Rittner
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 Infrastructure at Facebook? Check out our job postings on our Infrastructure career page here.
Sign up for monthly updates from Meta for Developers.