Tuesday, March 5, 2019

C++ On Sea Trip Report! - Day 2

Day 2

Day 2 didn't have an opening Keynote so let's jump right in!

The Hitchhiker's Guide to Faster Builds ⭐⭐⭐⭐🍟

By Viktor Kirilov - author of doctest - "The fastest feature-rich C++98/C++11 single-header testing framework", focus on game and game engine development.

This talk was a thorough list of all the things you could try to make your build time shorter! 
Some highlights:

  • templates and inlining functions is more work for the compiler/linker
  • debug builds take less time to build because compiler does a lot less
  • Remove unused code! 
  • Remove unnecessary includes!
  • Move function definitions out of headers!
  • Pre-compiled headers
  • Unity files (not Unity the game engine)
  • The "Rule of Chiel" - SFINAE is very expensive
  • compiler cache
    • maps a hash of preprocessed source to object files
    • first run (cold cache)
    • successive runs (warm cache)
  • C++20 modules will improve compile times! 
    • exports BMI (Binary Module Interface) produced by MIU (Module Interface Unit)
    • importing these won't recompile them
    • BUT - there won't be huge gains initially as it will take time for people to adopt modules in their code


Diffuse your way out of a paper bag ⭐⭐🍟

By Frances Buontempo - editor of ACCU’s Overload magazine, focus on machine learning, data mining.

This session was mainly using mathematical formulae to influence the animation to create randomness. Frances explained the random formulae and terminology a little, Brownian motion, stochasticmersenne twister, uniform/normal randomness, etc. 


Learning (and teaching) modern C++ - Challenges and Resources ⭐⭐

By Arne Mertz - author of blog "Simplify C++!", focus on modernising old C++

This session went through all the different resources you can use to learn/teach C++ and the pros and cons of each method. 
Modern C++ is a moving target and teaching/learning it can be difficult because the rules are changing every few years!
For example, you can write a book about C++17 features but if you want it to be published at the same time as the official C++ version release, then you will have to write while the language development is not yet finalised and so you could end up publishing incorrect material. On the other hand, if you write the book once the language features are released, then it will only be valid for a shorter amount of time, until the next version of the language comes out. 
I went to this talk hoping to be given an answer to how to effectively learn/teach c++ so I was a little disappointed that the talk was more of a general list of all the material you could use. The conversations that sparked after the talk from different Q&A was quite interesting though, because different people were talking about their experiences of how they managed to learn or teach.


Quickly testing legacy code ⭐⭐⭐🍟

By Clare Macrae - Principal Scientific Software Engineer at Cambridge Crystallographic Data Centre focus on research engineering

Here, the speaker was explaining about a framework she had worked on called Approval Tests which is available in other languages but wasn't, until now, for C++. She talked about how we often get stuck in a horrible loop with legacy code testing like this:



In such dilemmas, you can use a method of testing legacy code called "Golden Master Testing". This is a very high level "test", in that you save the output of your code in a text file and compare the file before and after you make code changes. AKA - "Poor man's integration test". Well the Approval Tests framework enables you to do this quickly with popular C++ testing frameworks gTest or Catch2. 

I actually tried to use the framework during a company hackney to try and test the legacy code I am tackling at work but I couldn't really get my methods to output anything that I could easily save in a text file. Also, the project was so lacking tests that it first took me half a day to build the one test package we already had, and then I didn't really know how to set up the framework to work within our tests. 😕 I think the framework would work better in the example scenarios that she gave, where they had functions that output an image. 



Keynote: What Everyone Should Know About How Amazing Compilers Are ⭐⭐⭐⭐⭐🍟🍟🍟

By Matt Godbolt - creator of Compiler Explorer

This final keynote was given by Matt Godbolt, who created the widely used tool - Compiler Explorer. This talk was a really excellent introduction to reading assembly - which is essential to using his tool and following a lot of online C++ content such as Jason Tuner's C++ Weekly. He started the talk by saying that after the talk, he wants everyone there to be able to understand assembly by the end of the talk and compared it to like reading Shakespearean poetry - "You pretend to like it, you kinda glaze over it and kinda get the gist, and at the end you're like 'That was actually quite good!'" 😂

And you know what? At the end of his talk that is exactly how I felt about reading assembly! 😂😂 So he definitely achieved his goal! 

I don't really want to spoil the talk by trying to explain it all here - he really explains it well. But basically, he went on to explain the basics, then gave examples of how the compiler does an awesome job of optimising your code, so don't try to be clever and do bitwise shift etc. in your code, because your compiler knows better! 
I really really recommend watching this talk! 

https://www.youtube.com/watch?v=w0sz5WbS5AM



And that's it! It was a very good conference and I think the only constructive feedback I had was that the break/lunch times were a bit too long so for those of us who went alone and aren't very good at striking up conversation with strangers, 90minute lunch time was a little too long to try and keep up a conversation haha 😅

But I look forward to going next year! Thanks for reading 😊