Facebook turns to wizened old C++ to power new photo-sharing app

Facebook turns to wizened old C++ to power new photo-sharing app

Facebook found that C++ can be used to develop a single code base to run across multiple mobile paltforms

Facebook's new Moments stand-alone app provides a way for friends to share photos

Facebook's new Moments stand-alone app provides a way for friends to share photos

Sometimes the best tool for the job is the oldest one in the toolshed.

For its new Moments photo-sharing application, Facebook eschewed the crop of currently fashionable mobile development platforms in favor of coding in the venerable C++ programming language.

As a result, the company is able to maintain a single code base for much of the app, which runs on both iOS and Android devices.

"It is somewhat of a surprising choice," admitted Ashwin Bharambe, one of the Facebook developers who created Moments, about the use of C++. "There are more and more people trying to do this in order to share code across different platforms."

Launched Monday, Moments is designed to collect and display photos taken by a group of people, such as a group of friends hanging out at a barbecue, so they can be viewed in a single location.

Today one of the most challenging issues mobile development teams must face in building such apps is that they must run on multiple, incompatible platforms. Maintaining separate code bases for Android, Windows and iOS can be particularly time-consuming when new features need to be added, given that all three code bases will need to be updated independently.

A number of companies, such as Xamarin and Microsoft itself, offer platforms that allow developers to maintain a single code-base for a cross-platform application, though the developer gets locked into relying on the platform, and can only use the functionalities the platform itself provides. Another approach is to use the HTML5 set of open standards, though performance can suffer from this approach.

Instead, the Facebook development team went with C++.

Initially developed in the late 1970s, C++ is a powerful general-purpose programming language, and is still widely used for writing mission critical and performance-sensitive applications. It is less widely used, however, for mobile platforms, given that it can be a challenge to program in because it forces the developer to deal with memory management and other subtle nuances in abstraction.

The Facebook team found the extra burden to be worth the effort. With C++, "a lot of our more complicated logic can be written once and run on both iOS and Android," Bharambe said. A single code base allows the group to frequently update the app, as well as offer high performance.

Facebook relied on a number of external technologies to help with the implementation.

From Dropbox, the company borrowed a piece of software called Djinni, which converts C++ data models into Java code, the runtime language for Android.

For iOS apps, Facebook took advantage of the similarities between C++ and Objective-C, which is Apple's preferred language for building iPhone and iPad apps. The team was able to use lightweight wrappers to get the C++ code to work in the Objective-C environment.

The team also used functional programming methodologies to make the resulting code easier to understand by others. Functional programming eliminates the use of variables by treating the code as a series of mathematical functions instead.

The Facebook engineers behind Moments discussed some of the other technology choices they made in a blog item posted Monday.

Joab Jackson covers enterprise software and general technology breaking news for The IDG News Service. Follow Joab on Twitter at @Joab_Jackson. Joab's e-mail address is

Follow Us

Join the newsletter!


Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags internetFacebooksocial networkingInternet-based applications and services



Malwarebytes shoots the breeze with channel, prospects

Malwarebytes shoots the breeze with channel, prospects

A Kumeu, Auckland, winery was the venue for a Malwarebytes event for partner and prospect MSPs - with some straight shooting on the side. The half-day getaway, which featured an archery competition, lunch and wine-tasting aimed at bringing Malwarebytes' local New Zealand and top and prospective MSP partners together to celebrate recent local successes, and discuss the current state of malware in New Zealand. This was also a unique opportunity for local MSPs to learn about how they can get the most out of Malwarebytes' MSP program and offering, as more Kiwi businesses are targeted by malware.

Malwarebytes shoots the breeze with channel, prospects
EDGE 2019: Channel forges new partnerships during evening networking

EDGE 2019: Channel forges new partnerships during evening networking

Partners, vendors and distributors reconnected during a number of social gatherings during EDGE 2019. The first evening saw the channel congregate for a welcome party at the Hamilton Island yacht club, while the main poolside proved to be the perfect stop for a barbecue on the final night.

EDGE 2019: Channel forges new partnerships during evening networking
Show Comments