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

Subscribe here for up-to-date channel news

Follow Us

Join the New Zealand Reseller News newsletter!

Error: Please check your email address.

Tags Internet-based applications and servicessocial networkinginternetFacebook

Featured

Slideshows

StorageCraft celebrates high achievers at its inaugural A/NZ Partner Awards

StorageCraft celebrates high achievers at its inaugural A/NZ Partner Awards

Revealed at a glitzy bash in Sydney at the Ivy Penthouse, the first StorageCraft Partner Awards locally saw the vendor honour its top-performing partners with ASI Solutions, SMBiT Pro, Webroot, ACA Pacific and Soft Solutions New Zealand taking home the top awards. Photos by Maria Stefina.

StorageCraft celebrates high achievers at its inaugural A/NZ Partner Awards
Kiwi resellers make a splash on Synnex and Lenovo RotoVegas road trip

Kiwi resellers make a splash on Synnex and Lenovo RotoVegas road trip

​Synnex and Lenovo hosted 18 resellers for an action-packed weekend adventure in RotoVegas, taking in white water rafting on the Kaituna River, as well as quad biking and dinner at Stratosfare​, overlooking Lake Rotorua at the top of Mount Ngongotaha​. Photos by Synnex.

Kiwi resellers make a splash on Synnex and Lenovo RotoVegas road trip
Show Comments