Efficient running of Facebook newsfeed through functional programming
Functional programming has been constantly used to debug complex codes and the same is being used by Facebook development team to fix on the bugs in their website. Facebook went along with the functional programming method to get the News feed updated in their client Apple iOS. This model has helped in tuning as well as debugging the apps to a very large extent.
Benefits:
During the process of rebuilding the news feed for the Apple devices, functional programming was very reliable, says Adam Ernst, engineer based in NY Facebook office. This approach by Facebook has clearly indicated that compared to declarative type of programming, functional programming has more benefits. Different developers have different approach towards this technology.
If this approach and programming model is implemented, then many of the other organizations will be able to provide better debugging options and performance.
The engineering team along with Ernst was enthusiast of this new programming model as lot of tension was getting raised during the debugging and maintenance process of the news feed especially when a user adds new item. Given the number of Facebook’s user, keeping the material up to date might look simple but it at the back end it is build on complex systems.
How it works:
Facebook’s newsfeed consist of different sets of items that has been posted in any profile by friends and family in the form of status updates, videos, photos, location etc. Each login by the user creates a new customized personal newsfeed. This process has to be very fast to avoid the latency time in the user. Every time a user posts any comments or even click on the like button, creates lot of complication as the information needs to get updated in real time.
According to Ernst, functional programming has been this complicated task easy and possible. It helps in understating the flow of information through code and how it can be reproduced easily and fast. Functional programming enables the developer to compose program by assembling a chain of functions. When compared to the declarative program it doesn’t use standard loop often known as immutability.
Even though functional programming is very popular in the academic community, it has not seen much implementation until recently. The popularity of this functional programming can be attributed to the multicore processors. The new Facebook iOS has already been implemented in iphone and ipads which enables the entire newsfeed to get refreshed even after single click. The amount of memory that can be taken by the functional programming has not been an issue to the Facebook engineers.
There are lots of languages designed for functional programming like ML, Haskell, Scheme and F# language etc. along with many other languages like java, JavaScript or even swift can be used as well. Ernst and team have used what they call multiple paradigm language which includes languages like C++, Objective C classes of objective etc, which can support lot of functions.
Based on this functional style, a user interface library has been created in another part of the company, known as React. This was the inspiration for Ernst. Currently they are working on getting the team of Android client to look for investment in this programming.
As per Ernst, using this programming model in iOS has increase the idea sharing in Facebook and future growth is expected.