X
Business

Facebook revamps Messenger, cuts code from 1.7 million lines to 360,000

The new app is twice as fast to start Facebook said. Meanwhile, the rebuild lays the foundation for cross-app messaging across Facebook products.
Written by Stephanie Condon, Senior Writer
facebook-lightspeed-socialimages-2000x1125.png

Facebook on Monday began rolling out a new version of Messenger on iOS, after deploying more than 100 engineers to completely rebuild the app's architecture and rewrite its codebase. Ultimately, they reduced core Messenger code by 84 percent, from more than 1.7 million lines to 360,000. The new version is twice as fast to start, Facebook says. 

The complete revamp comes nine years after Messenger's initial launch as a standalone app. The app became increasingly unweidly as Facebook added features like payments, camera effects, GIFs and video chat capabilities. At its peak, the app's binary size was greater than 130 MB, Facebook said. 

The rebuild started with the premise that "fundamentally, a messaging app should be one of the smallest, lightest-weight apps on your phone," Facebook wrote on its engineering blog. To minimize complexity and eliminate redundancies, the Messenger team built a unified architecture. This allows for global optimization, rather than having each feature focused on local optimizations. 

To accomplish this, the Messenger team decided to use the native OS wherever possible, rather than relying on abstractions on top of the OS to build new functionality or cross-platform experiences. When the app couldn't rely on the OS, the team built the smallest-possible library code for its specific needs. They also used an operating extension built in native C code for cross-platform logic. 

Next, the Messenger team decided to reuse the UI where possible. For instance, before this project, the app had more than 40 different contact list screens, each with slight design differences. Now, the contact list is  a single dynamic template, with a few categories of basic views powered by different SQLite tables. 

Additionally, the new Messenger uses SQLite as a universal system to support all features. 

Lastly, the team built a server broker to operate as a universal gateway between Messenger and its server features.

To ensure the app remains sustainable, Facebook said, engineers will be expected to meet binary size budgets as they build and update features. The rebuild, the company said, also lays the foundation for cross-app messaging across the family of Facebook products. 

Editorial standards