Journal Articles

CVu Journal Vol 31, #1 - March 2019
Browse in : All > Journals > CVu > 311 (6)

Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.

Title: C++ On Sea 2019 Trip Report

Author: Bob Schmidt

Date: 04 March 2019 15:57:00 +00:00 or Mon, 04 March 2019 15:57:00 +00:00

Summary: Arne Mertz and Frances Buontempo share their experiences of a new C++ conference.

Body: 

Arne Mertz

From February 3rd through February 6th I have been in Folkestone, UK, to visit the first C++ On Sea conference. There must be something in the water on that island that enables them to organize fantastic conferences like ACCUConf [1] and, since this year, C++ On Sea [2].

C++ On Sea is definitely the best conference I have ever been to, and here’s a little glimpse why I think so.

To put my experience in context, here is what my main reasons are for going to conferences:

I arrived in Folkestone on Sunday evening. It is in Kent, UK, directly where the channel tunnel emerges. Leas Cliff Hall, where the conference took place, is situated directly on the cliffs and has a great view that sometimes lets you see the French coast. If it’s not windy, rainy and foggy as it was most of the time during the conference.

Conferences don’t start with the opening speech or first keynote. They start on the day before, when people meet to chat and socialize. In this case, I had dinner with one of several groups of people from the #include<C++> community [3].

Monday, February 4th

On Monday morning, the actual conference programme started with an opening speech by the conference organizer Phil Nash.

C++ was not only in the conference name, but also in the details: The opener was titled “Hello, World”, there was a “main()” plenary hall and session rooms titled “const west”, “east const”, and “unsigned”. The latter was the smallest of the session rooms and had an overflow problem a few times, but luckily that did not lead to undefined behavior, because C++ conference attendees seem to be very nice people in general.

The list of C++ puns goes on, as you can see from the floor plan [4] and schedule [5].

The first keynote of the conference was ‘Oh, the humanity!’ by Kate Gregory [6]. She showed how the cliché of the logical, unemotional programmer is wrong. We can see lots of emotions in the code we write, and we better check whether it’s the emotions we want to show towards our fellow programmers.

One of the takeaways from the talk was that single letter variable names are bad and a sign of laziness. I myself am guilty of this, and throughout the conference, lots of speakers commented on their own slides along the lines of “yeah, since Kate’s keynote I know I should fix those”.

After the keynote, normal sessions started in four tracks. The first talk I went to was ‘Postmodern immutable data structures’ by Juan Pedro Bolivar Puente [7]. Juanpe showed some great examples of very efficient, partially copy-on-write, vector-like data structures.

The next talk I visited was by Adi Shavit and is called ‘What I Talk about When I Talk about Cross Platform Development’ [8]. Adi showed how the ‘Salami tactic’ enables us to write as little platform-specific code as possible by building thin layers of platform-independent C and C++ APIs around a pure C++ domain core.

Subsequently, I went to the main() track to see Jason Turner talk about ‘Practical Performance Practices Revisited’ where he showed how seemingly innocent changes can enable the compiler to optimize our code. The talk contained a fair amount of ‘life-godbolting’ and showed how optimizer technology is advancing: Jason himself sometimes seemed to be surprised that newer versions of Clang reduced his examples to a no-op or a constant return statement.

After that followed the most amazing talk I have ever seen at a conference. The keynote ‘Deconstructing Privilege’ by Patricia Aas [9] does not seem to have anything to do with C++, but it has to do a lot with the people who use it.

In her talk, Patricia shows how even though we might have hardship in our lives, being spared discrimination due to race, gender, sexual preferences and/or other factors can give us a head start in life. If you look again at the list in my Tweet above, this talk is a great example of #2: I have never before seen a large room filled with so many people in complete stunned silence.

After the keynote, there was a session of 11 interesting, enlightening, and entertaining lightning talks. The day concluded with a gala dinner where speakers and attendants met to eat and chat.

Tuesday, February 5th

After a short kick off, day two of the programme started with another round of sessions. The first one I visited was ‘Programming with Contracts in C++20’ by Björn Fahller [10]. Contracts let the programmer define preconditions and postconditions for their functions that can, depending on compilation flags, be checked at run time.

While this sounds like a great thing to have, the current state of the standard draft looks rather disappointing to me. This is also due to some properties of the language that implementers cannot always work around. However, while I am writing this, a standing committee meeting takes place at Kona, where no less than seven papers regarding contracts are scheduled for discussion.

The second talk was quite something different in many regards. Hana Dusíková talked about ‘Compile Time Regular Expressions’, but not in person: Due to a cancelled flight, she had to give the presentation remotely. And, of course, Murphy’s law provided some technical difficulties so she had to rely on Matt Godbolt as an avatar to handle her slides and, lacking a working camera, tell her about reactions from the audience.

This manner of talk delivery was quite an experience and had an element of fun, at least for the audience. But the talk itself was just amazing. Hana presented the intricacies of parsing regular expressions at compile time in a casual manner that makes constexpr template wizardry seem like a stroll in the park. In addition, there even was a working regex parser written in JavaScript in her slides (that Matt had to type the input for) to demonstrate the tree her library builds at compile time. Quite a few minds were blown by this talk.

Then it was time to give my own talk about ‘Learning (and Teaching) Modern C++ – Challenges and Resources’ [11]. In the presentation, I talked about how the quick evolution of our language makes it hard for teachers and authors to keep their knowledge and teaching materials up to date, and about the benefits and drawbacks of the different resources available to us.

As the next talk to watch I chose ‘Sailing from 4 to 7 Cs: just keep swimming’ by John Shearer [12], because it mentioned one of my blog posts [13] in the abstract and the talk: John presented how his team started out with the ‘4C’ development environment (Clang, CMake, CLion, and Conan) and added three more ‘C’s and quite a few other letters to their tool stack.

The last keynote of the conference was by Matt Godbolt: ‘What Everyone Should Know About How Amazing Compilers Are’ [14], in which he showed us how good optimizers are at guessing what developers want to do. In a series of live compiler explorer examples, he presented how modern optimizers can sometimes melt multiple lines of code into a single assembly instruction.

The key takeaway from this keynote: Trust your optimizer, don’t manually optimize in ‘smart’ ways without checking the output, because you might actually inhibit the optimizer from recognizing common patterns.

Conclusion

For me, the conference was a blast. I met a lot of people I had known from other conferences, quite a few that I had only met online before at #include<C++>, and made a handful of acquaintances I would not have made otherwise. Full marks for #1 of my conference checklist.

There were also quite a few talks that were fun and/or engaging to attend, for me and others. A check on #2 of the list, and also for #3, as I find it always rewarding to share thoughts and experiences with a room full of people, even though the prospect is extremely scary every time I submit a talk proposal.

If you have not been there, there are two things you should do: Try to get a ticket for the next instalment (hopefully 2020) and watch the videos on YouTube [15]. (At the time of writing, new videos are being uploaded every day.)

Frances Buontempo

Phil Nash organised a new conference, CppOnSea [2], this year. I was lucky enough to be accepted to speak, so attended the two conference days, but not the workshops.

There were three tracks, along with a beginners track, run by Tristan Brindle, who organises the C++ London Uni, which is a great resource for people who want to learn C++ [16]. I’ll do a brief write-up of the talks I attended.

The opening keynote was by Kate Gregory, called ‘Oh The Humanity!’ She made us think about the words we use. For example, Foo and Bar trace back to military usage, hinting at people putting their lives on the line. Perhaps we need better names for our variable and functions. We are not fighting a war. What about one letter variable names? ’k. Nuff said. What about errorMessage? If you call the helpMessage instead, how does that affect your thinking?

Kate was also talking about trying to keep the code base friendly, to increase confidence (Figure 1).

Figure 1

I went to see Kevlin Henney next. I have no idea how to summarise this. He covered so many thing. What does structured programming really mean? By looking back to various uses and abuses of goto, by highlighting the structure in various code snippets, he was emphasising some styles make the structure and intent easier to see.

I saw Andreas Fertig next. Inspired by Matthew CompilerExplorer’s Godbolt [17], he has created https://cppinsights.io/. Try it out. It unwraps some of the syntactic sugar, so you can see what the compiler has created for, say, a range-based for loop. This can remind you where you might be creating temporaries or have references instead of copies or vice versa, without dropping down into assembly. Do you know the full horror of what might be going on inside a Singleton? (See Figure 2.)

Figure 2

This led to an aside about statics and the double checked locking pattern. His headline point was the spirit of C++ is ‘you pay only for what you use’, so be clear about what you are using. The point isn’t that the new language features are expensive. They are often cheaper than old skool ways of going things. Just try to be clear about what’s going on under the hood. Play with the insights tool.

Next up, I saw Barney Dellar, talking about strong types in C++. His slides are probably clear enough by themselves, since they have thorough speaker notes [18]. My main note to myself says ‘MIB: mishap investigation board’, which amused me. He was talking about the trouble that can happen if you have doubles, or similar, for all your types, like mass and force:

  double CalculateForce(double mass);

It’s really easy to use the wrong units or send things in the wrong order. By creating different types, known as strong types, you can get the compiler to stop you making mistakes. Use a template with tags, you can write clear code avoiding these mistakes.

Next up was a plenary talk by Patricia Aas on ‘Deconstructing Privilege’. She’s given the talk before, so you’ll be able to find the slides [9] or previous versions on YouTube. Her take is that privilege is about things that haven’t happened to you. Many people get defensive if you say they have been privileged, but this way of framing the issue gives a great perspective. Loads of people turned up and listened. Maybe surprising for a serious geek C++ conference, but the presence of https://www.includecpp.org/ ensured there were many like minded people around. If you are privileged, listen and try to help. And be careful asking intrusive questions if you meet someone different to you.

After quite a heavy, but great talk, I was ‘in charge’ of the lightning talks. Eleven people got slots. More volunteered, but there wasn’t time for every one:

My heartfelt thanks to Jim from http://digital-medium.co.uk and Kevlin ‘obi wan kenobi’ Henney for helping me switch between PowerPoint, PowerPoint in presenter mode and the PDFs, and getting them to show on the main screen and my laptop. No body knows what was happening with the screen on the stage for the speaker. If you ever attend a conference, do volunteer to give a lightning talk. Sorry to the people we didn’t have time for.

Day one done. Day two begun. First up, for me, after missing my own talk pitch, was Nico Josuttis. Don’t forget his leanpub C++17 book [19]. It’s still growing. He talked about a variety of C++17 features. The standout point for me was the mess you can get into with initialisation. He’s using {} everywhere, near enough. Like

  for (int i{0}; i<n; ++i)
  {
  }

Adding an equals can end up doing horrible things.

Much as I wanted to go see Simon Brand, Vittorio Romeo and Hana Dusikova (with slide progression by Matt Godbolt) next, I had a talk to do myself. I managed to diffuse my way out of a paper bag, while reminding us why C’s rand is terrible, how useful property based testing can be, using some very simple mathematics: adding up and multiplying. This was based on a chapter of my book, and you can download the source code from that page if you want, even if you don’t buy the book [20]. I used the SFML to draw the diffusing green blobs. Sorry for not putting up a list of resources near the end.

I attempted to go to Guy Davidson’s ‘Linear algebra’ talk next, but the room was packed and I was a bit late. I heard great things about this. In particular, how important it is to design a good interface if you are making libraries.

My final choice was Clare Macrae’s ‘Quickly testing legacy code’ [21]. This was my unexpected hidden gem of the conference. She talked about approval testing [22]. This compares a generated file to a gold standard file and bolts straight into googletest or Catch. It’s available for several other languages. It generates the file on your first run, allowing you to get almost anything, provided it writes out a file you can compare, under test. Which then means you can start writing unit tests, if you need to change the code a bit. Changing legacy code to get it under test, without a safety hardness is dangerous. This keeps you safer. Her world involves Qt and chemical molecules visualisations. These can be saved as pngs, so she can check she hasn’t broken anything. She showed how you can bolt in custom comparators, so it doesn’t complain about different generated dates and does a closer than the human eye could notice RGB difference. Her code samples from the talk are available [23]. I’ve not seen this as a formal framework before. Her slides were really clear and she explained what she was up to step by step. Subsequently twitter has been talking about this a fair bit, including adding support for Python3.

Matt ‘Compiler Explorer’ Godbolt gave the closing keynote. Apparently, the first person Phil Nash has met whose first conference talk was a keynote. He also had some AV issues (Figure 3).

Figure 3

If you’ve not encountered the compiler explorer before, try it out [17]. You can chose which compiler you want to point your C++ code at and see what it generates. You need a little knowledge of the ‘poetry’ it generates. More lines doesn’t mean slower code. His tl;dr; message was many people spread rumours about what’s slow, for example virtual functions. Look and see what your compiler actually does, rather than stating things that were true years ago. Speculative de-virtualization is a thing. Your compiler might decide you only really have one likely virtual function you’ll call so checks the address and does not then have the ‘overhead’ it used to years ago. He also demonstrated what happened to various bit counting algos – most got immediately squashed down to one instruction, no matter how clever they looked. How many times have you been asked to count bits at interview. Spin up Godbolt and explore.This really shows you need to keep up to date with your knowledge. Something that was true ten years ago may not longer hold with new compiler versions. Measure, explore, think.

There was a lovely supportive atmosphere and a variety of speakers. People were brave enough to ask questions, and only a few people were showing off they thought they knew something the speaker didn’t.

Thanks to Phil for arranging this conference.

References

[1] Arne Mertz (2018) ‘ACCUConf 2018 Trip Report’, published on Simplify C++ on 25 April 2018: https://arne-mertz.de/2018/04/accuconf-2018-trip-report/

[2] C++ On Sea: https://cpponsea.uk/

[3] #include <C++>: https://www.includecpp.org/

[4] C++ On Sea 2019 floorplan: https://cpponsea.uk/rooms/

[5] C++ On Sea 2019 schedule: https://cpponsea.uk/schedule/

[6] Kate Gregory (2019) ‘Oh The Humanity!’, presented at C++ On Sea 2019: https://www.youtube.com/watch?v=SzoquBerhUc

[7] Juan Pedro Bolivar Puente (2019) ‘Postmodern Immutable Data Structures’, presented at C++ On Sea 2019: https://www.youtube.com/watch?v=y_m0ce1rzRI

[8] Adi Shavit (2019) ‘What I Talk About When I Talk About Cross Platform Development’, presented at C++ On Sea 2019: https://www.youtube.com/watch?v=dU3IgHrAmFA

[9] Patricia Aas (2019) ‘Deconstructing Privilege’, presented at C++ On Sea 2019: https://www.youtube.com/watch?v=ZYvyO27uMCU

[10] Björn Fahller (2019) ‘Programming with Contracts in C++20’, presented at C++ On Sea 2019: https://www.youtube.com/watch?v=Dzk1frUXq10

[11] Arne Mertz (2019) ‘Learning and Teaching Modern C++: Challenges and Resources’, presented at C++ On Sea 2019: https://www.youtube.com/watch?v=fKCwDg0vd18

[12] John Shearer (2019) ‘Sailing from 4 to 7 Cs’, presented at C++ On Sea 2019: https://www.youtube.com/watch?v=1Eh-uEzpikw

[13] Arne Mertz (2016) ‘The ‘4C’ Dev Environment’, published on Simplify C++ on 10 August 2016: https://arne-mertz.de/2016/08/the-4c-development-environment/

[14] Matt Godbolt (2019) ‘What Everyone Should Know About How Amazing Compliers Are’, presented at C++ On Sea 2019: https://www.youtube.com/watch?v=w0sz5WbS5AM

[15] Presentations from C++ On Sea 2019: https://www.youtube.com/channel/UCAczr0j6ZuiVaiGFZ4qxApw/videos

[16] Start Learning C++: https://www.cpplondonuni.com/

[17] Godbolt compiler explorer: https://godbolt.org/

[18] Barney Dellar (2019) ‘Strong Types in C++’, presented at C++ On Sea 2019: https://docs.google.com/presentation/d/17WRh90KWWqobRX1miUFCnRwaJJXxqvlcu-t3DvFVHOA/edit#slide=id.p

[19] Nicolai Josuttis (2017) C++17: The Complete Guide, available from http://www.cppstd17.com/

[20] Frances Buontempo (2019) Genetic Algorithms and Machine Learning for Programmers, available from https://pragprog.com/book/fbmach/genetic-algorithms-and-machine-learning-for-programmers

[21] Clare Macrae (2019) ‘Quickly Testing Legacy Code’, presented at C++ On Sea 2019: https://www.slideshare.net/ClareMacrae/quickly-testing-legacy-code

[22] Approval testing: https://github.com/approvals

[23] Clare Macrae (2019), code samples from ‘Quickly Testing Legacy Code’, presented at C++ On Sea 2019: https://github.com/claremacrae/cpponsea2019

Arne Mertz Arne Mertz is a C++ programmer living in Hamburg. He runs a blog called ‘Simplify C++’ at https://arne-mertz.de/.

Frances Buontempo Frances has a BA in Maths + Philosophy, an MSc in Pure Maths and a PhD technically in Chemical Engineering, but mainly programming and learning about AI and data mining. She learnt to program by reading the manual for her Dad’s BBC model B machine.

Notes: 

More fields may be available via dynamicdata ..