Standardizing Variant: Difficult Decisions -- Anthony Williams

Techincal discussion information while standardizing N4542.

Standardizing Variant: Difficult Decisions

by Anthony Williams

From the article:

One of the papers proposed for the next version of the C++ Standard is N4542: Variant: a type safe union (v4). As you might guess from the (v4) in the title, this paper has been discussed several times by the committee, and revised in the light of discussions.

Boost has had a variant type for a long time, so it only seems natural to standardize it. However, there are a couple of design decisions made for boost::variant which members of the committee were uncomfortable with, so the current paper has a couple of differences from boost::variant. The most notable of these is that boost::variant has a "never empty" guarantee, whereas N4542 proposes a variant that can be empty.

CppCon 2014 Making C++ Code Beautiful--James McNellis & Kate Gregory

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:

Making C++ Code Beautiful

by James McNellis & Kate Gregory

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Ask a non-C++ developer what they think of C++ and they'll give the language plenty of compliments: powerful, fast, flexible, and "the language for smart people". But along with that you are likely to hear ugly, complicated, hard to read, and "the language for smart people". Is it possible to write beautiful C++? Not arcanely elegant or wickedly compact, but readable, clear, expressive - beautiful! We say it is, and we want to show you how.

In this session, you'll see how to turn pages of "comic book characters swearing" into code you'll be proud to call your own. By making your code express your intent, using the power of new language and library functionality, and leaving hard-to-read constructs out of your vocabulary, you can give your code a makeover that will stand the test of time.

Time To Get Moving! -- Tony DaSilva

A nice "in a nutshell" about why you should run, not walk, to take advantage of move semantics:

Time To Get Moving!

by Tony DaSilva

From the article:

Starting from C++11 on, we not only get those operations for free for our user-defined types, we also get these turbo-boosters:

  • a “free” move constructor
  • a “free” move assignment operator

In addition, all of the C++ standard library containers have been “move enabled“.

When I first learned how move semantics worked and why this new core language feature dramatically improved program performance over copying, I started wondering about user-defined types that wrapped move-enabled, standard library types. For example,  check out this simple user-defined Msg structure that encapsulates a move-enabled std::vector...

Webinar: A Tour of Modern C++ -- Thursday, July 2nd, 2015

JetBrains is hosting a free webinar (registration required):

A Tour of Modern C++

Thursday, July 2nd, 2015

14:00 - 15:00 GMT (10:00 AM - 11:00 AM EDT)

The C++ programming language has moved quickly from relative stagnation to rapid evolution, with new versions of the standard adding sought-after features to the language and standard library. In this webinar we shall take a look at the latest language additions introduced in C++11 and will also talk a little bit about some of the forthcoming features in C++14 and 17.

Space is limited, please register now. There will be an opportunity to ask questions during the webinar.

About presenter

Dmitri Nesteruk is a developer, speaker, podcaster and technical evangelist. His interests lie in software development and integration practices in the areas of computation, quantitative finance and algorithmic trading. His technological interests include C#, F# and C++ programming as well high-performance computing using technologies such as CUDA. 

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/.