# C++Now 2017

I just returned from C++Now 2017 in Aspen, CO. This was my second time attending the conference and it was just as amazing as last year. My girlfriend decided to come along this time, since Aspen is such a beautiful place. We flew into Denver, rented a car and took the beautiful 4-hour drive into Aspen. She was very happy 🙃. Strongly recommended!

The week started like this:

A post shared by Amber (@audreydevotee) on

## Talks

Here are most of the talks I attended, in chronological order.

##### C++17 Features - Bryce Lelbach

Bryce took a breadth-first approach of exploring C++17 features that are around the corner. They took a form of “Tony Tables”, where we saw a simple before-and-after of each feature. I was glad to find many compelling examples delievered in the talk. It helped me remind myself that although we didn’t get many of the major language features we were hoping for, we still got a lot of useful features into the language. A few highlights:

##### Expression Templates Everywhere with C++14 and Yap - Zach Laine

Zach presented his expression template library called Yap. It’s being proposed as a boost library as a modernization of Boost.Proto. He covered some of the common and compelling use cases of expression templates in the domain of mathematics, then went on to describe the machinery of yap.

If I need expression templates soon (and I think I might), I’m glad to know that there’s a modern libray solution for it 😊.

##### constexpr ALL the things! - Ben Deane, Jason Turner

Ben and Jason shared their experience in pushing the boundaries of constexpr. Exploring containers that can be used during compile-time and run-time, enumerating standard algorithms that can / should be marked constexpr, and standard defects (probably?) such as std::pair’s operator= not being marked constexpr. The relaxed constexpr in C++14 made these constexprs relevant, because now things can be modified, as long as they happen within a constexpr function.

The highlight of the talk was the compile-time parser framework built by Ben to parse JSON at compile-time. This was of particular interest to me because I’ve written a compile-time parser myself to parse format strings in experimenting with mpark/format. Needless to say, this was a very engaging talk for me.

##### The Mathematical Underpinnings of Promises in C++ - David Sankel

David talked about the mathematical approach of reasoning about futures and promises (although he sticks to calling them just promises). We first learned about denotational semantics and found that it’s not quite sufficient due to the introduction of time; we then moved onto using operational semantics to tackle the issue.

This talk was mainly focused on math, but it lead into his follow-up talk, Promises in C++: The Universal Glue for Asynchronous Programs, in which he describes his open source promise library that is based on this mathematical backing.

##### Postmodern Immutable Data Structures - Juan Pedro Bolivar Puente

Juan presented his persistent, immutable data structures library called immer. Functional languages have been promoting value semantics since the 1950s, and was part of C++ since its initial design. Most of us love value semantics because of the referential transparency it provides, making our programs much easier to reason about.

The issue of performance has gotten in the way of using value semantics in the past, and move semantics in C++11 made that a lot more practical. Juan takes this further by allowing objects to share views of common subcomponents. The result is that we get very efficient data structures that are very fast to compare, with a compact undo-history.

He also presented ewig, a text editor using these data structures. Demo involves opening and editing a very larg file. Two things stood out to me:

• The text editor displays an asterisk when the file has been modified but not yet saved. When it is modified to be the same state as the original, the asterisk disappears immediately. This may not seem like a big deal, but it demonstrates that the original stayed in tact, and that the comparison is super fast.

• Juan copy-pasted a large portion of the file a bunch of times, and the editor handled that with no problem whatsoever. He then stopped and told us something along the lines of, “at this point, if we were to save this file and re-open it, we wouldn’t have enough memory to read it back in”.

Impressive.

##### Type Based Template Metaprogramming is Not Dead - Odin Holmes

Odin presented kvasir, the fastest metaprogramming library out there, competing against others like meta, metal, mp11, and brigand. According to metaben.ch, it’s the fastest in every algorithm except cartesian product. metal takes that one, but Odin had an excuse for it 😜.

On a more serious note, he presented an empirical study of the cost of compile-time operations:

Strategically paying for the cheaper compile-time operations is the secret to kvasir’s efficiency. I’ll need to remember this list to improve the compile-time for mpark/variant. Glad to have some general guidance here 😀.

Also, this was funny 😂:

Alright, so I think it was right about here when it looked like this outside 😳…

A post shared by Amber (@audreydevotee) on

Okay, back to the talks.

##### Call: A Library that Will Change the Way You Think about Function Invocations - Matt Calabrese

Matt presented his experimental call library that explores the space of function invocation, which in my opinion is a bit of a mess in C++ land currently.

Utilities such as std::apply, std::invoke, and std::visit all work great independently, but they don’t compose all that well.

He presented 3 hours worth of material, but this is the most basic issue:

In Python, we can say:

args = (1, 2, 3)
f(0, *args)


In C++, we have…

auto args = make_tuple(1, 2, 3);
apply([](auto&... args) { return f(0, args...); }, args);


This is way too complicated… With call, you can instead say:

auto args = make_tuple(1, 2, 3);
call(0, unpack(args));


Much better. The library does a lot more than this, but this is the beginning of its motivation.

The talk is based on his standards paper: A Single Generalization of std::invoke, std::apply, and std::visit.

##### Practical (?) Applications of Reflection - Jackie Kay

Jackie talked about reflection in other languages, followed by a comparison of P0194 “reflexpr” proposal, vs P0590 “operator \$” proposal. She pointed out that the proposals currently only support introspection, and that in order to do really interesting things we’d need more.

She shared a bunch of examples that were tested with the current implementations in Clang, I’m really glad that she’s investing time to get practical experience with the proposals.

The talk is based on her popular blog posts: An Introduction to Reflection in C++ and Fun with Reflection in C++.

##### Locally Atomic Capabilities and How to Count Them - Lisa Lippincott

I went to Lisa’s talk last year, What is the basic interface? which won best session. This was a follow-up to that session, and it was just as engaging.

She formally discusses the nature of capabilities of functions divided into different “neighborhoods”. She makes an analogy to chemistry, where the essential atoms are preserved during the flow. In programming, “claim”s such as “destructible”, and “deallocatable”, exit a function like new, and enters a delete. By counting the flow of essential atoms, one can detect bugs that arise due to humans’ poor ability to perform non-local reasoning.

While I understood the gist of the talk, I’m sure I didn’t fully follow. So I’m already looking forward to watching it again on YouTube 🙂.

## Beyond the Talks

The program was fantastic this year. Shout out to our program chair Bryce Lelbach, and all the speakers for their spectacular material.

Having said that, the real reason I attend C++Now is not because of the talks. As embarrassing as it is to admit, I missed all of the keynotes this year. But it’s okay. I can catch those on YouTube. (Sorry, keynote speakers! I’ll catch you on YouTube, I promise.)

What I cannot catch is the face-to-face interactions I get with the speakers and attendees, many of whom I consider to be good friends. C++Now is intentionally scheduled with a long lunch, and frequent, long breaks between sessions. People also hang out at the bar in the evenings, most nights into early morning. It’s ridiculous. I was up every night until 2am - 4am, discussing ideas, learning new concepts, having heated arguments, presenting my thoughts, and listening where I’m a novice.

It’s wonderful, and to me, this is the real magic of C++Now.

Also, a fun poll by Bryce, asking for the most desired features up to C++50:

and a fun challenge:

Ah… what a week.

## My Contribution

I gave a lightning talk entitled “MPark.Patterns: Pattern Matching in C++14”.

It’s a brief introduction of mpark/patterns which I’ve been working on in order to bring a clean pattern matching library to C++.

I started out with a few simple examples, and finished with a complex, red-black tree balancing code at the end:

My general feeling was that it was well received. Michael Caisse asked people to raise their hands if they thought the library was cool, and from what I saw, more than half of the room raised their hand! 😀

There’s some stuff that I didn’t get to present in the 5-minutes, of course. For example, the sum pattern allows matching on variant-like types, and the variadic pattern allows the power to implement std::apply, and std::visit. The real power of course is not just the ability to implement them, but rather the ability to compose them.

I’m planning to continue my work here and give a full session in the future. 🤓

The 4-hour drive back to Denver:

## Last but not Least

• Thank you to the conference chair Jon Kalb for putting an excellent conference together every year.
• Thanks to all of the conference staff and student volunteers.
• Thanks to my employer Mesosphere for sponsoring me to attend!