Tuesday, February 19, 2019

C++ On Sea Trip Report! - Day 1


Earlier this month I went to the C++ On Sea conference, sponsored by my company, King. It was the first of it's kind organised by Phil Nash, organiser of London C++ Meetups, and it was really great! 


There were a number of famous C++ speakers such as Jason Turner, Kate Gregory and Matt Godbolt, to only name a few! 


The only thing that was unfortunate was the weather and since the venue was a lovely old 19th Century theatre, the rooms did not warm up much and kept us on our toes 😅 The venue, Leas Cliff Hall, is in Folkestone, where the channel tunnel is also located, so it was a convenient location for those travelling from Europe and would have been lovely if it was sunny!




The conference was 2 days long and there were workshops on the third day. I attended the 2 day conference and the Meet the Speakers Gala Dinner at the end of the first day. This was a really nice occasion to speak to other attendees so you have some familiar faces at the conference the next day 😄 , but also to have the opportunity to speak to the speakers of the conference, get to know them, ask them specific questions about something you've been wanting to ask! I had the opportunity to sit next to Nicolai Josuttis, who is the author of many C++ books, including 'The C++ Standard Library', 'C++ Templates', and he is currently writing 'C++17 - The Complete Guide', which he gave a free electronic copy of to all attendees of the conference! You can find the e-book here

Below, I'll cover each of the talks I went to briefly and give my two cents. 

Key:
Overall quality of content and delivery: ⭐ - 
How code heavy the talks are: 🍟 (snack-able), 🍟🍟(decent portion), 🍟🍟🍟(overload)

Day 1

Keynote: Oh The Humanity ⭐⭐⭐⭐⭐ 🍟

Kate Gregory - author, speaker, mentor, project leader

In this excellent talk, Kate opened our eyes to the fact that there are emotions in code!  Say what? Well, not in the sense that the programs are becoming sentient and will take over the world! She was talking about how the programmer's emotions are reflected into the code that we write. These emotions are often:
  • Fear - eg. "Maybe I'll need this code later so I'll just comment it out."
  • Arrogance - eg "I know what these variables mean and what this method does, so why should I name it properly? If other people can't understand it by reading the code, then that's their problem."
  • Selfishness - eg. "Why should I spend my time making things easy for others?"
  • Laziness - eg "Whatever, it works."
But these emotions be replaced by positive emotions with a little care from ourselves:
  • Confidence
  • Humility
  • Generosity
  • Caring
She emphasised how we are all human - not robots, and it's ok to have emotions. It's ok to show emotion and we shouldn't try to be like Mr. Spock because it's good to have emotions! We should share the positive emotions with each other - through code - to make the world (and the code base) a better place! 😆

Postmodern immutable data structures ⭐⭐⭐🍟🍟

Juan Pedro Bolivar Puente - consultant engineer, focus on interactive software, functional programming and open source strategy

This talk was about the benefits of having immutable data structures and how to use his library for persistent and immutable data structures to achieve a stricter yet more elegant software architecture. He was describing how copying of data is a common problem we have in C++, and the cause is because we pass objects by value. However, the root cause is the mutability of the object. 


He introduced us to the Uni-directional Data Flow architecture, which is common in front end languages such as React, and explained how this Action-Model-View architecture can be used instead of the traditional Model View Controller architecture, where you end up having a reference or a listener everywhere and can become messy. 


He gave a detailed example of how you can use his library, Immer, to implement the 'undo' feature in a text editor he wrote using it, Ewig, and how performant this architecture allows it to be. It was quite impressive because even when copy-pasting/undoing large amounts of text (I think it was like 2GB), it was almost instantaneous and it wasn't freezing up the editor like you would expect it to. 


Unfortunately, there were some technical difficulties with the slides and the talk didn't run smoothly, which is perhaps why I couldn't appreciate the content as much but I believe he gave a similar talk at CppCon 2017, where I believe the delivery was better and you could actually see the code on the screen 😅 Although I think his demo had more updates since the one from 2017.


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



Fast and Small - What are the Costs of Language Features ⭐⭐⭐⭐⭐🍟🍟

By Andreas Fertig - lecturer, trainer, focus on practical and theoretical knowledge of C++ at various operating systems. Creator of cppinsights.io

In this talk, Andreas Fertig gave examples, using Cpp Insights, of the seemingly harmless mistakes you can make that may result in unwanted behaviour and bugs. Therefore the importance of following good practices. 


Recommendations from the talk:


  • Use auto& and auto* for consistency
  • Default to using const auto& BUT use auto&& when writing generic code/abstraction/templates
  • Beware of decltype auto brackets:
    • decltype (auto) b = foo; <=copy
    • decltype (auto) d = (foo); <=reference!
  • Incrementing variables
  • If you ever see this, remove the brackets because it's an old C-style return statement
    • return (x);
  • auto can optimise better than when you know your type
  • Beware of lambdas - the compiler is actually creating an anonymous class
  • Watch the Jason Turner Cpp Weekly Stateful Lambda episode 
  • Static variables are initialised the first time the program passes the declaration and this is controlled by a boolean flag to say whether it has already been initialised. It is not thread safe pre-C++11. Post-C++11, there is a mutex to control thread safety.


Practical Performance Practices Revisited ⭐⭐⭐⭐⭐🍟🍟

By Jason Turner - regular conference speaker, developer, and trainer. Host of YouTube channel C++ Weekly and co-host of CppCast. Author of ChaisScript.



In this talk, Jason Tuner gave a talk in 2016, where he gave  recommendations on best practices using examples from when he was trying to improve the performance of his ChaiScript. This talk was him giving an update on those best practices, now that there is new functionality and new best practices for C++17. His talks are always fast paced and very interactive make sure you are fully awake and paying attention otherwise you'll be left behind! 
  • std::array in C++17 is very optimised and even better than vector. Always prefer to use std::array over std::vector over std::list, map, etc
  • constexpr All The Things! 
  • Use IIFE - Immediately Invoked Function Expression
  • Reduce the amount of branching in your code!
  • Don't add virtual destructors if you don't need it because it disables the move constructor
    • this can be up to 10% less efficient
  • Don't declare variables until you need it, but don't declare at all if you don't need it! 
  • std::endl flushes so use \n 
  • Try not to use: 
    • shared_ptr
    • std::map
    • std::deque
  • Smaller code is better because if it can fit into the CPU cache, it'll be faster!
(no youtube link yet!)

Keynote: Deconstructing Privilege ⭐⭐⭐⭐⭐

By Patricia Aas - programmer, founder of TurtleSec consultancy. Member of #include organization hoping to improve diversity and inclusion in the C++ community.

This ending keynote did not have any code references but was by a C++ developer to a C++ audience and it was very powerful. 
Aas talked about how 'Privilege' is not having experienced a specific hardship. As part of a diverse community, she really opened my eyes to some of the hardships that I had never thought about. 
https://www.youtube.com/watch?v=ZYvyO27uMCU

Day 2 blog coming soon...  Slides for the talks are available here and video recordings on the official Youtube channel.

No comments:

Post a Comment