Facebook likes to talk about building for scale and moving fast. It did that even before it had more than a billion users around the globe. Now it’s dealing with such huge numbers, it has no choice – every change has to be made quickly and rolled out to around a billion smartphone apps.
Clearly, making sure all the code is clean and error-free is of utmost importance, because if it rolls out an update that breaks its app there will be a lot of unhappy people.
To help ensure that the most common code errors are caught, it developed a program called Infer that analyzes code before it is shipped live to handsets. Infer was designed primarily to spot problems caused by null pointer access and resource and memory leaks. In addition to spotting errors, Infer also automatically writes comments on source code where it finds the potential issues.
Today, Facebook is open-sourcing Infer, making it available to the wider development community for use and modification.
The move is a continuation of the company’s second push to put more effort towards the open source community – it first tried to do so back in 2008 with projects like Cassandra, but they weren’t very well received at the time, James Pearce, head of open source at Facebook explained to me:
“We, as a company, perhaps did that a little prematurely or rather – we open-sourced this and didn’t have the resources to be able to follow through on the projects and keep them alive.
One thing we’ve learned over the years is that open-source is a bi-directional process, you don’t just throw the software out and forget about it, you have to continue to maintain it and to continue to work with the community…
Our initial attempts were a little uni-directional and as a result didn’t really succeed.”
Around two years ago it decided to start gearing up to release some of its other technologies, notably React and HHVM, both of which were far better received and are now widely used by other companies like Google and Box.
Releasing the technologies into the wider community makes a lot of sense: it aids ongoing development and helps Facebook attract and retain talented coders with an interest in open source.
Pearce said that the company has still struggled to open source technologies in certain areas, like Android, though.
“We haven’t had as much success open-sourcing Android projects to date, but Infer is one of the projects that we’ve released this year that has a very strong Android resonance.”
He added that there’s been one specific and unpredicted effect of open-sourcing some of its technology – it’s made the team more open-minded.
“An interesting phenomenon that we’re seeing is that by open-sourcing stuff ourselves, we and our own engineers become more open-minded about the things that other people in the community create. So, if you open source React and the community goes and creates a whole load of packages and creates an eco-system around React, then we are now more likely to pick the best-of-breed and bring them back in again from that community.
Open-sourcing in one direction has opened our minds to pulling more open-source in from the outside world.”
While Facebook is now embracing the open-source world more fully don’t expect to see the core platform up on GitHub anytime soon – or ever.
Pearce explained that Facebook is only looking to open up technologies that can be widely adopted – opening up the social network wouldn’t really do that.
“We tend to focus on open-sourcing infrastructural pieces, the things that support the user interfaces – we don’t open-source the Facebook app itself. If only because that might even slow us down at the speed the product team is trying to work.
If you look at our overall open source portfolio, the majority of it is product infrastructure just behind the UI… then there’s that top layer which is the experience users have and the apps they use, which we will not [open source].
I’m not sure what benefit there would be honestly. It would slow us down and I don’t know that we’d get that many contributions. And then there’s back-end algorithmic stuff that doesn’t make sense out of the context of the business that we’re trying to run, so no we won’t open source every line of code. “
OK, so you don’t get every line of code, but a huge bug-tracking system to go alongside its other contributions is certainly no bad thing when it means quicker development times for engineers.