Structural Concepts, ISO Papers, Games in C++ and more!

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

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

July Mailing

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

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.

Become a patron to

271
Unlock 271 exclusive posts
Be part of the community
Get discounts to an online store
Connect via private message