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 Internet-based applications and servicessocial networkinginternetFacebook

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

Cool Tech

Breitling Superocean Heritage Chronographe 44

Learn more >

SanDisk MicroSDXC™ for Nintendo® Switch™

Learn more >

Toys for Boys

Family Friendly

Panasonic 4K UHD Blu-Ray Player and Full HD Recorder with Netflix - UBT1GL-K

Learn more >

Stocking Stuffer

Razer DeathAdder Expert Ergonomic Gaming Mouse

Learn more >

Christmas Gift Guide

Click for more ›

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

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.

George Khoury

Sharp PN-40TC1 Huddle Board

The biggest perks for me would be that it comes with easy to use and comprehensive programs that make the collaboration process a whole lot more intuitive and organic

David Coyle

Brother PocketJet PJ-773 A4 Portable Thermal Printer

I rate the printer as a 5 out of 5 stars as it has been able to fit seamlessly into my busy and mobile lifestyle.

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?