Welcome to the 30th edition of the C++ Stories Newsletter!
Summer and holiday time work against my content schedule... so for example there was no blog post on Monday at C++ Stories.
Here's the plan for today's email:
- Top C++ News
- Quick Links
- Reminders
⏰ Reminders
- Ongoing Patreon survey: https://forms.gle/n8zTntWmdE4fg7Rt9
- Here's the list of all additional content available for you (depending on the tier): https://www.cppstories.com/p/extra-patreon-content/
- Join our Discord Server, and let's discuss various (non)programming things :) https://www.patreon.com/settings/apps
1. STLab with Sean Parent and Dave Abrahams
https://cppcast.com/adobe-software-tech-lab/
Sean Parent and Dave Abrahams in the 310th episode of C++ Cast!
Notes
- They speak about Boost Con - Dave is a founding contributor of the Boost C++ Libraries project and the BoostCon/C++Now conference.
- move from C++ to Swift - as Dave is the principal designer of the Swift programming language at Apple.
- how C++ compares to Swift - generally familiar, but strong on the value semantics, with default right (immutable by default)
- restarting STLab - improve software practice - focusing on the code, not much on processes. Like many other companies, Adobe struggled with good concurrency - how to deal with this, what are good patterns, how to utilize resources, and have stable code. And they decided to restart the Lab to research those questions.
- Hopefully, we'll get a book from Sean Parent
- How to move forward from real code (30 mln LOC, 30 years old) and still add some good concurrency practice. "Please stop with singletons" - but how to deal with them in a practical way?
It's a an excellent interview with two super experienced legends of C++ software developments. It's great to have a chance to learn their stories a bit.
🔍 A Quick Question
How to get current value from std::variant?
2. ISO Mailing from July
Some interesting papers:
- P1206R4 - Conversions from ranges to containers - missing parts for Ranges where you can convert your range to another container.
- P2392R1 - Pattern matching using "is" and "as" by Herb Sutter
- P2409R0 - Requirements for Usage of C++ Modules at Bloomberg - this proposal is handy for the Tooling group that gathers reports on real-life usage of C++. This may help with the proper support for Modules in the future.
- P2411R0 - Thoughts on pattern matching by Bjarne Stroustrup
- P2412R0 - Minimal module support for the standard library Bjarne Stroustrup - the main idea is to ship import std into C++23 so that the experience with modules is nice and consistent. And then, if time allows, discuss the granularity and details of smaller modules like std.regex, std.concurrency, etc, etc...
3. C++20 concepts are structural - what's that?
C++20 concepts are often compared to Rust traits, Haskell’s type classes, Swift’s protocols. But as the author - Jonathan Muller - explains C++ version is different as they are checked against the "structure" of a type.
type classes, traits, and protocols all use nominal typing: a type models the concept only if the user has written a declaration to indicate it.
In other words, you have to explicitly say that a given type conforms with some concept/protocol in those other languages. But in C++, there's no need for that.
What are the pros of nominal?
- Structural concepts do not allow for semantic differences between concepts, but nominal ones do. For example, std::relation and strict_weak_order - are both the same.
- Names matter - “If it looks like a duck, quacks like a duck, it's a duck!”
But there's one big issue: nominal concepts won't work with legacy/existing code, so that would be a nightmare for C++!
See a new detailed blog post by Jonathan Muller: C++20 concepts are structural: What, why, and how to change it?
In the second part of the article Jonathan also shows how to "emulate" nominal concepts - for example, by adding extra syntax like a dummy typedef that distinguishes between otherwise identical concepts.
🌐Quick Links
- Retiring boost from my codebase : cpp - it looks like we have lots of replacements for libraries in Boost. We can also use larger and larger Standard Library.
- Edit Your C++ Code while Debugging with Hot Reload in Visual Studio 2022 | C++ Team Blog - an early version of reloading, based on Edit&Continue. There are many limitations currently (debugger attached), but maybe that feature will be handy in a couple of iterations. There's also a survey you can take to help to develop this feature.
- Upcoming C++ User Group Meetings in August 2021 - see the upcoming events in August.
- Making the Classic Minesweeper Game using C++ and SFML - the code is maybe not so super modern, but it's such a funny video
- 640 Pages in 15 Months – journal.stuffwithstuff.com - "Crafting Interpreters" book is ready, and Robert Nystrom explains his process and how he created this large book. In the free online version (https://craftinginterpreters.com/contents.html), I've seen a lot of straight C code - so it looks like the author picked that language to build the new language and VM.
- Shift-M/47: Bjarne Stroustrup on the future of programming - one-hour video where Bjarne shares his vision for C++ (and also some history and design choices). There's also a part on AI and NoCode techniques. They also stress the existence of Coding Guidelines, which with some language simplifications can make the programming experience and the code quality better.
- C++ Weekly - Ep 283 - Stop Using const_cast! - any attempt to change the const object results in an Undefined Behaviour, and Jason shows various examples (also C-API, POSIX) where that might fail.
See you next week!
Best Regards
Bartek
💡 PS: The answer to the question: there are couple of ways: std::visit, std::get (might throw), std::get_if. Read more in Everything You Need to Know About std::variant from C++17 - C++ Stories.