Algorithms + Data Structures = Programs - Episode 74: C++ Education, Cats and More! 🐈⬛
Episode Date: April 22, 2022In this episode, Bryce and Conor interview Patrice Roy about C++ education, cats and more!TwitterADSP: The PodcastConor HoekstraBryce Adelstein LelbachAbout the Guest:Patrice Roy has been playing with... C++, either professionally, for pleasure or (most of the time) both for over 30 years. After a few years doing R&D and working on military flight simulators, he moved on to academics and has been teaching computer science since 1998. Since 2005, he’s been involved more specifically in helping graduate students and professionals from the fields of real-time systems and game programming develop the skills they need to face today’s challenges. The rapid evolution of C++ in recent years has made his job even more enjoyable.He’s been a participating member in the ISO C++ Standards Committee since late 2014 and has been involved with the ISO Programming Language Vulnerabilities since late 2015. He has five kids, and his wife ensures their house is home to a continuously changing number of cats, dogs and other animals.Show NotesDate Recorded: 2022-04-14Date Released: 2022-04-22A Tour of C++ by Bjarne StroustrupProgramming: Principles and Practice Using C++ by Bjarne StroustrupThe C++ Programming Language by Bjarne StroustrupPatrice Roy’s WebsiteZach Laine’s Text LibraryJelly Programming LanguageFORTRAN 77camomilla by Vittorio RomeoIntro Song InfoMiss You by Sarah Jansen https://soundcloud.com/sarahjansenmusicCreative Commons — Attribution 3.0 Unported — CC BY 3.0Free Download / Stream: http://bit.ly/l-miss-youMusic promoted by Audio Library https://youtu.be/iYYxnasvfx8
Transcript
Discussion (0)
I'll say this, you are not the oldest guest we've had on the podcast.
Yeah, you're very sweet. I just turned 50 a few weeks back.
Yeah, you're not even in the top two or three.
Yes. Welcome to ADSP, the podcast, episode 74, recorded on April 14th, 2022.
My name is Connor, and today with my co-host, Bryce, we interview Patrice Roy about C++
education, cats, and more.
You know, it's interesting. I was thinking about this a bit the other day that
I was thinking about the nature of programming books that I think, and maybe this is untrue,
but I'll put out my theory here, which is I know a lot of people who write programming books. I
have a shelf full of books that are written by my friends.
But my impression is that most of them are written with the audience of post-education people, people that have graduated from college that are practicing software engineers or
programmers and who want to continue learning their skills and that they're not written as textbooks.
And I guess my impression is that like in other fields, that tends to be less the case.
It tends to be more that books get written as explicitly as textbooks or as course books.
Maybe I'm wrong about that.
Maybe my perception is off here.
I certainly know that some of the C++ books that I'm familiar with are used as course textbooks, maybe not at the introductory level, but at the higher levels. reminds me of another thing, which is when I was a kid, I would go to conferences all the time with my mother because she's a lawyer and lawyers have to do a certain amount of continuing education
every year to keep up with their certifications, their bar association memberships in the US.
And one of the ways that you can qualify to do that for that continuing education is to go to
a conference and attend some classes there, which is a lot more fun than just like
taking some training courses. So of course that's what we would do. But there's no real certification
or requirement for that in, you know, the programming industry. So it's sort of up to our
own, to each of us to feel motivated to continue learning. Yeah. But if you don't, you're going to get stuck way, way back and you're going to stop following
what's going on in the world.
And the, I don't use books written.
I have probably the same books you have, but I don't use most of them in my classes.
I do suggest chapters from time to time to students.
I write my own material.
If you look for introductory books, there's one from Yarnet that's kind of cool.
The one with the birds on it.
Yeah, Tour of C++.
No, this is cool if you already know how to program.
But the Programming Principles book with the swans on it, it's written for undergrads, so it's kind of accessible.
And what I like about it is that it goes into detail as to why you do that.
How you can do things with the language, what the purpose is,
there are pictures of people like Stepanov and they're like,
these are the artisans, the people that have worked on this.
The language lives through them.
I think for beginners, it's an interesting book.
It's a bit big maybe for a class, but I don't use it.
So the one that portrayed, there's a few different books by bjarne um uh two of the more mainstream
popular ones are uh the swan book one which is uh programming principles and practices using c++
by bjarne the other one which um is one that i is perhaps the most frequently cited introductory C++ book that I know of
is the C++ Programming Language book,
which has a similar cover
in that both covers are blue,
but the C++ Programming Language book
has mountains on it.
I don't know if there's a fifth edition of it now.
The fourth edition was, I think, the C++11.
No, he doesn't want to write one because the language has changed too much.
I don't think it's a good introductory book if you've never programmed before.
It's a good book to get C++ if you learned something else in the past.
Interesting. I know some professors that have used it for
an intro programming course that was taught in C++.
There's some other books that Bjarne has written, like The Design and Evolution of C++.
That's an awesome book. That's really, really, really good.
Yeah. I recently was diving in it to find quotes for something. It is a pretty solid book.
It gives you perspective as to why things are the way they are, why the model is what it is,
and how it differs from other languages.
So even if you don't like C++,
you should read that book
to at least get why the language is what it is.
There's purpose to that.
There's meaning to that.
I passed it along to my colleagues
and everybody loved it.
Even those who don't do C++,
they love the book.
So you said you develop your own course material. Is that
pretty common in
the CS world?
Well, I don't know about the
CS world entirely.
Where I work,
many of us do
that.
Yeah, I'm a bit of a maniac
for that, so I write stuff all the time.
Now, of course, I'm going to put you on the spot.
Is it open source?
Well, if you can read French, a lot of it is on my website.
I have a very big website with awful colors, I know,
but that's on purpose.
It's an ugly-looking site with lots of contents
that people who speak French look at quite a bit.
I used to have a password on the site, an ugly looking site with lots of contents that people who speak French look at quite a bit.
I used to have a password on the site, but it was a hassle because people couldn't reach it through Google. So I removed that. The course material that's in book format is accessible,
but universities, they want to control access a bit. so they're on mobile sites, so it's not as open source as it could be.
If I do a big update of everything at some point, now I don't have the time these days,
I might just publish the stuff in article form on my site to make it available to more
people.
So right now, there's an overlap between the book stuff that I write that's for the
students and the article stuff that I write that's on my site.
In some cases, the site is more up to date. In some cases, the books are more up to date.
But the overall stuff is pretty good, I think. It seems to me like we in the soft world world,
we know how to do open collaboration between different spanning organizations and national boundaries and
everything, it seems like, why doesn't every programming language or every field in CS
have some open source collaborative effort to, educational material for the university level?
That's a very good question. I don't know. There are open classes.
Maybe it's just because schools make money out of that. I don't know.
It can be that simple. No,
why do we sell the standard on ISOs because there's some slight amount of
money to be made out of it, I guess. I want people in my classrooms.
I want to be with people and talk to them.
So I don't want to record my classes
and let people watch them from home using popcorn and beer.
I prefer them to be having popcorn and beer with me or something.
So if I publish everything online,
I'm going to be alone in the classroom.
It's going to be boring.
I have that, yeah.
So do you teach all your classes in French?
No, no, no, no.
The CP North class will be in English,
of course. I'm at the university
classes. Yeah, yeah.
Sometimes I give,
when we have students from
outside of Canada quite a bit,
sometimes they do give bits in English. I answer
English questions in English
to help people along.
But people who come to study with our class,
in our classroom,
they do have to learn French or speak French.
There's a video game graduate class
that we've been offering for 17 years now.
It's a full-time graduate degree
for people who want to come in and participate in game
development. In this class, there's a lot of French from France students, but there's also
Spanish people. There's people from the Eastern, from Eastern Europe, from South America, from the
English speaking world too. And, but the classes are in French. So I can't believe them as much
as I can when they're stuck, but otherwise, well, they're learning and they're doing well. And, but the classes are in French. So I can't believe them as much as I can when they're stuck, but otherwise,
well, they're learning and they're doing well anyway,
they want to work in Montreal. So learning French is important.
So are there any, are there any challenges to teaching
something like C++ in French C++, you know, the, the, the language,
you know,
and the constructs of the language are obviously sort of uh very english centric in nature are there any you know challenges that come out of
that you want the funny ones yes definitely so something like length the t and the h they're
so hard to write for french-speaking people they keep mixing them up
but no way no it's not that difficult.
Most people here in Montreal,
they speak both languages.
So they kind of have the basics of English at least.
Coming from France,
those who come from France,
they do have some basics in English too,
so they kind of get along.
If you ask them to write a paper for you,
it might be unpleasant to read because the syntax would be all wrong but you know it's not nothing that difficult the most
difficult thing is getting people to structure their thought and that's regardless of language
so writing smaller functions more focused classes stop using pointers all over the place when you
don't need them things like that and that has nothing to do with English or French.
Interesting.
Yeah.
You know, it's, it's, it's interesting to think about, you know,
people programming in languages other than English,
because I'm not really aware of any programming languages where the
constructs are not,
or the keywords are not sort of very English-centric.
There are some.
There are some people who make it in French.
It's very, very strange when you look at it,
though I've seen that.
There's APL.
It was more math-oriented.
And there's weird things, yeah.
There's weird things like white space
where everything that you write,
that's not a white space in the company.
Yeah.
But are there any languages where the keywords are
not English keywords? As I said, I know when Dev does that.
I sometimes have people having internships in places
where they use that, but it's kind of...
It's understandable if you think of it, because you want to reach a wider audience.
So if it's C Sharp, the guy who wrote that is Danish, but it's an English language.
And B&R is from the Scandinavian countries too, but your audience is English.
Yeah.
And for a long time in a language like C++, you couldn't have non-ASCII identifiers or
even, you know, there were some compilers that would
reject comments if they were not ASCII.
And if I may, I have so much respect for the SG16 people who are working on Unicode for
C++.
My hat tip to them, they are heroes.
Yeah, when is C++ going to get Unicode?
I need to be able to write my APL compiler in C++. And I tell you, trying to iterate over a string that does not contain UTF-8 or
the 256, it is... You should try Zach Lane's text library,
which I think is part of Boost now. Okay. I'll look into it.
Yeah. So do you know of any languages that have non-English keywords?
I think we asked this question earlier on another podcast and we had a response from someone on Twitter that said, oh, there is actually a language and they linked me to it, but I do not have it top of mind. I'll throw a language out there that doesn't have non-English keywords,
but it has a very interesting character set and it's called Jelly. I'll just leave that
for the listener to go explore. Just Google Jelly programming language.
I've had to use tricks in jobs I've done in the past. In the recent past, that brought me to pre C++98.
And you know, the toolbox,
when you have a full toolbox,
it's very, very useful in those moments.
Yeah, I can't imagine.
I can't imagine, you know, C++11.
That's what I started with because I started working in C++,
or not in C++.
I started working in the year 2014 and we were using C plus plus 11 at that
point.
I don't even think the full feature,
cause we had some visual studio 2000 something that only had like half of
the features still,
they had the auto keyword and lambdas and stuff like that.
And yeah,
I can't imagine having to go back.
And every time you want to call a bull,
you have to build a function object in the form of a struct.
There's so many things that I took for granted
when I started with the language.
And you'd hear about people being like,
oh, you don't know what it was like.
And I'd be like, I don't know.
It seems like a pretty nice language to me.
But then you realize that there were the,
I don't want to call them the dark ages,
but just like the pre C++11 ages.
And so when you mentioned pre C++98,
that's, I can't even, yeah, I can't even imagine.
It was a lot of fun because it was an alien place
where they had to certify the binaries
that they were generating.
So they had to compile stuff in debug mode
to make sure it was the readable binaries.
Then they certified them and it cost so much
that they didn't want to change the compilers
in any way to make sure that the binaries
were as stable as they could. So we were using compilers I had not used in my 23 years of
teaching, older stuff than that. So I had to really pick in my old toolbox. If you took
a problem like doing function composition, f of g of x, and you try to solve the problem
with C++ 98, 11, 14, 17, 20, the evolution of the way you solve that problem
is amazing. It's gotten so simple and so clean and so efficient. It used to be doable, but in such
convoluted ways. There's a number of things we have learned over time and the language is really
helping us. So yeah, we're going to solve problems in many different manners in that class.
And I think it's going to be awesome. Patrick, you haven't always been a professor,
right? I thought you worked on some pretty cool stuff for your professor. Didn't you do
flight simulators or something? Yeah, I did research for Hydro-Quebec,
which is the biggest company in Quebec here.
It's a state-owned thing where we produce electricity.
And since we have a lot of water in Quebec, well, we have a lot of electricity.
And after that, I did a few years of military flight simulator work.
Indeed.
So what do you want to know?
So was that all in C++?
Was that in C++ in the early C++ days?
Okay, so now you want the stories.
When I got there, the reason I got into flight simulators at first was that I had gotten a scholarship for graduate studies.
And I had a baby and another baby was coming along that was not expected. And I looked
at my scholarship and said, oh, we're going to have a problem. Money is not going to be sufficient.
So I applied there because a friend told me, oh, we're looking for people. I went there and they
asked me, do you want to do military work? And I said, no, I don't. And they still hired me and
they offered me a job doing military flight simulators. And I thought about saying no.
And then I looked at the money and said, well, I have no choice.
But I really, really enjoyed it.
I learned a lot of stuff.
It was very instructive.
It was a milestone in my personal development.
It was a very good learning experience.
Now, when I got there,
my boss was a Fortune 77 expert.
And he was, you might not be aware of that,
but Fortune 77, you don't have local variables.
Everything is static.
So if you were trying to write recursive functions, you're going to have a lot of pleasure.
He was scared of using the stack for functions because there seemed to be, in his mind, a cost to the stack pointer being incremented and incremented in code.
So just selling the fact that we had local variables was a fight.
So it was a mixed L4477 and size NCC that we had to do.
Now, I was a C++ aficionado back then already.
With the C++ I knew,
which was much more limited than what I know today.
So I had built a framework of macros to make my C code behave kind of like C++ with initialization and stuff, which generated a lot of code because I tried to be as clean as I could.
And I actually saw an error message when I was there that claimed that the function had
gotten too big through macros and the compiler refused to optimize it.
I'd never seen that before.
There are too many lines
and I refuse to optimize your code.
Go to hell.
Kind of sounded like that.
So yeah, so I did that.
I worked on mostly helicopters that went to R
but also did search and rescue.
I worked on communication channels and I worked on a system that simulated voice messages
within the simulated helicopters.
Voice is interesting because it's a real-time system.
It's hard real-time.
The people in the helicopter, they have to be able to tune into a radio and listen to,
believe it or not, the weather. That's very important for them because they don't see what
they're doing. They're guided mostly because there's always fog and stuff. They want to go
to such and such airport and they want to know what the weather is to actually do their approach
properly and don't kill themselves or anything.
And the executive system that we had there, so it was a layered thing with, see it as a four-level tree. The topmost part was a critical band where things have to be done at every iteration of the system.
And that's life-saving stuff.
And as you go along down the tree, things get less and less critical.
So they might skip turns from time to time.
And I happened with the system to have pieces on each and every level of the system.
So I got the whole experience.
Yeah.
And it was the biggest flight simulator in the world back then.
So by far.
So it was seen as a research project,
but our motto was at CAE, we can.
So we said yes to everything,
regardless of whether it made sense or not.
And I was given 50 hours to take this bit of Fortran code
that worked on a single helicopter
and make it work on a system of helicopters
that behaved as a unit
when sharing a world through many machines. Pure parallel code. It was concurrency and shared
memory and stuff, which of course made no sense. It took three hours to do. So it was three hours,
three years, three years to do instead of 50 hours. It was crazy. And if you want the inside story,
when I saw this, I said, I'm never going to write that in Fortran 77. Makes no sense to me. It's
way too hard. So I asked for budget to rewrite it in C because C++ was out of the question.
It was too scary. And they said, no, we don't have the money. So I went on my own at night,
then I wrote the whole thing in C on my own time.
And I committed it and told nobody for a few weeks.
And when everybody saw that it worked, then I told them.
And everyone was relieved because nobody wanted to do that in Fortran anyway.
But yeah, so that's it.
What year was this?
When was this?
I was there between 1995 and 1998.
Wow.
Those were really the early days of C++ and you were already using it, already familiar
with it.
Wow.
Yeah.
I started using C++ around 1993 or something.
I'm old.
Sorry.
I'll say this.
You are not the oldest guest we've had on the podcast.
You're very sweet.
I just turned 50 a few weeks back.
Yeah, you're not even in the top two or three.
You're very sweet.
To be honest, I would have stayed at CE if I had not gotten a teaching opportunity
but I wanted to do teaching
in the long term and when I got an offer
I said well if I don't
do it right now I might never do it
so let's just do the move it cost me a lot
of money to do that
because I was well paid at CE
so how many kids do you have now
you mentioned two
I can hear some kittens in the background I was really hoping we'd get to see one How many kids do you have now, Patrice? You mentioned two.
I can hear some kittens in the background.
I was really hoping we'd get to see one.
No, they're sleeping right now.
Most of them, I just fed them like 15 minutes ago.
Someone had some cats or something that was going meow.
And I'll keep that in.
I'll keep that in.
Everyone's going to get to hear Connor as a cat.
I do know you have a lot of pets though, Patrice.
There are seven cats at home.
There's one dog, three parrots, a hamster.
The number of cats has gone up to as high as 30 from the beginning.
But we have a shelter.
Okay.
I was about to say, like you basically have a farm or a shelter.
Yeah.
Well, I have a wife who works at the veterinarian's clinic who's an expert in cat and dog nutrition so she works from home mostly and she guides
people who have problems it's a free service and people just call that in or the the scheduled
meeting with her and they have an hour and she listens to what kind of problem they have and she guides them through
their nutritionary needs. We have seven cats of our own. They're all kind of weird, like with
weird paws or weird defects. One of them is missing a tail, whatever. And we take,
in Quebec, most people move around July. There's a tradition where first of July, everyone's moving.
And people tend to abandon their cats around that time, which is very sad.
When we were leaving, our previous house was about 15 minutes drive from where I live now.
And my wife was in the administration. She was managing
kind of a shelter
organization where they rescued cats,
sterilized them, vaccinated them, and
let them go.
When they got pregnant cats,
it was more complicated because you don't want to
sterilize them with the babies in.
We used to take the cats
down, let them
have the babies, and then sterilize everyone
and vaccinate everyone
and find homes for them. So we kept on doing that when we moved. So that's why sometimes we have as
high as 30 cats because there was one time two years ago, three years ago, when we had four
pregnant cat ladies in the span of a month and all of them gave birth to four to six kittens.
So they each had their own room such that they didn't fight. And there were seven little boxes in the span of a month, and all of them gave birth to four to six kittens.
So they each had their own room, so they didn't fight.
And there were seven litter boxes to be twice a day.
So if I understand correctly, then it is likely that you will,
that right before C++ North, you will have additional cats that will end up in the house because everybody's moving in July.
It's absolutely probable.
Yeah, that's the kind of thing that happens.
It's happened less with COVID because people move less.
But yes, we do that.
And then why do we do that?
Because we can.
I mean, my wife is good at this.
We can, when they need special medication or treatment,
we can actually do that.
We can prepare milk and feed them when the ladies cannot do that
with small, I don't know what the English word for that is,
but when you feed babies with bottles,
so we can do that with cats.
They're very tiny bottles.
And when the lady cats cannot do it,
because already they kind of lick the babies to make them pee and stuff.
Well, you need to do it yourself.
You need to put the baby cats on top of the sink or the toilet.
You need to message them properly such as the pee and stuff.
And then you wash your hands, of course. So I do that quite a lot.
How do you put pictures of these cats in your, in your talks?
You have to start if you don't.
I've done that once or twice with a few cats.
My wife has a Facebook account.
She's more of a picture person than I am.
But I haven't done that.
I'm not a big picture person, but I have done talks with pictures of cats.
But I feel it feels weird to me to advertise that during my talks.
But I do talk about them.
And you talked about the kids.
I have five.
There are only two left at home because theirs are all gone.
One of them is going to be a kind of lawyer soon. One of them is a dance instructor. One of them is a literature major. And I have a teenager and a young kid who's still in elementary school.
And you teach it to different schools.
And I have a PhD, which I did along the way. And I used to be a union worker too, because I used to be part of the teacher's union.
Well, one of the executive members.
And I do the work, you know.
What's the secret, Patrice?
Ask Bryce, he never sleeps.
I mean, I do sleep from time to time.
Bryce doesn't sleep, so.
No, I had to take that out of my profile signature
because now I sleep.
My email signature for many years said sleep is for
the weak, but now that I'm an old man,
I go to sleep.
When I feel tired, I go to sleep. I can tell you that.
Since I've seen Michael Wong's resume, I don't feel like I work a lot anymore
because Michael is ridiculously busy.
It makes no sense.
I don't know why he does it.
But yeah, I get up early, I go to bed late, and I try to do a proper job.
So that's what I do.
You know what's the most difficult these days?
There's been a lowering in literacy skills.
So people learning to make meaning out of the text that they read. So in
university, in college these days, what I noticed for less than two or three years, you have to
repeat more what you say because people, they can read out loud the words, but the phrases don't
make the same sense to them as it used to. So the thing I say the most these days is please
reread the directives to make sure you've
got them right. Please mark down what you've done because you probably didn't get it properly.
And sometimes they give me homework back and I have to give back saying, that's not why I asked,
please do it again. And when at some point I sat down with them and I've done that many times in
the last few weeks, I read out loud with them the words and said,
I never saw that paragraph.
It's the first one in the actual text.
But it just came over.
You don't see it.
So my fight these days is make sure you read,
because there's been a lowering during COVID times of reading skills.
Yeah, I was just about to ask.
You said the last one to two years.
Do you think that that's related to the move to online?
Yeah.
Yeah, I'm pretty sure there's an impact
because it didn't used to be there's always problem with people having problems with their
reading skills but to generalize like that inside i saw almost half of the students these days
interesting i used to have to uh at the top of my exams i would write rtq which stood for read
the question and this is not necessarily because I have a low proficiency
in reading. Like I read quite a bit, but especially with math exams, I get very,
very excited because I know I like, I see the structure of the problem in a few numbers and
I just assume, Oh, I know, I know what to do here. And then I'll end up, you know, there's times
where I failed tests because I didn't actually read what it was asking me to do.
And I just sort of very quickly got excited, went ahead and answered.
And then I got back and it would say, you know, 40 percent. And I'd be like, what? What happened?
I like I nailed that. And then I would go back and the commentary from the prof or the teacher would be like, this is not what was requested.
You know, please read more carefully. And yeah, that's, that's sometimes there's this
interesting phenomenon that sometimes people that have a high reading proficiency and who can read
very quickly will have trouble like recognizing an error in a text because they read through it
so quickly that they like, you know, they, they, they just complete their mind,
their head just like corrects whatever the error was in the sentence.
And yeah.
If you allow me, we used to, me and one of my close colleagues,
we used to have this exam.
We passed to first year students like midway through the semester where
there were objective questions.
So you have a choice of answers.
And in one of them, the answer was pseudocode.
But we put pseudopod, P-O-D, instead of code, which is a tentacle as first answer.
And pseudocode was the fourth one.
And the only ones that missed it were the good students because they read too quickly.
So they saw the first word and I used to give them,
I used to draw small squids and hand them over in the class,
the public saying, you got a prize today
because you read too quickly.
So yeah, you only hit the bad ones,
the good students with that.
It's funny, my dad would always joke to me
like when I was in high school and if I did poorly on something,
he'd ask me and I'd say,
ah,
I didn't do that good.
But I mean,
that's just because I didn't read the question correctly or whatever.
And,
you know,
so I knew what I was doing.
I just didn't.
And it went on into university.
And like,
whenever I would talk to him on the phone,
he would just like,
he just sort of chuckle.
Cause like,
it's his joke is like,
oh,
you didn't read the question.
Oh,
surprise, surprise. You know, that you did the only his joke is like, oh, you didn't read the question. Oh, surprise, surprise.
You know, that you did, the only reason you did poorly is not because you didn't prepare.
It's because you don't have time to like do the most important thing, which is to figure
out what the test or the class is asking from you.
At the level where we are, it's reading your messages.
Professionals, they don't read messages well enough.
But they're often
quite talkative.
So when you read
them properly,
you kind of grasp
the gist of what's missing
and work your way through.
So making them learn
to read their messages
is a fight
because after two years
in school,
they still don't do it.
What's super,
super interesting
about that
is a lot of the times
in a production code base,
you'll get some crazy template metaprogramming, 100 lines, everyone's seen it.
And my gut reaction is like, I don't know what this is doing.
And then I'll go to Godbolt.
I'll get some minimal reproducing version of it.
And it'll be the same sort of error.
But now because it's a minimal, you know, reproduce and like,
I know exactly what's happening.
I'll just read it.
And it'll actually tell me like in the midst of all the garbage, like the exact problem,
which the previous error actually also said, I just, I just like, I saw it and my eyes
glazed over and I was like, oh, I'll go fix this and God bolt.
But like, it's like you said, a lot of the times the error messages, like in the midst
of all the angle brackets,
there is actually very specifically what your issue is.
If you had just taken the time to read it, which I rarely do,
I just go to Godbolt.
So there's something there that we always complain about how awful they are,
but a lot of the times in the midst of that awfulness is actually the key to the problem.
We just don't.
You're making a point for writing smaller functions
and smaller meta functions.
If you write small things,
it's so much easier
to find your way around.
You almost don't debug
if you don't do that.
Yeah, that's true.
One thing that I,
I've run into that
a lot too, Connor,
and I do the same thing
where if it's,
if it looks like
it's going to be hard,
I'll just go to Godbolt
to try to reproduce it there.
Especially a lot of the bugs,
because I mostly work
in compilers these days,
a lot of the problems that I run into are bugs that are actually in the compiler.
And so if it's a compiler, if I think it's a compiler bug, my first reaction is to reduce it
down to, you know, the form that a compiler writer wants it in, which is, you know, pure,
like ideally pre-processed source code that's like minim, that has no includes or anything so that it's an
easy test input to reproduce.
But one thing that I've often done with more complex template errors is I'll dump the error
message to a text file, and then that lets me go and do some reformatting of it.
If it's an error message where it's complaining about the second argument,
the template argument in a template that has four or five arguments and maybe one of them is just
a string of nonsense, the default way that most compilers format that is just to give it to you
all as one long line. And so oftentimes, if I take it into a text editor, and if I just start manipulating it,
put each argument on one line, then it becomes a lot easier for me to figure out, oh, this
is actually what the problem was.
You're making a point for indentation of code, too, is the same thing.
Yeah, yeah, exactly.
On the other hand, some of the other compilers I work with, they try to do that sort of formatting for you in their error messages.
And it's hard to identify what the optimal formatting of an error message is going to be in the generic case.
And so I think oftentimes it's good for us as programmers to take the error diagnostic and, see if we can sort it into something that's a little bit more manageable
ourselves.
I think there's a,
there's a tool that Vittorio Romeo has written,
but I do not recall the name of,
but it actually is like you pipe your compilation into this.
And then you can set the level of like nesting of the brackets that it
shows.
So by default, it it collapses all of it.
And then you get a much more succinct.
And the idea is you can keep running it and increasing the level until the message or
the info that you need is there, which is kind of a neat idea.
One interesting problem that we have in the C++ space is the question of when you dump
out an error that's got some sort of stack to it,
like template instantiation stack, which direction do you output? Most compilers
output from the original source of the error all the way down to where it was
triggered from. And I think that's actually not very helpful because like you,
you see it then when you get this long error dump,
the last thing is going to be the first thing that you see.
The last part of the error must be the first thing you see.
And if you see instantiated from here within main, you know,
the place where it was instantiated from is maybe not the most helpful thing.
Oftentimes the most helpful thing is what the, the root of root of that tree of this was the error that happened.
I think the only compiler I've seen that does it the inverse direction, if I recall correctly,
is I think Circle does it the other way around, which I have found to be quite interesting.
I'd love to see that be a switch for which direct, which, which, you know,
to reverse the template instantiate the error instantiation, like message order. I'd love to
see a switch for that so that I could, I would probably switch it by default. Cause like almost
always what I do is I, is I scroll up to the start of the error and I read the error from the start
down. Do you need a clang format kind of tool for error messages?
Yeah. I was just thinking that I was thinking I want clang format for error
messages.
Yeah. That would be cool. It would be a nice project to write.
Yeah. Somebody, somebody get on that. Yeah.
I'm sure there's something out there.
If not after this podcast, there will be.
Thanks for listening. We hope you enjoyed and have a great day.