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:
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:
- Language: structured bindings,
if constexpr
, class template deduction - Library:
filesystem
,string_view
,optional
,variant
,any
,
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 constexpr
s 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:
Compile time costs of various TMP techniques #cppnow pic.twitter.com/PpudMV9hV5
— Meeting C++ (@meetingcpp) May 17, 2017
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 š:
"This is basically @ericniebler showing off", @odinthenerd on meta functions #cppnow pic.twitter.com/Ipxl4R984e
— Meeting C++ (@meetingcpp) May 17, 2017
Alright, so I think it was right about here when it looked like this outside š³ā¦
Middle of #cppnow. I look happy š #cpp pic.twitter.com/X5VaIU6I7F
— Michael Park (@mcypark) May 22, 2017
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:
Entirely non-serious C++-20 to C++-50 polls. Q0: Most desired #Cpp20 feature. #CppNow #Cpp @cppnow
— Bryce Lelbach (@blelbach) May 19, 2017
and a fun challenge:
What is the most interesting valid #Cpp17 code you can write with no alphanumeric characters other than 'o', 'u', 'a' and 't'? #CppNow
— Bryce Lelbach (@blelbach) May 19, 2017
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:
Aspen -> Denver #cppnow #cpp pic.twitter.com/VrEBpfQF6A
— Michael Park (@mcypark) May 22, 2017
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!