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 Joab_Jackson@idg.com

Join the newsletter!

Error: Please check your email address.
Rocket to Success - Your 10 Tips for Smarter ERP System Selection

Tags internetFacebooksocial networkingInternet-based applications and services

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Joab Jackson

IDG News Service
Show Comments


James Cook University - Master of Data Science Online Course

Learn more >


Sansai 6-Outlet Power Board + 4-Port USB Charging Station

Learn more >



Back To Business Guide

Click for more ›

Most Popular Reviews

Latest Articles


PCW Evaluation Team

Louise Coady

Brother MFC-L9570CDW Multifunction Printer

The printer was convenient, produced clear and vibrant images and was very easy to use

Edwina Hargreaves

WD My Cloud Home

I would recommend this device for families and small businesses who want one safe place to store all their important digital content and a way to easily share it with friends, family, business partners, or customers.

Walid Mikhael

Brother QL-820NWB Professional Label Printer

It’s easy to set up, it’s compact and quiet when printing and to top if off, the print quality is excellent. This is hands down the best printer I’ve used for printing labels.

Ben Ramsden

Sharp PN-40TC1 Huddle Board

Brainstorming, innovation, problem solving, and negotiation have all become much more productive and valuable if people can easily collaborate in real time with minimal friction.

Sarah Ieroianni

Brother QL-820NWB Professional Label Printer

The print quality also does not disappoint, it’s clear, bold, doesn’t smudge and the text is perfectly sized.

Ratchada Dunn

Sharp PN-40TC1 Huddle Board

The Huddle Board’s built in program; Sharp Touch Viewing software allows us to easily manipulate and edit our documents (jpegs and PDFs) all at the same time on the dashboard.

Featured Content

Product Launch Showcase

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?