June 2015

C++ and Facebook Moments: Facebook code blog, Techworld

fb-moments.PNGHere are two notable articles related to C++'s central role in Facebook's Moments app, released yesterday.

The first is the announcement on the Facebook code blog:

Under the Hood: Building Moments

by Ashwin Bharambe, Zack Gomez, and Will Ruben

From the article:

... There are many alternatives for sharing code between mobile platforms. We wanted to optimize for fast iteration, app performance, and native look and feel. After weighing the alternatives, we chose to write the UI in platform-specific code and the business logic in shared code using C++. Traditionally, C++ is known for providing high performance while lacking easy memory management and higher-level abstractions. However, using modern C++11 features such as std::shared_ptr reference counting, lambda functions, and auto variable declarations, we were able to quickly implement highly performant, memory-safe code...

The growing use of C++ for cross-platform shared code in mobile apps is not a new technical story in itself -- last year's CppCon had multiple sessions about doing this including from Dropbox and Microsoft Office -- but even the mainstream press is starting to notice this is happening more often:

C++: It is back to the future for Facebook's new photo-sharing app

by Joab Jackson, TechWorld

From the article:

Faced with the burgeoning problem of maintaining a code base for multiple, incompatible mobile applications, Facebook engineers turned their noses up at HTML5 and trendy development programmes and went back to the 70s [sic] for an answer.

By choosing the C++ programming language for its new Moments photo-sharing application, Facebook 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." ...

CppCon 2014 How to call C libraries from C++--Lisa Lippincott

Have you registered for CppCon 2015 in September? Don’t delay – Early Bird registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2014 for you to enjoy. Here is today’s feature:

How to call C libraries from C++

by Lisa Lippincott

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Many libraries used by C++ programs present C-like interfaces that are compatible with C++, but are not directly compatible with good C++ style. Using these libraries directly is error-prone in many of the ways C++ is designed to avoid. It is better to pass through an interface layer that presents good C++ style on the C++ side.

But writing such an interface layer is daunting. Completing it may be an enormous task, as are documenting it and maintaining it as the underlying library evolves. To address this problem, I will present a style of writing such interfaces that can be used incrementally as needed, and that reduces documentation cost. I will also present a small library that supports the writing of interface layers in this style.

Folding Expressions -- Marco Alesiani

A new blog post containing runnable code from the Italian C++ Community:

Folding Expressions

by Marco Alesiani

From the article:

C++17, scheduled by 2017 at the time of writing, will introduce fold expressions into play and significantly broaden parameter packs scopes of use [...]

template<typename F, typename... T>
void for_each(F fun, T&&... args)
{
    (fun (std::forward<T>(args)), ...);
}

The sample above uses fold expressions together with the comma operator to create a simple function that calls the provided lambda per each one of the supplied arguments with perfect forwarding. [...]

HPX and C++ Dataflow(await) -- Hartmut Kaiser

Uses/Implementation/Discussion about await feature in modern C++.

HPX and C++ Dataflow

by Hartmut Kaiser

From the article:

We have done some experiments with a preliminary implementation of await in Visual Studio 2015RC. We were able to integrate it well with the futures in HPX and the results are very promising. Unfortunately, the await keyword (and resumable functions) will only be available in all mainstream compilers years from today. So for now we will have to make do with our poor-man’s-await –dataflow.

In any case, if you want to try things out (including dataflow), please fork HPX from our Github site and tell us what you think.

Trip Report: C++ Standards Meeting in Lenexa, May 2015 -- Jason Merrill, Red Hat

With a Core language perspective, with extensive notes about modules discussions:

Lenexa C++ Meeting Report (Core Language)

by Jason Merrill

From the report:

Red Hat sent four engineers to the spring C++ meeting this year, in Lenexa, Kansas, a suburb of Kansas City.  It was hosted by Perceptive Software, a division of Lexmark.  The meeting went very smoothly overall; while there were some disagreements they were pretty cordial...

Bloomberg C++ Challenge for Chance to Attend CppCon

Announced by Bloomberg this week, starts June 22:

Got What it Takes? Enter C++ Challenge for Chance to Attend CppCon

From the press release:

This summer, Bloomberg is hosting a weekly coding competition in partnership with the Standard C++ Foundation and CppCon, the flagship C++ conference. Part of Bloomberg’s overall CodeCon program, this contest will award seven problem solvers with a trip to Bellevue, Washington to attend CppCon in September 2015. The competition will be opened only to students currently enrolled in a university or college. Bloomberg CodeCon is a browser-based eLearning platform used by universities in their curricula, and powers coding challenges for college students in the US and Europe.

The series of seven weekly challenges will kick off on June 22, 2015, and each week contestants will be provided a different set of problems to solve via Bloomberg’s cloud-based CodeCon platform. Each week’s winner will earn a trip to CppCon in September. The list of seven winners will be announced and notified via email on August 5.

Additional coding contests will take place at the CppCon event in September for those who attend.

“We are excited to expand the types of competitions we can create and the opportunities CodeCon can provide to contestants,” said Rangan Prabhakaran, Bloomberg R&D developer and creator of CodeCon. “Focusing the competition to C++ and partnering with an industry leading conference like CppCon allows us to open greater opportunities for the programmer community at all skill levels.”

Keep an eye out for further contest details by following us on Twitter @BloombergLabs where we will be announcing the beginning of challenges – and make sure you are checking out the Bloomberg CodeCon site: http://codecon.bloomberg.com/.

CppCon 2014 Founding C++ User Groups--Jon Kalb & Jens Weller

Have you registered for CppCon 2015 in September? Don’t delay – Early Bird registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2014 for you to enjoy. Here is today’s feature:

Founding C++ User Groups

by Jon Kalb & Jens Weller

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Jens and Jon will share their experiences starting and working with local user groups and C++ conferences. They share some history and pointers on what has worked for them.

If you'd like to start or be active in a local tech group this session will be a good place to start.

CppCast Episode 15: C++ 11/14 Library Best Practices with Niall Douglas

Episode 15 of CppCast the only podcast by C++ developers for C++ developers. In this episode Rob and Jason are joined by Niall Douglas to discuss best practices for C++ 11/14 libraries.

CppCast Episode 15: C++ 11/14 Library Best Practices with Niall Douglas

by Rob Irving and Jason Turner

About the interviewee:

Niall Douglas is a consultant for hire, is one of the authors of proposed Boost.AFIO and is currently the primary Google Summer of Code administrator for Boost. He is an Affiliate Researcher with the Waterloo Research Institute for Complexity and Innovation at the University of Waterloo, Canada, and holds postgraduate qualifications in Business Information Systems and Educational and Social Research as well as a second undergraduate degree double majoring in Economics and Management. He has been using Boost since 2002 and was the ISO SC22 (Programming Languages) mirror convenor for the Republic of Ireland 2011-2012. He formerly worked for BlackBerry 2012-2013 in their Platform Development group, and was formerly the Chief Software Architect of the Fuel and Hydraulic Test Benches of the EuroFighter defence aircraft. He is a published author in the field of Economics and Power Relations, is the Social Media Coordinator for the World Economics Association and his particular interest lies in productivity, the causes of productivity and the organisational scaling constraints which inhibit productivity.

Dive into C++14 - [2] - `for_each_argument` explained and expanded -- Vittorio Romeo

Vittorio Romeo covers in his second tutorial a very interesting code snippet originally posted on Twitter by Sean Parent `for_each_argument`.

Dive into C++14 - Part 2

by Vittorio Romeo

About the tutorial:

It shows and explains the usage of C++14 compile-time integer sequences, and analyzes a very interesting iterative implementation of an alternative version of Sean's function that takes the desired arity as a template parameter.

This tutorial video is a reviewed and improved version of my C++Now 2015 lightning talk ("`for_each_arg` explained and expanded").

Some possible use cases for the implemented functions are also shown and analyzed:

  • `make_vector(...)`
  • `forTuple` - iteration over tuple elements
  • `make_unordered_map(...)`

The target audience is people with knowledge of C++11 features and some C++14 experience.

Previous episodes are here: Playlist