{"id":302,"date":"2021-08-31T14:40:03","date_gmt":"2021-08-31T14:40:03","guid":{"rendered":"https:\/\/fde.cat\/?p=302"},"modified":"2021-08-31T14:40:03","modified_gmt":"2021-08-31T14:40:03","slug":"a-brief-history-of-rust-at-facebook","status":"publish","type":"post","link":"https:\/\/fde.cat\/index.php\/2021\/08\/31\/a-brief-history-of-rust-at-facebook\/","title":{"rendered":"A brief history of Rust at Facebook"},"content":{"rendered":"<p><span>Facebook is embracing Rust, one of the<\/span><a href=\"https:\/\/insights.stackoverflow.com\/survey\/2020#most-popular-technologies\"> <span>most loved<\/span><\/a><span> and fastest-growing programming languages available today. In addition to bringing<\/span> <span>new talent<\/span><span> to its Rust team, Facebook has announced that it is officially <a href=\"https:\/\/developers.facebook.com\/blog\/post\/2021\/04\/29\/facebook-joins-rust-foundation\/\">joining the nonprofit Rust Foundation<\/a><\/span><span>. Alongside fellow members including Mozilla (the creators of Rust), AWS, Microsoft, and Google, Facebook will be working to sustain and grow the language\u2019s open source ecosystem.<\/span><\/p>\n<p><span>For developers, Rust offers the performance of older languages like C++ with a heavier focus on code safety. Today, there are <a href=\"https:\/\/developers.facebook.com\/blog\/post\/2021\/04\/22\/meet-rustaceans-chris-konstad\/\">hundreds of developers at Facebook<\/a> writing millions of lines of Rust code. And while it\u2019s clear that Facebook is increasingly invested in the future of the language, it\u2019s important to understand how we grew to this point.\u00a0<\/span><\/p>\n<h2><span>2016\u20132017: Early use in source control<\/span><\/h2>\n<p><span>Our oldest Rust codebase dates to 2016, when the rate of source code changes in Facebook\u2019s monorepo started to encroach on the maximum commit rate that the Mercurial source control management tool could keep up with. In response to this, Facebook\u2019s Source Control team launched a rewrite project called<\/span><a href=\"https:\/\/github.com\/facebookexperimental\/eden\/tree\/master\/eden\/mononoke\"> <span>Mononoke<\/span><\/a><span> with the goal of increasing Mercurial\u2019s commit rate by some additional orders of magnitude to serve Facebook\u2019s thousands of developers and automated processes.<\/span><\/p>\n<p><span>Developing Mononoke in C++ was the obvious choice at first. At the time, Facebook\u2019s back-end codebase was very C++ heavy, meaning Mononoke would have been implemented in C++ by default. But the Source Control team needed to consider the reliability needs of the source control back end. When corruption or downtime can potentially bring services to a halt, reliability is a top priority. That\u2019s why the team chose to go with Rust over C++.<\/span><\/p>\n<p><span>Jeremy Fitzhardinge, a software engineer in production confidence at Facebook, describes this experience in a<\/span><a href=\"https:\/\/www.youtube.com\/watch?v=kylqq8pEgRs&amp;list=PL85XCvVPmGQhDOUIZBe6u388GydeACbTt&amp;index=7\"> <span>talk at RustConf 2019<\/span><\/a><span>.<\/span><\/p>\n<p><span><\/span><span>Mononoke served as a great test bed because it was naturally fairly isolated from other Facebook systems. As long as Mononoke could use the Mercurial protocol to speak with client services and the Thrift protocol to communicate with some storage systems, choosing Rust wouldn\u2019t affect anything outside of the Source Control team\u2019s work.<\/span><\/p>\n<p><span>The Source Control team was willing and able to support itself in any Rust-specific tooling and infrastructure. This played out well, and Mononoke has been the production back end for our monorepo since 2019, successfully scaling over the years.<\/span><\/p>\n<h2><span>2017\u20132019: The adoption curve<\/span><\/h2>\n<p><span>With Mononoke as evidence that it was viable and lived up to its claims, over time, other projects considered and adopted Rust as well. At first, these were typically developer tooling projects that didn\u2019t need to integrate with the broader service infrastructure, or small services\/daemons that could do their work with just a few handwritten wrappers around some C++ client libraries.<\/span><\/p>\n<p><span>Many of the engineers at Facebook who adopted Rust came from Python and Javascript backgrounds. They appreciated Rust\u2019s combination of high performance with compile-time error detection. As more success stories, such as performance improvements at two to four orders of magnitude, circulated within the company, interest grew in using Rust for back-end service code and exploring its use in mobile apps as well.<\/span><\/p>\n<h2><span>2019\u20132020: Some dedicated support for Rust<\/span><\/h2>\n<p><span>From 2017 through 2019, the Source Control team doubled as the unofficial Rust support team within Facebook. But by 2019, the number of Rust developers at Facebook had grown exponentially, to over 100.\u00a0<\/span><\/p>\n<p><span>As one significant example of that growth, Rust is the leading language in the development of the <\/span><a href=\"https:\/\/www.diem.com\/en-us\/\"><span>Diem<\/span><\/a><span> (formerly Libra) blockchain, which is overseen by the independent Diem Association. Facebook, through its digital wallet Novi, is a member of the Diem Association. The Diem blockchain is primarily written in Rust, covering 94 percent of the open source <\/span><a href=\"https:\/\/github.com\/diem\/diem\"><span>codebase<\/span><\/a><span>. In addition, <\/span><a href=\"https:\/\/developers.diem.com\/main\/docs\/move-overview\"><span>Move<\/span><\/a><span>, a new, secure programming language to be used for the blockchain, was developed with Rust.<\/span><\/p>\n<p><span>Given this growth in need, the part-time assistance of the Source Control team wasn\u2019t enough to support the number of teams standing to benefit.<\/span><\/p>\n<p><span>We created a small Rust developer experience team, which dedicates its attention to tooling and integration challenges, such as building the<\/span><a href=\"https:\/\/github.com\/facebookincubator\/reindeer\"> <span>mechanism<\/span><\/a><span> for using the language\u2019s open source package registry ecosystem in production non-Cargo builds. The team formed a central point of contact for Rust developers across the company to unblock use cases, prioritize short-term developer experience concerns, improve core libraries, and generally set the fledgling Rust codebase up for success as it passed the million-line mark.<\/span><\/p>\n<h2><span>Onward (2021 and beyond)<\/span><\/h2>\n<p><span>At the end of 2020, we re-upped our commitment by launching a Rust team in our Programming Languages organization, the same org responsible for Facebook\u2019s C++ standards work and toolchains.<\/span><\/p>\n<p><span>This team has a longer-term focus beyond immediate developer experience priorities in the context of our codebase. In particular, all contributions to grow and sustain Rust as a healthy and productive language and community are now in scope.<\/span><\/p>\n<p><span>In the short term, this new team is focused on four areas:<\/span><\/p>\n<p><span> \u00a0 \u00a0 \u00a0 <\/span>Supporting internal users from a language and toolchain perspective:<span> This includes toolchain rollouts, cross-cutting migrations, code review\/audit, best practices, and acting as a point of contact for language and toolchain questions.<\/span><br \/>\n<span> \u00a0 \u00a0 \u00a0 <\/span>Contributing positively in the community outside Facebook:<span> The team performs code reviews of the standard library and compiler and provides developer resources toward priorities of the Rust community.<\/span><br \/>\n<span> \u00a0 \u00a0 \u00a0 <\/span>Easy and safe interoperability of Rust with C++:<span> We have a vast amount of C++ code that is necessary to communicate with the back-end systems that services are built on. We need developers to be able to use these libraries safely and easily without sacrificing the benefits that Rust offers. Inversely, if we want to see Rust components integrated with our larger C++ binaries, we need smart runtime interoperability in asynchronous code. Facebook\u2019s servers are highly distributed and heavily threaded. Rust tasks need to play nicely on a C++ threadpool and safely share synchronization primitives and I\/O resources. We have already done a lot of work in the C++ space improving asynchrony, having supported and quickly adopted C++20\u2019s coroutines. Bringing Rust into the game will be an extension of that and will build on the excellent work already happening in the Rust asynchronous library stack.<\/span><br \/>\n<span> \u00a0 <\/span>Actively supporting and engaging with the <a href=\"https:\/\/foundation.rust-lang.org\/\">Rust Foundation<\/a>: <span>Facebook has been committed to the Rust community and expanding its development with Rust since 2016. We are taking that commitment even further by joining the Rust Foundation as a Platinum <\/span><a href=\"https:\/\/foundation.rust-lang.org\/members\/\"><span>member<\/span><\/a><span>, where we hope to help continue to drive the advancement and adoption in a proactive and impactful way.<\/span><\/p>\n<p><span>Rust\u2019s journey within Facebook is far from finished. This team is small, but it will grow over time as support needs scale. We are excited and optimistic about the trajectory of Rust within Facebook and across the industry. Our plans for work inside Facebook, open source contributions, and more community-oriented work will develop over the course of 2021.<\/span><\/p>\n<p>The post <a href=\"https:\/\/engineering.fb.com\/2021\/04\/29\/developer-tools\/rust\/\">A brief history of Rust at Facebook<\/a> appeared first on <a href=\"https:\/\/engineering.fb.com\/\">Facebook Engineering<\/a>.<\/p>\n<p><a href=\"https:\/\/engineering.fb.com\/2021\/04\/29\/developer-tools\/rust\/\">Read More<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Facebook is embracing Rust, one of the most loved and fastest-growing programming languages available today. In addition to bringing new talent to its Rust team, Facebook has announced that it is officially joining the nonprofit Rust Foundation. Alongside fellow members including Mozilla (the creators of Rust), AWS, Microsoft, and Google, Facebook will be working to&hellip; <a class=\"more-link\" href=\"https:\/\/fde.cat\/index.php\/2021\/08\/31\/a-brief-history-of-rust-at-facebook\/\">Continue reading <span class=\"screen-reader-text\">A brief history of Rust at Facebook<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[7],"tags":[],"class_list":["post-302","post","type-post","status-publish","format-standard","hentry","category-technology","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":614,"url":"https:\/\/fde.cat\/index.php\/2022\/07\/27\/programming-languages-endorsed-for-server-side-use-at-meta\/","url_meta":{"origin":302,"position":0},"title":"Programming languages endorsed for server-side use at Meta","date":"July 27, 2022","format":false,"excerpt":"\u2013 Supporting a programming language at Meta is a very careful and deliberate decision. \u2013 We\u2019re sharing our internal programming language guidance that helps our engineers and developers choose the best language for their projects. \u2013 Rust is the latest addition to Meta\u2019s list of supported server-side languages. At Meta,\u2026","rel":"","context":"In &quot;Technology&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":888,"url":"https:\/\/fde.cat\/index.php\/2024\/06\/25\/the-key-to-a-happy-rust-c-relationship\/","url_meta":{"origin":302,"position":1},"title":"The key to a happy Rust\/C++ relationship","date":"June 25, 2024","format":false,"excerpt":"The history of Rust at Meta goes all the way back to 2016, when we first started using it for source control. Today, it has been widely embraced at Meta and is one of our primary supported server-side languages (along with C++, Python, and Hack). But that doesn\u2019t mean there\u2026","rel":"","context":"In &quot;Technology&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":776,"url":"https:\/\/fde.cat\/index.php\/2023\/10\/23\/5-things-you-didnt-know-about-buck2\/","url_meta":{"origin":302,"position":2},"title":"5 Things you didn\u2019t know about Buck2","date":"October 23, 2023","format":false,"excerpt":"Meta has a very large monorepo, with many\u00a0 different programming languages. To optimize build and performance, we developed our own build system called Buck, which was first open-sourced in 2013.\u00a0 Buck2 is the recently open-sourced successor. In our internal tests at Meta, we observed that Buck2 completed builds approximately 2x\u2026","rel":"","context":"In &quot;Technology&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":728,"url":"https:\/\/fde.cat\/index.php\/2023\/06\/27\/meta-developer-tools-working-at-scale\/","url_meta":{"origin":302,"position":3},"title":"Meta developer tools: Working at scale","date":"June 27, 2023","format":false,"excerpt":"Every day, thousands of developers at Meta are working in repositories with millions of files. Those developers need tools that help them at every stage of the workflow while working at extreme scale. In this article we\u2019ll go through a few of the tools in the development process. And, as\u2026","rel":"","context":"In &quot;Technology&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":258,"url":"https:\/\/fde.cat\/index.php\/2021\/02\/07\/open-sourcing-thrift-for-haskell\/","url_meta":{"origin":302,"position":4},"title":"Open-sourcing Thrift for Haskell","date":"February 7, 2021","format":false,"excerpt":"What it is: Thrift is a serialization and remote procedure call (RPC) framework used for cross-service communication. Most services at Facebook communicate via Thrift because it provides a simple, language-agnostic protocol for communicating with structured data. Thrift can already be used in programming languages such as C++, Python, and Java\u2026","rel":"","context":"In &quot;External&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":492,"url":"https:\/\/fde.cat\/index.php\/2021\/10\/20\/facebook-engineers-receive-2021-ieee-computer-society-cybersecurity-award-for-static-analysis-tools\/","url_meta":{"origin":302,"position":5},"title":"Facebook engineers receive 2021 IEEE Computer Society Cybersecurity Award for static analysis tools","date":"October 20, 2021","format":false,"excerpt":"Until recently, static analysis tools weren\u2019t seen by our industry as a reliable element of securing code at scale. After nearly a decade of investing in refining these systems, I\u2019m so proud to celebrate our engineering teams today for being awarded the IEEE Computer Society\u2019s Cybersecurity Award for Practice for\u2026","rel":"","context":"In &quot;Technology&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/posts\/302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/comments?post=302"}],"version-history":[{"count":1,"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/posts\/302\/revisions"}],"predecessor-version":[{"id":408,"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/posts\/302\/revisions\/408"}],"wp:attachment":[{"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/media?parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/categories?post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/tags?post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}