from Shower Thoughts to Ruminations

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!

Talks

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:

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

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.

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.

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

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

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.

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:

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