đź”— Week 1: core guidelines
đź”— Pre-Class Learning Material
- CppCon 2017: Kate Gregory “10 Core Guidelines You Need to Start Using Now”
- C++ Code Smells - Jason Turner - code::dive 2019
- watch the first twelve minutes to get the gist
- C++ Core Guidelines
- there’s a lot of text in the core guidelines
- try to browse through the interfaces subsection, focusing on “Reason” and “Example” for each guideline
đź”— Conversation Starters/Discussion Questions
- Which is more intuitive or easier to pick up: patterns or antipatterns? is it important to be familiar with both?
- With so many guidelines/best practices, what are effective strategies to try to familiarize yourself with them? To what extent is it necessary to learn by doing?
- Are guidelines that aren’t concrete enough to be automatically refereed practical?
- To what extent should we/is it effective to argue “because the guidelines say so” about a coding decision (instead of a deeper reason)?
- What guidelines or terminology were most difficult to understand or most unfamiliar?
- Do you disagree with any of the guidelines mentioned?
đź”— Week 2: smart pointers
đź”— Pre-Class Learning Material
- CppCon 2015: Herb Sutter “Writing Good C++14… By Default”
- pointer lifetime issues (the relevant part starts at 24:30)
- CppCon 2016: Herb Sutter “Leak-Freedom in C++… By Default.”
- memory management
I would recommend watching both as they are related. Obviously, come with things you don’t fully understand or want more clarification on, but also it would be fun to discuss things y’all disagree with.
đź”— Week 3: STL algorithms
đź”— Pre-Class Learning Material
- CppCon 2018: Jonathan Boccara “105 STL Algorithms in Less Than an Hour”
- GoingNative 2013: Sean Parent “C++ Seasoning” (first 33 minutes)
đź”— Conversation Starters/Discussion Questions
- Which of the algorithms did you learn about for the first time that you found useful/surprising?
- Can you bring a sample of your favorite STL algorithm usage, something you find either beautiful or really helpful?
đź”— Week 4: C++ Secrets
đź”— Pre-Class Learning Material
- CppCon 2019: Miro Knejp “Non-conforming C++: the Secrets the Committee Is Hiding From You”
- CppCon 2019: Timur Doumler “C++20: The small things” (watch first 8 minutes, although the rest is encouraged & we will likely return to this topic in future weeks)
đź”— Conversation Starters/Discussion Questions
- Would you use any of these non-conforming secrets in your own code? If so, which ones?
- What do you think of the committee’s choices in choosing simplicity over flexibility/C compatibility in standardizing designated initializers? How does the wide presence of non-standard extensions in compilers affect the rationale behind this decision?
đź”— Week 5: Parallelism
đź”— Pre-Class Learning Material
If, after watching that, you think “my god how do I get in on these c++ 17 parallel algorithms”, have no fear…
- CppCon 2016: Bryce Adelstein Lelbach “The C++17 Parallel Algorithms Library and Beyond” (optional)
đź”— Conversation Starters/Discussion Questions
- Why are parallel max, min, and inner product hard? Can they run with linear speedups in terms of cpus/gpus?
- How can we use caching and spacial locality to improve parallel algorithms?
- How important is legibility versus speed for industry code?
- How much should you optimize code for a certain platform, given that such optimizations would cause performance decreases on other platforms?
đź”— Week 6: Concepts
đź”— Pre-Class Learning Material
This is the video to watch. Explains what concepts are, why we want them, and how we’ll use them.
- CppCon 2018: Andrew Sutton “Concepts in 60: Everything you need to know and nothing you don’t”
Less important (but nice nevertheless), which follows my initial thoughts on concepts. The Haskell typeclasses Grimm mentions are described at .
đź”— Week 7: Compiler Optimizations
đź”— Pre-Class Learning Material
The first video is a broad discussion of things the compiler tries to optimize automatically and ways to write code utilizing this.
The second gives specific examples of some compiler switches and what they do.
(Just the portion from 7:00 - 33:00. The rest of the video shows some interesting benchmarking examples, but isn’t necessary to get the general idea of the talk.)
Found the following in perusing through some compiler optimization settings, thought it might also be helpful. By godbolt no less.
đź”— Week 9: Design Patterns
đź”— Pre-Class Learning Material
I also highly recommend watching the Godbolt talk that Nitash sent on Friday since it will allow us to expand on our discussion, but it’s not required.
đź”— Conversation Starters/Discussion Questions
- Are there any variations on design patterns that you regularly use that are unique to C++ features/perks?
- Which C++20 features could open the door to new variations on existing design patterns?
- What are some strategies to deal with performance trade-offs when considering different design paradigms?
đź”— Week 10: Ranges
đź”— Pre-Class Learning Material
A more graphical look at the views available in C++20. Feel free to skip the first 20 minutes.
Treasure trove of range examples: range_by_example. (Thanks @wfpunch!)
Range exercises put together by @cgnitash.
đź”— Conversation Starters/Discussion Questions
- Can you think of an interesting application of composing views? Something with polynomials, prime numbers, images, or anything else?
- Have you ever used lazy evaluation? Do you know of any cases where lazy evaluation can significantly hurt performance? This is one of the first times I’ve seen lazy evaluation in C++; do you know of any other places (libraries or the language) where things are lazy?
- How do you feel about the function call syntax that was shown as an example in the second video? Does this style remind you of any other programming language? How would you like to program in a language where every function began with a return statement?
- Have you ever seen the
type_name()
function shown in the first video? For you template metaprogrammers, do you think it would be useful when debugging your template code?
đź”— Week 11: Template Metaprogramming
đź”— Pre-Class Learning Material
After watching waaay too many talks on template metaprogramming, I think this one is a good choice to start some good discussion:
- CppCon 2015: Fedor Pikus “C++ Metaprogramming: Journey from simple to insanity and back”
- quick-bench reproduction of the Pow profiling result reported in the talk: O1 and O3
Nitash has some good suggestions below. What I really came out of this understanding is just how hard modern C++ compilers have been working to simplify and eliminate the need for meta programming. One big help is fold expressions. Let’s also watch this short (<8 minute) summary of them:
optional extra material…
For those of you who want something more (NOT required!) here is Herb Sutter talking about how to replace template meta programming with more sensible alternatives:
A brief, example-driven primer on using SFINAE to test for the presence of a member function in a struct contributed by @cgnitash. (Find the example code all spliced together on Compiler Explorer here).
Also, reccomended by @cgnitash: CppCon 2014: Walter E. Brown “Modern Template Metaprogramming: A Compendium, Part I”.
đź”— In-Class Material
- Godbolt link with template metaprogramming live coding from class
đź”— Week 12: Topic TBD
đź”— Pre-Class Learning Material
A good overview of C++ modules. It’s a bit on the long side, but covers a lot of ground and is the most clear and well organized out of the module talks I was able to find.
Extra if interested… Also a good talk, but more narrowly focused on building/compiling modules.
đź”— Conversation Starters/Discussion Questions
- benefits of modules
- problems with switching over to modules
- anything you didn’t understand about modules (in the video or otherwise)
- bigger picture impact
- how does this change c++?
- …how we write/think about c++?
đź”— Week 13: Move Semantics
đź”— Pre-Class Learning Material
- CppCon 2019: Klaus Iglberger “Back to Basics: Move Semantics (part 1 of 2)”
- covers r- and l-value references, move constructor and assignment operator
- CppCon 2019: Klaus Iglberger “Back to Basics: Move Semantics (part 2 of 2)”
- reccomended: first half hour (discusses forwarding references)
- optional: second half hour, which has some tricky exercises
- these might be fun to talk through in class (feel free to watch ahead of time!)
These talks were part of a “Back to Basics” series at CppCon 2019, many of which I have enjoyed. It’s worth searching CppCon 2019 Back to Basics up on YouTube and perusing them!
đź”— Conversation Starters/Discussion Questions
- What (????) does this code snippet even do?
(I checked, it compiles.)
std::string s{"hi"}; s + s = s;
- What are the plusses and minuses of using
... , pi( std::move(w.pi) ) { w.pi = nullptr } ...
versus
... ,pi( std::exchange(w.pi, nullptr))
- Why is it important to make move constructors and move assignment operators noexcept?
- What is
std::swap
and how does it relate to moving? - What is the point of a function with a const return object (e.g.,
const Widget getWidget();
)? When (if ever) would this be useful? - Do you have any obervations/comments or questions about the giant “Paramater Conventions” table at 53:43?
đź”— Week 14: Polymorphism & Object-Oriented Programming
đź”— Pre-Class Learning Material
- CppCon 2019: Jon Kalb “Back to Basics: Object-Oriented Programming”
- start at 4:42, watch until 28:30
- introduces object-oriented programming, discusses some design best practices
- rest of the talk discusses implementation best practices (reccommended!)
- Better Code: Runtime Polymorphism - Sean Parent
- start at 1:48, watch until 38:21
- discusses a solution for runtime polymorphism without an inheritance-based API
- middle part goes on a bit of a tangent about copy constructors and saving copies before presenting the complete solution, feel free to fast foward that part
- rest of the talk adds real-world context and discusses some additional features made straightforward to implement by using the runtime-concept idiom (reccomended!)
đź”— Conversation Starters/Discussion Questions
- What are the best examples of object-oriented or runtime-polymorphic you’ve used, maintained, and/or implemented? What made them great to work with?
- What are the worst examples of object-oriented or runtime-polymorphic you’ve used, maintained, and/or implemented? What made them not so great to work with?
- How do C++’s polymorphism toolkit/idioms compare to approaches to polymorphism in other languages (Rust? Python? etc.)?
- From the Sean Parent YouTube comments… (WON YOO)
I see global draw() function can be specifically defined with different types if I want to have a different behavior in the function other than a template function defines. Wouldn’t this pattern cause developers less convenient to find what methods can be overridden or not unlike the traditional polymorphism? For example, in traditional inheritance, if a method is virtual, I can know that can be overridden.
- Also from the Sean Parent YouTube comments… (Rob Inson)
How is it different from the pimpl idiom? …
đź”— Week 15: Topic TBD
đź”— Pre-Class Learning Material
TODO
đź”— Conversation Starters/Discussion Questions
- TODO
- TODO
- TODO
- TODO
- TODO