Facebook uses functional programming to make News Feeds run smoothly

Functional programming has been instrumental in helping debug complex code issues, one Facebook development team has found

By , IDG News Service |  Software

Facebook went with a novel programming methodology, called functional programming, to update the News Feed for its Apple iOS client, which helped considerably in tuning and debugging the app.

Functional programming has "increased our reliability in a really big way," said Adam Ernst, an engineer based at Facebook's New York office, who oversaw the effort to rebuild the News Feed for Apple iOS devices.

Facebook's embrace is the latest indication that the functional style of programming, though a radically different approach for many programmers, may offer greater benefits than the declarative style of programming favored today.

Other organizations may also find investigating this approach is of value, in terms of offering better performance and easier debugging.

Ernst and his team turned to functional programming, of which he is an admitted enthusiast, because of the growing headaches around managing and debugging the code used for populating each user's News Feeds with new items.

While the feed may appear to be a simple feature of Facebook, its simplicity is built on a complex set of gears that keep the material up to date -- no easy task given Facebook's billion-plus users.

The News Feed includes status updates, photos, videos, location check-ins and various items of interest that users find on the Internet. Each time a logs into Facebook, a new customized feed of items posted by their friends is created. (Ernst's team is not involved in the sometimes controversial work Facebook does in deciding which items to show in user News Feed).

This operation must happen almost instantaneously because even a 100 millisecond delay can be felt by the user as latency. Making things even more complicated is that with Facebook, users add additional material to News Feed Items, either in the comment section for each entry, or through the "like" button that allows users to express satisfaction that a particular item has been posted. All this material must be updated on the fly, in as close to real-time as possible.

To date, Facebook has used the traditional Model-View-Controller (MVC) approach to coding the News Feed.

The MVC approach can present some challenges, Ernst explained. In particular, it can be difficult to pinpoint subtle errors that result in race conditions, in which two user interactions may interact with one another in unexpected ways. Race conditions are particularly difficult to diagnose, because they may happen only occasionally, based on the unique state of the machine, which is difficult to pinpoint at any given moment in an MVC setup.

Join us:






Answers - Powered by ITworld

Ask a Question