Facebook Folly – OSS C++ Libraries

I’ve been beating the drum this year (see the last section of the talk) that the biggest problem facing C++ today is the lack of a large set of de jure and de facto standard libraries. My team at Microsoft just recently announced Casablanca, a cloud-oriented C++ library and that we intend to open source, and we’re making other even bigger efforts that I hope will bear fruit and I’ll be able to share soon. But it can’t be just one company – many companies have already shared great open libraries on the past, but still more of us have to step up.

In that vein, I was extremely happy to see another effort come to fruition today. A few hours ago I was at Facebook to speak at their C++ day, and I got to be in the room when Andrei Alexandrescu dropped his arm to officially launch Folly:

Folly: The Facebook Open Source Library

by Jordan DeLong on Saturday, June 2, 2012 at 2:59pm ·

Facebook is built on open source from top to bottom, and could not exist without it. As engineers here, we use, contribute to, and release a lot of open source software, including pieces of our core infrastructure such as HipHop and Thrift.

But in our C++ services code, one clear bottleneck to releasing more work has been that any open sourced project needed to break dependencies on unreleased internal library code. To help solve that problem, today we open sourced an initial release of Folly, a collection of reusable C++ library artifacts developed and used at Facebook. This announcement was made at our C++ conference at Facebook in Menlo Park, CA.

Our primary aim with this ‘foolishness’ is to create a solution that allows us to continue open sourcing parts of our stack without resorting to reinventing some of our internal wheels. And because Folly’s components typically perform significantly faster than counterparts available elsewhere, are easy to use, and complement existing libraries, we think C++ developers might find parts of this library interesting in their own right.

Andrei announced that Folly stood for the Facebook Open Llibrary. He claimed it was a Welsh name, which is even funnier when said by a charming Romanian man.

Microsoft, and I personally, would like to congratulate Facebook on this release! Getting more high-quality open C++ libraries is a Good Thing, and I think it is safe to say that Casablanca and Folly are just the beginning. There’s a lot more coming  across our industry this year. Stay tuned.

12 thoughts on “Facebook Folly – OSS C++ Libraries

  1. Hi, I’m Tudor. I initiated the folly project at Facebook (and I’m responsible for the name) and I’m one of the main contributors.

    Folly was released with an ultimate goal in mind — to make it easier for Facebook to release more, higher-level software written in C++. We also hope it will be useful to other people in its own right, and we’ve made sure that the code is high quality (that’s not to say it’s bug-free, of course; we’d welcome bug reports).

    We do use Linux x86_64 exclusively, and portability has never been a main concern; architecture- and OS-specific optimizations are absolutely worth doing at Facebook’s scale. We liberally use C++11 features that VC++ doesn’t support (variadic templates), we rely on Linux- and gcc-specific library functions, and we make use of optimizations that wouldn’t even make sense on a 32-bit platform (stuffing extra data, including a mutex, inside the 64 bits of a pointer, relying on the fact that at most 48 of those bits are actually used).

    As far as distributions go, we use a heavily customized version of CentOS internally (doesn’t this always happen in large-scale deployments?) and an internally developed build system — all the autoconf stuff and testing the build on various distributions happened for the purpose of open-sourcing this.

  2. Google has released its version of these common shared libraries as part of Chrome (to answer Tom’s question)
    http://src.chromium.org/viewvc/chrome/trunk/src/base/
    Some of this is the same as what’s used on the server side, a lot of it is different. This is a standalone-able library of Chrome that is used in many Google client programs, ChromeOS, etc.

    It doesn’t use C++11 which is either an advantage or a disadvantage depending on your development. To answer Lars’ question, “base” runs on Windows, Linux, OSX, Android, and various (at least at one time or another) BSDs.

    It’s got quite a lot more stuff than Folly, most notably for platform independence, but less “here’s a more optimized version of vector” stuff than Folly. If you’re building a client C++ app, I think the platform-independent message loop processing is the most valuable and complicated part since it’s been tuned for a large high-performance app (Chrome).

  3. Sadly the library reeks of platform dependence, only supporting the particular operating system and distributions that they happened to have used.

    Support for non-Linux is probably spotty, and something like proper Windows is probably a great stretch considering the headers they use, let alone the piles of LP64 assumptions it likely contains everywhere.

  4. Too bad Microsoft is trying to force Metro down everybody’s throat. The decision to remove Win32 application support from Visual Studio Express 2012 is a slap in the face to the open source community. I don’t know any open source developers who want to be locked in to Metro. Any developer who wants to use C++11 features on Windows either has to pay $500 for Visual Studio 2012 Professional or use gcc.

    Herb, I understand you aren’t personally responsible for every decision of your employer. Maybe you agree with what they’ve done with VS 2012, maybe you don’t. If you don’t, it wouldn’t be appropriate for you to air that disagreement in public. Having said that, it’s hard to take you seriously when you talk about open source C++11 libraries while you employer is erecting financial barriers to C++11 adoption by Windows developers.

    http://blogs.msdn.com/b/visualstudio/archive/2012/05/18/a-look-ahead-at-the-visual-studio-11-product-lineup-and-platform-support.aspx

    http://arstechnica.com/information-technology/2012/05/no-cost-desktop-software-development-is-dead-on-windows-8

  5. @Tom: did you ever give POCO a try (http://pocoproject.org)? It’s a (ISO C++) C#-like comprehensive framework; our SAX and DOM XML parsers are 7 years old. Delegates, DB access, events, logging, threading, networking … targeting platforms from phones to mainframes. Parts will be proposed for the next iteration of standard.

  6. I agree, this is good. Bloomberg is doing something similar:

    http://www.bloomberg.com/careers/opportunities/job/show/32195/open-source-moderator-&-administrator—cto-office.html

    A word of caution, though … now that the C++ general-purpose library fragmentation is uncovered, we’ll see how massive C++ wheel reinvention actually is. Which, again, can be a Good Thing if handled right; forces should be synergistically joined to standardize a combination of the best code out there, both performance- and design-wise. Hopefully, more standard proposal pressure will ensue on a wider frontline and we will actually see competing proposals; it is of utmost importance to funnel those into a coherent and well designed standard framework.

    I have to admit – I got intrigued by the act of folly; so much so that I’m getting ready to benchmark Poco::Dynamic::Var against folly::dynamic ;-). Stay tuned …

  7. To use C++ 11 rather than say C# for writing ‘Model’ code in the finance domain what I really need to get the managed folks to pay attention is for the C++ Standards team to put out a technical report that includes a ‘tr::’ namespace with XML support in it… That would be #1… I have a lengthy shopping list for required yesterday Standard Library extensions.

    Nice move by Facebook, let’s hope we see Apple, Google, Adobe and say Autodesk rise to the occasion and offer up some of their internal libraries.

Comments are closed.