Sane C++ Live Streams

Subscribe to watch future live streams here:
YouTube Live Stream Channel

Live streams happen on Wednesday at 7pm GMT

Sane C++ is a weekly live stream with Stewart Lynch. Stewart will take you through files in his C++ codebase sharing his experience on how to write performant and maintainable C++.

The live streams will be on Wednesday's at 7pm GMT and will last between 30-60 minutes. Please come and ask questions or make comments in the live chat.

Stewart has over 30 years of experience in programming. He worked for 17 years in the games industry and now works at PureDev Software developing software for other programmers.

10x: Sane C++ Live Stream 10

A detailed look at my Red-Black tree Map class. How to learn the Red-Black tree algorithm. When to use a Map vs. a HashMap. A (very) general overview of the algorithm. Why the Map is O(logN). What is all this red-black stuff about anyway. How the tree is re-balanced. Why to factor out the Red-Black tree from the Map class. A detailed look at the RedBlackTree class in 10x codebase. Packing the red-black pointer into the parent pointer. A look at the general pointer bit packing functions, and why to use the lower bit rather than higher. How to look up item in the tree. Why check less then before equality. A brief look at the Insert and Remove. A brief discussion about recursion and how to convert to non-recursion. Why check functions are important. A look at the growable fixed size allocator used. Examples of where Map is used in the 10x codebase and why it is used. Brief mention of the WStringHashMap class.

10x: Sane C++ Live Stream 9

A detailed look at my HashMap class. Why write your own container classes. Linear array for hash map rather than buckets and the benefits/drawbacks. Why the array needs to be a power of 2 and sparse. How to deal with clashes. Removing of values that have clashed, 3 case examples. Dealing with wrap-around. Benefits and drawbacks of this hash map algorithm. An explanation of KnuthHash, why the multiplier is used and why the shift if so important. Resizing the hash map. A detailed look at the C++ HashMap code. How to monitor collisions. Why I use int's rather then uints. Using an allocator for pairs so that swapping is only swapping pointers.

10x: Sane C++ Live Stream 8

This week I'll be talking about my core library. Why write your own containers. Don't just rewrite stl. Explanation of Array class. Template trick for eliminating allocator pointer when array allocator is templated to void. When you can and can't safely memcpy on an array resize. WeakPtr example of where memcpy breaks. How range based for is implemented. Useful debug info for catching common bugs. MoveTo array function. MoveSwapLast as an efficient way of removing from the middle of an array. The most efficient array grow size. Potential bug using memcmp in array equals operator. Comparrison of Array and ObjArray classes. How to use the Visual Studio .natvis file to show Array class in debugger.

10x: Sane C++ Live Stream 7

Carrying on from the last stream, looking at classes and inheritance. A note on && Rvalue references. Rvalue references causing hidden copies and bad habits. The case for classes without inheritance. Inheritance as a last resort. Problems with deep hierarchies. Entity component systems (ECS). Containment over inheritance. Some examples in the 10x codebase. Interface classes. When to use multiple inheritance, virtual inheritance, private inheritance. Examples of when to use them. Example of inheritance in smart pointer base class. Tuple class implementation with recursive templated inheritance. Virtuals, the cost, calling base virtuals.

10x: Sane C++ Live Stream 6

Compile times in C++, C and "simple C++". A detailed look at classes in C++. When to use them, when not to use them, patterns to avoid. Why use classes at all. Two types of data, class and struct. We don't use classes for perf, and they are often harmful. Getters/setters in simple classes. Data oriented design. Comparison of a class in 10x converted to struct + data. Why classes are like libraries. Why put data at bottom of the class. Why use public/private. Why have one class per file. Serialization and virtuals. Templated serialization. When to change a struct to a class. Private copy constructor trick. GC optimisation, 10X speedup. Declaring sub-classes outside of class.

10x: Sane C++ Live Stream 5

Designated initializers analysis. Why putting complex code into function calls makes debugging more difficult. An observation on range based for loops. An overview of all the C++ features I use and the ones that I don't use, with a brief explanation of why.

10x: Sane C++ Live Stream 4

Making the case for using a simple subset of C++. Brain cycles on language rather than problem. A case for auto? C style enums compared to C++ enum classes. Scope for enums and enum values. Bitwise combining of enum values. Enum operators. Using a macro for quickly declaring operators? Rvalue references and why they are needed. Alternative, MoveTo() function.

10x: Sane C++ Live Stream 3

Simple C++. Why use C++ and not C. ASSERT_CODE() question. Enum class operator question. Lambdas: Why use lambdas, inline code, capturing. Walkthrough of a number of simple examples. How to do the same thing without using lambdas. Comparing with my Function class. Lambdas require auto keyword. When to factor out code into a function. Potential problems with capturing local variables. RenderPrimitive lambda example. Debugging lambdas. Good threading practices and lambdas. Walkthrough of real world examples in the 10x codebase, converting existing code over to lambdas and comparing with and without. Layout and formatting for easy reading of code. Function length and when to factor out. How to write threading code so that it's easy to maintain.

10x: Sane C++ Live Stream 2

Why I never think about C++. Why keeping the language simple is so important. My RISC brain. How my usage of my language has evolved over time. What is good code. Using namespace and why it's ok to use. How good practices all fit together and why you can't look at rules in isolation. Why use 'private' at all. More on 'auto'. Examples of where auto could be ok, and why I still don't use it. Tabs or spaces? A good argument for tabs. How I evolved from C to C++. Comparison of modern C and my C++.

10x: Sane C++ Live Stream 1

This first stream starts with a short introduction to this series. It is recommended that you watch this first before watching the other streams.

We briefly covered a lot of C++ topics in this stream. 'using namespace' statements. Why put constants in unnamed namespaces. The Function template class for storing function pointers. Why not use stl. Layout of functions in a file. Touched on coding conventions. Why not lambdas. ObjArray and POD Array classes. When to use public/private. Smart pointers and when to use them. Should we use auto.