CppCon 2014 Multiplatform C++--Edouard Alligand

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:

Multiplatform C++

by Edouard Alligand

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

C++ is a multiplatform language, yet many difficulties arise when you want the same code to compile properly and function identically on different platforms. If you put aside the obvious system programming related obstacles, and the differences you might have between compilers (especially when it comes to supporting C++11 and C++14), you come to the surprising conclusion that what is truly hard is all the "little things" you didn't anticipate.

This talk will be about our experience with our own software, quasardb, that runs every day on three OS (FreeBSD, Linux and Windows), is built with three compilers (clang, gcc and msvc) and supports two architectures (IA32 and AMD64).

How to build natively the same software on Windows and Linux, provided that they have radically different tool chains? How to work around the subtle, but existing differences between Linux and FreeBSD? How do you solve cross-tools, cross-platform file editing problems? How to prevent your maintenance costs from increasing dramatically?

Safety: off - How not to shoot yourself in the foot with C++ atomics -- Anthony Williams

Guidelines for how to use C++ atomics safely in our code using worked examples.

Slides and code and for my ACCU 2015 presentation

by Anthony Williams

From the article:

It's now two months since the ACCU 2015 conference in Bristol, UK, so I thought it was about time I posted my slides.

This year my presentation was titled "Safety: off - How not to shoot yourself in the foot with C++ atomics". I gave a brief introduction to the C++ atomics facilities, some worked examples of usage, and guidelines for how to use atomics safely in your code.

The slides are available here, and the code examples here.

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. [...]