CppCast - Teaching and Training Modern C++
Episode Date: February 9, 2024Rainer Grimm joins Timur and Phil. Rainer talks to us about what he has learnt from many years of teaching C++ as a professional trainer, how training has become more accessible now more people are ta...king it online, and his thoughts on modern C++. News The C++ Iceberg "C++20 Concepts applied - Safe bitmasks using scoped enums" - blog post by Andreas Fertig ACCU conference: Early-bird tickets and workshops Links Reddit thread on Episode 375 with Daveed Vandervoorde Rainer's website and blog Rainer at Meeting C++ online, Feb 21st Rainer's "Concurreny in Modern C++" workshop at C++ Online, March 14th
Transcript
Discussion (0)
Episode 376 of CppCast with guest Rainer Grimm, recorded 2nd of February 2024.
This episode is sponsored by Native Instruments, innovative hardware and software that inspires
musicians, creators and DJs.
And Sona, the home of clean code. In this episode, we talk about applying concepts in practice
and about the C++ iceberg.
Then we are joined by Rainer Grimm. Rainer talks to us about teaching modern
C++. Welcome to episode 376 of CppCast, the first podcast for C++ developers by C++ developers.
I'm your host, Timo Dummler, joined by my co-host, Phil Nash.
Phil, how are you doing today?
I'm all right, Timo. How are you doing?
Well, last few episodes, I've been talking about the weather,
and I'm going to continue talking about the weather because every week is something new week is something new so you lived in the uk for too long so so i i am all right but i i have been struggling
with this thing um basically what happens up here in finland right now is that there was a lot of
snow and then it melted and then it froze and then it melted and it froze and now basically everything
is just covered in ice and you can't walk outside at all because you just instantly fall and the locals all have these like shoes with like metal spikes on them
but i just haven't bought these yet so i'm kind of not daring to go outside but other than that
i'm i'm doing great um just kind of yeah doing my stuff working uh nothing nothing really special
going on no trips planned in the immediate future.
Actually, no, that's not true. I'm going to Japan in March.
Oh, yes.
How are you, Phil? What's up with you these days?
Yeah, I don't have so much weather here, but I have been a bit under the weather.
I know.
Nothing serious, just a bit of a cold. But I mention it because my voice is a little bit
croaky today, so I'll try not to do too much
talking if you don't mind but other than that i'm okay all right as long as you can fix the croaky
voice and post i think we're good i'll see what i can do about that okay so at the top of every
episode we'd like to read the piece of feedback and the last episode about reflection with david
it actually generated quite a lot of feedback.
It was not so much about the show as such,
but it was all about the reflection proposal itself that we discussed, P2996.
So it seems like we struck a nerve there.
So that's good to hear.
I'm just going to pick one email by Vincent who says,
thanks for the great episode with David.
I'm excited about reflection,
especially if its first incarnation lands
as soon as C++ 26.
If we can eventually have the same kind of code generation
or alteration possibilities as one can achieve
with C Sharp attributes or Python decorators,
that would be a game changer.
And maybe we could even have a macro-free test framework.
No offense, Phil.
Keep up the good work.
So thanks for the email, Vincent. And so,
Phil, what do you think about a macro-free test framework?
It sounds like a great idea. It already exists. I think we mentioned on a previous episode.
Yeah, I vaguely remember something.
Chris Jusiak's UT framework uses all the C++20 features to achieve that. And even when we talked about my Catch-23 side project
a little while ago, I said, yeah, it's possible.
We could go macro-free.
I'm just not sure if it's still quite the right trade-off yet.
But I'm not sure even if we do get this reflection proposal,
it would even be possible in the way that I would like.
So we'll see.
Sorry for taking your Jake question a little bit too seriously.
All right. So there's actually. Sorry for taking your Jake question a little bit too seriously. All right.
So there's actually one more thing
I want to mention about the last episode
for the sake of completeness.
So the episode generated,
as I said, a lot of discussion.
There's a big thread on Reddit,
among other places.
And on that thread, David,
who was our guest,
actually wrote the following.
I failed to acknowledge
some other important contributors
to the current reflection
effort in that interview, Dan Katz and Faisal Vali. There are others also by intended, but I
intended to mention Dan and Faisal for having specifically contributed content to the paper.
So yeah, I just want to put that info in as a little addition to last episode.
Yeah, so consider that corrected.
All right.
So we'd like to hear your thoughts about the show.
You can always reach out to us on xmaster on LinkedIn
or email us at feedback at tppcast.com.
Joining us today is Rainer Grimm.
Rainer has worked as a software architect,
team lead and instructor since 1999.
In 2002, he created company internal meetings
for further education
and has given training courses since 2002.
In his spare time, he likes to write articles about C++, Python, and Haskell and to speak at conferences.
He publishes weekly on his blog Modernist C++.
Since 2016, he has been an independent instructor giving seminars about Modern C++ and Python.
In the last 10 years, he published several books in various languages about Modern C++.
Rainer is always searching for the best way to teach Modern C++.
Rainer, welcome to the show.
I'm happy to be here. Thanks a lot.
So a little bit of a risk of getting into our interview questions,
but you mentioned Modern C++ a lot in your bio.
In fact, you've really leaned into it, the name of your blog. It Modern C++ a lot in your bio. Yeah.
In fact, you've really leaned into it,
the name of your blog.
It's got it right there in the name.
We hear Modern C++ a lot.
I've got a book on the back shelf behind me
that listeners can't see,
which is actually Modern C++ in the context of C++98.
Alex Andrei's book.
Oh, I have that book there as well.
Right around here.
So it's always a moving target.
I also have it on my right.
I know what you mean.
Right.
Yeah.
But what does modern C++ really mean for you?
Honestly, for me, it's starting with 11.
When you use 11, C++ 11,
and when you want to solve your challenges.
And I would say it ends kind of with 17. C++ 11, when you want to solve your challenges.
And I would say it ends kind of with 17.
And I don't know how we should pronounce what we say about 20.
I even did a tweet about that.
I have no idea.
But essentially, at least 11.
And kind of 17.
So 11, 14, 17.
I think postmodern C++ is being proposed.
Postmodern.
This is one of the titles.
Right.
Okay.
By the way, let me say something very interesting.
You talked about Decorator Python, you know, in the intro.
Yes, that was the email that we received. I wrote in my last 15 years about 120 articles for magazines.
My first one was about decorators in Python.
It's a nice way to do metaprogramming.
Very nice way.
Now I shut my mouth.
All right.
Yeah, don't worry.
We'll get more into your work in just a few minutes.
But we first have a couple of news articles to talk about.
So feel free to comment on any of these.
The first news item for today
is something I saw on the internet,
which I found absolutely hilarious.
So I had to mention it on the show.
It's called the C++ Iceberg,
which is something somebody just posted.
It's a picture of an iceberg with lots of like tag,
how do you call them?
Yeah, sort of a tag cloud.
It's like a tag cloud.
Tag cloud is fine.
Yeah, like a tag cloud,
like clickable, like C++ stuff.
And yeah, at the top are some kind of well-known quirks
of C++, like when you write instead of array,
square bracket zero, you can write zero square bracket array.
Or inline doesn't mean inline, like a lot of things like that.
And then further down, it gets more evil.
There are some kind of rather interesting ones.
There's hello world has a bug, std optional is a monad,
and C++ disproves Fermat's last theorem,
and dozens and dozens more. You can click on all of them
and they take you to different blog posts
or tweets or other things like that.
It's just absolutely hilarious.
I highly recommend you to check it out.
Yeah, I browsed through a few of these
and I have to say, being C++,
I think the whole iceberg
is the tip of the iceberg.
So you can actually go a lot further than this.
But some of them just had some extra interesting things about it, The whole iceberg is the tip of the iceberg. So you can actually go a lot further than this.
But some of them just had some extra interesting things about it.
Like the one about the for loop is broken.
I think that pointed back to a tweet from a couple of years ago from Nico Giacitas.
That's now fixed in C++23.
So that one's a little bit outdated.
Another one was, is it t&&? It's not is not an R-value reference, but out of
context, well, it might be,
it might not be.
Right, yeah, no, this thing is a
gem. Like, apart from t ref ref
not being an R-value reference, there's also
t and and t bit and,
which is kind of
related to that. Yeah.
I also noticed that there was an item
that was linking to this initialization matrix thing
that I did a few years ago.
Ah, okay.
Yeah, there's a lot of stuff going on in that iceberg.
By the way, in our class, I often say,
C++ is the only programming language
in which you can talk one hour about initialization.
And I mentioned your talk.
This is really nice.
That was an interesting experience preparing your talk.
Right.
So check out the C++ Iceberg.
The other news item that I have for today
is a blog post that I found interesting by Andreas Fertig.
It's called C++ 20 Concepts Applied, Safe Bitmasks
Using Scoped Enums.
And so the premise is kind of that you want to have,
you don't want to use like integers where you can,
for a bitmask, because you can do all kinds of stuff there,
like additions or multiplications.
You don't want to do that.
You just want to have this like
and and or operators for a bit mask, right?
So what you do is you take an enum
and then you just define operator pipe for that enum.
And then you get this kind of type safe bit mask.
Now, instead of like the problem with that
is that you have to repeat this implementation
of operator pipe for every enum
that you want to use like that, right? So that's a lot of boilerplate. So instead of doing that,
you can write it once with like an long like an abled if kind of thing and then opt into that with
an const extra bool flag that kind of enables this enable if thing. So this is a trick that Anthony
Williams actually published originally in 2015. And it's
really neat, but it requires the enable if
and it looks absolutely horrible.
So Andreas Fertig shows how to
do this much nicer with concepts in
C++20 and the code really becomes
so much nicer. And then
it becomes even nicer when you use
std to underlying, which is a new feature in
C++23. So I thought
that was a cool example of something that you can do, which is kind new feature in C++ 23. So I thought that was a cool example of something
that you can do, which is kind of cool in
more than C++,
like C++ 11,
but then with C++ 20,
it looks not horrible anymore
and actually really nice and readable.
So I thought that was quite a good
example of that.
But for me, one
small step is missing.
I don't like standalone requires
expressions. I like
named concepts. And this
is the last step which is missing
for me. Make a concept out of
it and use it.
Yeah, that's a good idea.
What I liked about it was it really takes
the iceberg and flips it on its head.
So it starts off with the
the big enable if version at the top and then you've got a much smaller version a bit further
down and then even smaller version still right at the bottom uh plus you know taking modern c++
features dare i say it and making things cleaner and nicer with them so in both senses flips the
iceberg on his head all right so i, Phil, you have one more news item
for us, right?
Yes. So my job to do
the conference ticket roundup
again. And again,
I mentioned last time
C++ Online, I sort of jumped the gun a bit
in the previous episode
talking about the early bird tickets. I sort of did the same
thing with the ACCU tickets as well.
So ACCU early bird tickets,
they have technically been available for a few weeks now,
but just recently they've been,
all of the options are now there.
All the workshops are available,
fully described,
and there's a page telling you what all of the workshops are.
So it's a great way to get world-class training
for a very reasonable price.
The early bird prices do
apply to workshops as well so now is the time to to get those because only birds only going to run
in front of a i think about a week after this is if that i think the 15th of february we are coming
off early bird um and while i'm talking about the c++ online i know we mentioned that last time
i want to mention it again now because that's another way to get really good value workshops.
And one of our workshop instructors is none other than Rainer Grimm, our guest today.
I know it.
I know you do.
So if you like what you hear today, then sign up for Rainer's workshop or one of the others.
All right.
Thanks, Phil.
So with that, we come to our main topic,
which is teaching what on C++.
So Rainer, thank you again so much for joining us today.
So you've been on the show actually two years ago
when Rob and Jason were still running it.
So how have you been these two years?
Like what's new on your side?
What's new on my side?
Of course, COVID is over
and
nothing's changed so far.
Only one small thing,
small, let me say differently.
Due to my illness,
I cannot give on-site
classes. I only give online
classes now.
For me, it's business as usual.
I give one class a year. At Friday is my mentoring
day, meaning today. And this is what happened for me last year. I was at a few very, very nice
conferences. Toronto, CPB North, Tel Aviv, Kronstadt, very nice. This happened essentially.
So you mentioned your illness there.
Is that something you'd like to share more about for those that don't already know?
I have ALS.
I cannot pronounce it.
It's the illness which Stephen Hawking also had.
Yeah.
I have a special, which is, sorry to say,
it's really funny.
I have a special illness and a special form of it. which is, sorry to say, it's really funny.
I have a special illness and a special form of it.
A very rare form, which starts in my thorac,
so in the upper part around my lung,
and goes into the arms.
But what's good is it will stay, when I'm lucky, very long local.
And this is what I hope for. And now I have it around one and a half year. But you see, my speaking is not affected. For many people it starts, which means here,
for others it starts in different places.
But I have a special version of it.
And I only
want to say, sorry, not too much about it.
Once, the best
thing I could do is, after
asking my family, can I go
public with it? And now I can
go public. And
this is, by the way, my second
job now. I want to raise awareness of ALES
because it's heavily underfunded. And this is my goal. What I want to say is the following.
When I don't have to do anything, when I don't have something to implement to build,
I have an issue. And this is what is my overall goal, to raise awareness for this.
I call it in German, only you can understand it, Timur,
Scheisskrankheit.
I would call it fucking disease.
I don't know how to translate it to English.
Yeah, I mean, it really sucks.
But thank you so much for sharing this with us.
That's very generous of you to share that.
Thank you very much.
And is there a link that we can put in the show
notes for people that want to find out more?
When people want to find out more,
they should contact me directly.
Okay. Because we want to talk
about C++ and not
about my illness.
I have no issue with this.
Well, I hope you're going to continue your amazing
work in C++ for many years to come.
Me too, I also hope.
Right.
So last time when you were on the show, you were saying that you were creating a mentoring program, right?
So it was kind of about accompanying and mentoring people kind of for a longer period of time.
You said you wanted to build a community of people helping each other.
So how did that go in the last two years?
I'm still in the process.
I have now, I would say, around 100 participants
mastered my four mentoring programs.
I say four because the fourth will be installed in March this year,
so in one month.
And what should I say?
I'm still in the process of building this community.
And the people who participated are really, really happy when they participated.
Essentially, they started with the first one.
Then they went to a second, a third, and maybe also the fourth one.
I'm a big fan of mentoring.
And I still think this is the future of training
so not training but you know what i mean right so so if i understand it correctly uh training
is if you have a like a lot of people in a room or like online on an online class and mentoring
is like one-on-one is that is that kind the difference? Okay, training, I think you know what it is. It's essentially a
three-day class. You talk
three days about, let's say, C++
20, and then
you cover each feature, which
you have to cover. You have
only time to cover one feature
once because there are time
limitations. Mentoring
is totally different. It is
my idea. Mentoring consists of three parts. Theory,
practice, and mentoring. Theory means essentially... Let me go one step back. My big mentoring consists of 30 weeks.
And in these 30 weeks, I have all the content in 30 parts.
And each week consists of theory, practice, and mentoring.
Now I have it.
Theory means I have the theory explained in around 10 videos.
I explain the theory also showing five examples.
And there are additional posts and training videos.
Practice means you have to do exercises.
I also recorded the solutions to the exercises. I also recorded the solutions to the exercises. And there's an active C++ community
involved in forums, which I moderate. Meaning people can ask the questions in the forums
and I answer them. And then on Friday, there's the mentoring part. Mentoring means on Friday,
there's a Q&A in which I pick up the questions
from the forum or other questions, and I discuss them in the forum. All parts I mentioned are
recorded, meaning when you cannot participate, you can watch the recorded Q&A.
Additionally, I have two recordings. I record two times times or let me put differently two times i give
the q a on friday 9 a.m and no 10 a.m german time and 9 a.m p.m german time why because i have
participants from seattle and sydney you, I have a big time issue to solve.
Yeah.
And this means the essential part is you can take in one feature,
one interesting thing from five different aspects.
And therefore, it is way better than only do it once.
And you can discuss it with others.
You can discuss with other participants.
And you can ask me.
This is it in a nutshell.
Right. So I have one more question.
So two years ago, when you were at CppCast,
you said that it was during the COVID pandemic.
And so you said that all your classes at that point
had gone from on-site to online.
And then you also said that you expect that long-term,
like kind of two-thirds of the classes would remain online.
So you said now that due to your current condition,
you're actually back to like online yourself.
But I wonder whether your prediction has come true.
Is it true that most people want to be trained online now
or has it kind of swung back to on-site?
Do you have any idea?
Yeah, I have an idea, honestly.
I can only do it online.
Therefore, if someone asks me,
I said I can only do it online.
But many people already ask me,
can we do this online?
For example, yesterday, but many people already asked me can we do this online for example yesterday today i got a new class which will participate in austria and they immediately asked me can we do it online
okay i had a few on-site classes and i said i cannot do it can we switch to online? No issue. But I would say at least half of my
people want
to get trained
online. And the main
difference is how far away
it is. Meaning when I'm
outside of Germany, most
people want to have online.
Right. That's interesting.
So Germans prefer on-site
for some reason, but outside of Germany, most people...
No, this is just a question about traveling.
You can travel five hours, but you don't want to travel to Canada for giving us three days class.
Okay, so people are not willing anymore to basically pay for travel costs.
Yeah, of course, they have to pay, which would make this way more expensive.
And I'm not a full-time trainer, but the little bit that I do, I've been seeing the same sort of trend.
So some are still wanting in-person.
But even then, they're often saying, well, we want quite a few different groups to be trained.
Can you come in and do these groups in-person and then do all the rest online?
And then they can put them all in a single bag if you like and in one class hybrid uh what in one so either
all online or all in person we don't because when you do it hybrid this is terrible yeah yeah yeah
we don't do that yeah yeah i see your point it might be worth talking about that actually it
seems obvious to us if we've actually
been doing training, but I still get asked about it and I have to push back and say,
that never works. And then they say, yeah, you're probably right. But yeah, the idea of the hybrid,
anything really, but particularly training, where you have some people remote and some
people in the room. I mean, have you actually tried that yourself, Rainer?
I tried it once, but honestly, you only recognize the on-site people.
The online people are totally ignored.
Yeah, that's been my experience as well.
So I always say no.
Yeah, it's good that you could.
Yeah.
Right.
Okay, Rainer, so we're going to continue the interview with you in a minute,
but now I'd like to read a message from our sponsor for this episode.
Okay.
So this episode is supported by Native Instruments,
guided by their mission to make music creation more inclusive and accessible.
They create innovative hardware and software that inspire and empower musicians,
engineers, and DJs of all genres and levels of experience to express themselves. Want to work on world-class tools for music and audio?
Check out their Career Center at www.native-instruments.com slash careers.
So funnily enough, the last episode that we did, I think I alluded to it at the time,
but we tried out their new plugin, VE i think it's called which is really sort of
dedicated to people that do podcasts or other sort of this sort of scale audio production work where
you just got some people talking because usually i mean i've got a whole set of plugins also from
native instruments that uh they're quite expensive but they do a really good job i've replaced all of
those with vea for the last episode,
just to say how it went.
And I have to say it got pretty close to where I would normally get
with all of the whole array of plugins.
In fact, any deficiencies were probably just purely down to my editing.
So I give that a big thumbs up.
It's a fraction of the cost of those, so I'm not trying to sell it.
But I was actually pretty impressed when I tried it. it so well that's worth yeah worth talking about that sounds cool
well i haven't tried it yet but yeah isotope via came out a few weeks ago i also have a license
now thanks to our friends at isotope i haven't tried it out yet but i will make sure to do so
especially after this uh interesting review so thanks phil um Phil. And we're back here with Rainer.
So one thing I wanted to ask you,
because I haven't really ever experienced
this kind of class about C++,
where you go into all of these different features
for several days.
What is that like?
Is it like a conference talk,
but three days long instead of one hour?
You kind of just show slides and explain stuff? is it more like interactive like are they like practical exercises like what
kind of stuff do your students have to do when when they're in a class like that this depends
on the topic but in general i have a lot of slides for three days I would say around 200. Then I explain the theory.
Most of the time, I do it once more, show an example, provide additional theory about one feature.
Then I have, in an optimal case, an exercise, which I have to do.
And then I have the solution for the exercise.
And so we jump from one feature to the other.
And yeah, this is, so I would say a lot of theory, a lot of explanation.
When it's a good class, a lot of discussions.
This is what makes a lot of fun.
When I have really, really good people and I discuss about things.
This is really fun.
And as I always say, I learn the most.
But this is how our class works.
So features are things like templates, Lambdas?
Let me say, when I talk about 20,
I start with concepts,
then we jump to modules.
I talk about the core language feature,
then I jump to the library.
I start with ranges and what goes on.
And then I come to concurrency, which is not really a concurrency feature.
I start with coroutines.
I talk about the Atomics extensions, semaphore registers, and so on and so on.
That's interesting.
So is it mostly C++20 then that you teach?
Or do some people still want to be taught C++98 or C++11 or like kind of the older standards?
Extremely seldom before 11. Only when you have people which are deeply embedded.
Okay.
And they have a compiler, C++ compiler, which only half supports 11. Or when they have no operating system, bare metal.
This, but really, really seldom.
Okay.
Most of the time I give these three classes.
EISER C++ 20.
Then for the automotive industry and their supplier,
embedded programming with modern C++.
And
the third one,
I call it clean code,
but you can also call it best practices,
which is essentially rules
from the core guidelines.
These are my main classes.
And all of them are three days?
All of them are three days.
Three days, by the way, is enough.
After three days, I'm done and my trainees are done.
Because it's really exhaustive.
Yeah, yeah, yeah.
I imagine after three days of a workshop like that,
your brain has just melted.
Yeah.
And one day, only six hours C++ in total.
But this is enough.
One thing I'm interested in,
so having dabbled with this sort of thing myself,
is when you are teaching language features
and you have exercises to work on,
do you tend to have exercises
that build on previous exercises?
This would be nice.
Sometimes you can do it, but I don't have it.
The problem with exercise, you have two problems.
Either you only show this feature, then the people say,
this is too simple.
Or you have a nice exercise,
and they don't find the feature in the exercise.
This is always a difficult thing and i tend to i try to make the
exercise easy to showcase only this feature right interesting so so speaking of exercises and and
features i think the thing i'm really most curious about is somebody who doesn't do teaching
like what are the parts of c++ that people struggle most with in your classes?
Is there anything, any part of the language
where everybody just falls into,
everybody stumbles upon this
and they just don't get this thing
and don't get that thing?
Are there any particular things
that are just typically hard to learn?
I always think that in general,
the knowledge about templates is too bad.
Templates. Templates in general.
Okay.
People are pretty good when they do object orientation.
They know it from different programming languages.
But in templates, they are really, really bad.
And here I use, by the way, Andrea's Vertex tool.
I show a little bit of a function template.
I make it stepwise more complicated.
And they have to guess what happens on the right.
I use CPP Insights to introduce templates.
And I strongly encourage all to use it, to build your intuition.
Because templates is not complicated. It's only ugly. I strongly encourage all to use it to build your intuition because templates
is not complicated.
It's only Aki.
So CPP insights is this page that kind of you type text and then it kind of
explains what actually goes on and under the hood.
Exactly.
I call it,
you know,
the term,
um,
um,
what is the term for it?
Syntactic sugar. You know, the term syntactic sugar you know the term syntactic sugar
and this is syntactic unsugaring it makes the quote accio i think it's good so i think i've
used it um when i i had a talk a few years ago about like lambdas like lambda idioms and how
lambdas work and i think i was using it quite a lot for that. It shows like the actual closure type that is being generated and stuff.
But I never use it for templates.
Does it like untemplate your code?
Like what does that look like?
Yeah, you see what's happening.
You have your function template.
Then you instance it, for example, for int.
And then you see that you get a fully specialized function template
for int.
And you see, you really see it.
And this is extremely nice.
For example, try out a fault expression.
Try out variadic templates.
You see what's happening
underhood with these three dots,
with this ellipse.
That's cool. I've never used this website properly. I've only
used it for this Lambda stuff.
Definitely need to look into that more.
When you have people
who don't take it so seriously
with types, let them put
their code inside CP Insights.
And you'll see all over the place,
static casts.
Right. Interesting.
It's interesting you do pick on templates
because I remember it was 2016, 2017,
whenever we met for the ISO meeting
in Applesville in Switzerland.
I know.
There was a talk given by Walter Brown
in the evening.
And I believe, I don't want to speak for Walter,
but I believe he had been told that it was actually
for the students at the university.
So he gave a talk just on templates,
starting from the very basics.
But actually the room was just filled with C++ experts
who were there for the standards meeting.
And I was thinking, I wonder how this is going to go down,
trying to teach the
basics of templates to a room full of experts.
And I think everyone I spoke to, at least, and I got the impression most people walked
out of that room thinking, wow, I really learned something there.
So you can teach the basics of templates to a room full of experts and they will still
learn something.
Yeah, this is also my experience.
Yeah.
They say they are perfect in templates
and then I say, let's try it out.
And then I have issues.
Oh, is this argument
converted or
not?
When you have one type parameter, does
this work when you invoke it with an internet
double? And I make
a poll. So many are wrong.
Sounds about right.
So, I mean, on that point going off on a little bit of a tangent
but I'm sure there are people
sitting there listening to this thinking
oh they're talking about training again
you know I don't need
training we never had that here
what would you say to
those people to not
necessarily persuade them that they need to come
and have training with you, but just to open their minds that maybe this is something that
could actually get something of value out of? I think that's often what's missing.
For me, training is not a goal. Training is a process. It's a thing you should do daily.
This does not mean they should go to me or to you.
It means you always
have to read about
the best way to solve something.
Or let me put it differently.
When you don't fix the code
you have written two years before,
you don't need nothing in between.
Right.
You should always try to become better.
And we know it. C++ is a very challenging programming language and this is what i love about there's a reason to learn
yeah i think uh none of us stop learning when it comes to c++ at least and this must be your
must be your mindset you should learn the entire life and you should spare always amount of time for learning
for improving so um i i definitely feel that myself that i keep learning uh even though i've
been doing css for a while sometimes i i learn things that i'm not sure are things i want to know
like sometimes it's one then like how how like a certain like edge case and css actually
works and then i like i was like oh i always thought it works like this and you know i've
been on the css committee now for like what eight years or something and i didn't know this thing and
um then i found out how it actually works and i was like oh god this is so complicated why is it
like this and then it turns out oh it has to. And I was like, oh, God, this is so complicated. Why is it like this? And then it turns out, oh, it has to be like this
because like, usually because of C compatibility.
And so like the latest one was,
what happens when you have a const integer,
const int i equals something.
And then if the something on the right
is a core constant expression,
then you can use this i as if it was a constexpr thing exactly it's a special rule yeah but if if there if there if there isn't
then you can't and then we had to figure out like because i was uh we were working on contracts
a new feature of this 26 so we had to figure out how this new feature works in this in this
circumstance and i had a vague idea how this works but then we had to actually sit down with the standard
and figure out exactly how this works.
And we had this delightful discussion where,
oh, so you have to do this trial evaluation,
which figures out if it's a core constant expression
and then depending on that.
But what happens if during that,
you like some, oh God,
and it's just brain melting,
like how this actually works.
And I was like, I wish I would just wouldn't know this.
Like you don't need this. It's like, just put a, like how this actually works. And I was like, I wish I would just wouldn't know this. Like you don't need this.
It's like, just put a const expert in front of it.
You know, if you, if it's your code and you're done,
you don't have to ever think about this.
So it feels like, like there's a lot of stuff
and stuff that I wish we didn't have to teach.
Or maybe we don't because nobody needs to know.
I don't know.
Like, do you teach the stuff?
Like all of these like legacy things, edge cases, or do you just like, you don't stuff like all of these like legacy things edge cases or do you just like
you don't need to know this this depends on the on the skill level of my participants
sometimes have really good people sometimes not so good then i try to ignore it but my point is
a different one when you give a class some of your participants will find this and ask you this question.
And now you have to search for a solution.
This is typical.
This is the reason why you learn so much when you give a class.
Because each participant gets a feature from a different perspective.
And you have to understand that.
Right. from a different perspective. And you have to understand that.
Right.
I think my own take on the question I just asked,
which sort of goes some way to answering Tim's as well,
is that most of us, even the experts,
maybe even more so the experts,
tend to learn most things not just by sitting down and reading a book or reading the standard from end
to end and waking up as if from the matrix saying i know c++ but you try things and then you page
14 a bit of knowledge and a bit of knowledge and then you get something done and then you move on
to the next thing and then you accumulate this knowledge over time but you don't necessarily
have that sort of end-to-end connection between why all these things are that way. And
I'm not necessarily saying that all training will explain all of those things, but it will give you
a more structured progression through knowledge that will fill in those gaps. So even if you're
covering material that is ultimately familiar to you, you might come away thinking, now I have a
much more well-rounded understanding of why all this hangs together and a better idea of how to use it and that's certainly something that i've i found and
really value right so can i add something yeah absolutely yeah you asked me for the most
complicated thing you know what the most complicated thing in modern c++ is? I'm very curious now. What is it? You know it.
Initialization?
No, coroutines.
Oh, coroutines.
Yeah.
Oh, God, yes.
Oh, God, yes.
I think initialization might be slightly more complicated.
It's funny.
It's funny because
I've sat through, like,
I think a dozen talks
about coroutines,
including Phil's.
And I, it's funny, like at some point,
I think last year I asked on Twitter,
like, hey, what do you want me
to give conference talks about?
Like, I am looking for new topics.
And somebody was saying,
I'm curious about your take on coroutines.
I was like, well, I can't do it
because I just still don't get them.
And like, it's funny because with lambdas, for example,
one thing that really helped me is what you were just saying earlier,
like the sugaring, like as you understand, like the sugaring,
you understand what this actually does, right?
But with coroutines, you know,
I kind of got to a level where I can kind of work with them.
I can kind of like write a simple like promise type
and like have a coroutine that does something.
But then as soon as it gets more complicated,
like I just, I don't know, it's just so unintuitive.
And like I found, somebody said,
oh yeah, yeah, there is actually a blog post by Lewis Baker.
And he tells you what the compiler transform is.
He does the desugaring.
And then I looked at that blog post and my head just exploded.
It's just so much going on there.
I wouldn't know how to teach this because I don't still know how to wrap my head around this myself.
It's really quite hard.
I only try to build an intuition.
I have a few coroutines with a lot of output statements.
And then you observe the workflow of
this coroutine, and then the next
step is to modify it
and guess what it now should do.
So I
tried from the intuition,
I tried to build an intuition
not to explain all the
23 functions you could
override. Right, yes, yes, yes.
But it feels like you need to know a lot about the stuff.
You need to understand a lot of these functions.
Before you can even write the simplest coroutine
that just yields 1, 2, 3, 4, 5,
you already have to write like 100 lines of code
and implement many of these functions that you're talking about.
So the learning curve is just ridiculously steep yeah and this is my funny
my joke do you know the sentence about monads in haskell uh each one who understands monads
writes a paper about it okay the same will happen with coroutines i promise it's already happened
so i i clearly don't understand coroutines yet because
I have not yet done a talk on them
or a blog post or anything. For me, coroutines are
the monads in Hessken. Right.
Well, coroutines are a monad.
Maybe also,
yeah. So that makes
sense. That does not
make sense.
This was a joke.
You keep doing these things like i just but it but it is actually true
you know it always confuses me when you do these jokes okay okay okay it was a joke okay fine
it's good it's funny let's move on all right uh right um so where are we now um oh yes um i wanted to ask you something um so you said uh so one of your
classes about css 20 and uh last time when you were on the show you said that css 20 has so much
stuff in it like coroutines and you know modules and concepts and etc that you can spend the next
10 years basically teaching css 20 without running out of material so since since then, we got C++ 23, which is the next standard.
I wonder if anything in there is relevant at all for what you do,
or nobody cares about C++ 23 because it's too new
or nothing interesting in it.
Do you have any thoughts on that?
Of course.
I think C++ 23 is a great standard.
Not because it's big, but it has a few very interesting features.
For example, I'm really annoyed about modules in 20.
The state of implementation, only Microsoft supports it, kind of.
But in 23, we have a standardized standard library.
And this is a big, big, big, big win.
I'm totally happy about it.
I'm happy that a few of the
missing functions
in ranges come.
Now it's complete.
I'm also really happy
about a really strange feature
which you talked about
deducing this.
Not because of the feature, but of course of the things
you can do afterwards.
The visitor pattern,
overload pattern, this is
unbelievably great.
It's complicated stuff,
so easy. CRTP goes
away. At least see it
are.
I did a talk about this and it's
kind of funny because it
seems like a small and kind of weird feature
but then it just simplifies
so many things.
This is what I totally like about it.
Really a small feature
but the impact is extreme.
Yeah, I guess this is what a good feature
a good new language feature should be like
yeah i think we're used to thinking about features in terms of what they add to the language
and it does add something to the language but it also takes away some of the complexity
if you use it instead of other features of course you still have to support the old stuff for all
eternity so the language will still be complex but but the usage gets simpler. But honestly,
Timo, this is my job.
I should explain how you should do
it now. You should not do
the visitor pattern such as in
the design book. You should use
the overload pattern, which in 23
based on deducing this
and now it's readable.
When I explain
the visitor pattern,
even in Python,
half of the people don't understand it.
At least half of it.
In C++, maybe 80%. Huh, that's cool.
This double dispatch makes them crazy.
I tend to call it the unwelcome visitor pattern.
But with deducing this,
the overload pattern is it's pretty easy
to get. Yeah, yeah.
So like the, it just kind of
deduces the type for you
under the hood and then when it's getting
called, it's already the correct type and
you don't really have to do anything.
Yeah. These are my, I
would say, great features
which just make the
programming language more complete.
Also that we have Sprint or the Sprint line.
Not a big feature, but it makes the language complete.
And the generator.
Ah, good point.
Only one small coroutine.
And the only one which each one can implement by himself.
Does the generator
actually work?
I remember on the committee we had lots of
discussions about like, oh, but this
should be like that, and this should be like that,
and you can't really do this correctly.
There was lots of discussion about
it, which I found weird
because it should be simple, right?
But apparently it's not.
Most of the use cases are simple, but there's some more complex ones around the ages,
like particularly with recursive coroutines, I seem to remember.
That was a big thing that they spent a lot of time solving.
Recursive coroutines?
Is that a thing?
This sounds crazy.
This is one of those things that I wish I just wouldn't know.
Most people have issues with recursion.
Then they have issues with coroutines.
Now it becomes fun.
All right.
So I need to look into coroutines again.
After my previous attempts of understanding them that have failed,
I'm going to make another attempt now that we have the generator.
Okay.
So you mentioned that you're going to do a workshop
at Phil's online conference,
at C++ Online.
Is there any other things like that,
like talks or workshops or conferences
or events that you've planned for this year?
Anything exciting?
Due to my illness, I cannot plan.
But what I will do at least, I will be a guest of Meeting C++ and ask me anything around in three weeks.
And I will see.
I will at least try to give online talks and workshops at conferences.
But yeah, I cannot say too much about my future
all right well i've never been in one of your workshops but i've been in quite a few of your
talks and they were all brilliant so i hope that you get to do many many more of them in the future
thank you very much for that thank you i was not aware of that all right so there's the traditional last question which i
like to ask our guests um so i'm curious about your take on this uh apart from what we discussed
is there anything else in the world of c++ uh going on right now that you find particularly
exciting or interesting honestly i never thought about it but what i think is what I think is, what I like is, what I, no, let me say differently. C++ is more than 40
years old. I would say around 45 years. And it's still in some points or many points, even bleeding
edge. You talked about contracts. We talk about concepts, we talk
about
compile time
reflection.
And this
is, for
me, the
extraordinary
feature of
C++.
Being so
old, but
being still
bleeding edge.
One of the
points on
that C++
iceberg we
talked about
in the news
was that
C++
OX
concepts,
so not the version we have now, but the originally planned version,
are basically like Rust traits.
So I'm still hopeful we'll get those someday.
But yeah, we are.
I mean, they were ahead of their time at the time.
I think Carbon is also getting concepts that are more along those lines.
Yeah.
But of course, carbon is a little bit
younger yes yes but it seems like all of these languages they continue to influence each other
and one thing that i find is uh c++ is still the dominant language in like so many industries like
when i was living in london there were lots of people doing finance high frequency trading
low latency trading it's all c++ and now i moved to um
finland um here there's a very strong video game industry like a lot of the people i see at the
c++ meetup that i'm organizing here are like people from different video game studios it's
all c++ right and so there's so many industries where c++ just is still so dominant, right? And I
think we are getting those
features because a lot of those people
they want to be able to write better
code,
right? So I don't think C++
is going away anywhere anytime soon.
No, no, no.
Despite anybody else, despite some
people saying otherwise, I think
you're pretty safe.
We have no other language
in this domain.
Hardware or embedded related software.
Yes. This is only C++.
What do you want to do?
Aga? No. To less programmer.
C, I guess.
C to less abstraction.
Rust,
you have issues with
certification probably. And there's nothing left. to less abstraction. Rust, you have issues with certification
probably.
And there's nothing left.
Well, that means we're going to continue to have
a job for the foreseeable future, all of us.
I have no issues, yeah.
All right. So, Rainer,
thank you very much again for being our guest today.
I'm very happy. Is there anything else
you want to tell us, for example,
where people can reach you if they want to get in touch?
Of course.
You know my blog.
You know my mentoring page.
Just put it in the Twitter, all the social media I work with.
But just put me on the notes.
We will do, yes.
We are.
All right. Well, thanks again. Thanks for coming on the notes. We will do, yes. We are. All right.
Well, thanks again.
Thanks for coming on the show.
Nice to see you.
Thanks so much for listening in as we chat about C++.
We'd love to hear what you think of the podcast.
Please let us know if we're discussing the stuff you're interested in.
Or if you have a suggestion for a guest or topic, we'd love to hear about that too.
You can email all your thoughts to feedback at cppcast.com. We'd also appreciate it if you can follow CppCast on Twitter or Mastodon.
You can also follow me and Phil individually on Twitter or Mastodon. All those links,
as well as the show notes, can be found on the podcast website at cppcast.com.
The theme music for this episode was provided by podcastthemes.com.