CppCast - Beautiful C++

Episode Date: December 9, 2021

Rob and Jason are joined by Kate Gregory and Guy Davidson. They first talk about a free online game development course and updates to CLion. Then they talk to Kate and Guy about their upcoming book: B...eautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code. News C++ Game Programming course on YouTube CLion 2021.3 Modernizing Your Code With C++20 Links Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code on Amazon Kate Gregory's Blog - Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code Sample Code for Beautiful C++ on Compiler Explorer C++ North - The Canadian C++ Conference C++ Reflection TS: A First Look Total War: Warhammer III Sponsors Indicate the #cppcast hashtag and request your PVS-Studio one-month trial license here https://pvs-studio.com/try_free C++ tools evolution: static code analyzers: https://pvs-studio.com/0873

Transcript
Discussion (0)
Starting point is 00:00:00 Episode 328 of CppCast with guest Kate Gregory and Guy Davidson recorded December 9th, 2021. Sponsor of this episode of CppCast is the PVS Studio team. The team promotes regular usage of static code analysis and the PVS Studio static analysis tool. In this episode, we talk about C-Line and an online game dev course. Then we talk to Kate Gregory and Guy Davidson. Kate and Guy tell us about their upcoming book, Beautiful C++. Welcome to episode 328 of CppCast, the first podcast for C++ developers by C++ developers. My host, Rob Irving, joined by my co-host, Jason Turner.
Starting point is 00:01:17 Jason, how are you doing today? I'm all right, Rob. How are you doing? Doing okay. It is December, which is crazy. Like, this year has just flown by 16 days until christmas for people who are keeping track yeah uh you're you're ready for the holiday season sure we're getting some housework done right now so the whole house is in shambles so it's hard to like think about that but we still have the decorations up. That seems like it'd be difficult to do in December in Colorado, get any sort of work done. Nah, it's inside stuff, which is why, yeah.
Starting point is 00:01:51 Okay. Well, at the top of every episode, I'd like to read a piece of feedback. Jason, you put out this tweet last week about different types of brackets, and you got a nice reply saying, listening to an old CppCast yesterday, I think someone called the angle brackets alligator brackets and I kind of want that to be a thing.
Starting point is 00:02:15 I don't recall that. I don't know. It sounded vaguely familiar but I have no idea who it was. I like the idea of calling them alligator brackets though. That's cute. I like the idea of calling them alligator brackets though. That's cute. I was really just trying, I was like,
Starting point is 00:02:27 honestly trying to be just, I was, I'm doing the education thing, right? I'm like, this is how these things are referred to in the standard. And you know, it helps if we're going to talk about braced initialization or parenthesized
Starting point is 00:02:40 initialization that we know what we're talking about. And, uh, that is not what most people took from that. Yeah. You got some kind of snarky comments. Yeah. I got called lots of names or something.
Starting point is 00:02:54 Yeah. Yeah. Don't think that's what we're saying. All right. Well, we'd love to hear your thoughts about the show. You can always reach out to us on Facebook, Twitter, or email us at feedback at cppcast.com. And don't forget to leave us a review on iTunes or subscribe on YouTube. Joining us today is Kate Gregory. Kate has been using C++ since before Microsoft had a C++ compiler and has been paid to program since 1979. She loves C++ and believes that software should make our lives easier. That includes making lives of developers easier.
Starting point is 00:03:23 She'll stay up late arguing about deterministic destruction or how modern C++ is not the C++ you remember. Kate runs a small consulting firm in Roland, Ontario and provides mentoring and management consultant services as well as writing code every week. She's spoken all over the world, written over a dozen books, and helped thousands of developers to be better at what they do. Kate is a C++ MVP and Imagine Cup judge and mentor
Starting point is 00:03:43 and active contributor to Stack Overflow and other Stack Exchange sites. She develops courses for Pluralsight, primarily on C++ and Visual Studio. And since its founding in 2014, she has served on the planning and programming committees for CPCon, the largest C++ conference ever held, where she also delivers sessions. Kate, welcome back to the show. Thank you. Good to be back. Okay, so of all the things that you mentioned here, I don't know if we've ever talked about Imagine Cup. Oh, I love Imagine Cup. It's sort of more.NET focused and more Azure focused.
Starting point is 00:04:12 So it's harder for me to be part of the technical side of it these days. But it's a competition that Microsoft runs for students. And they set them a challenge and they get some software and sometimes build some hardware. And then we judge it. Is this a good idea? Did you do a good job of it? set them a challenge and then get some software and sometimes build some hardware uh and then then we judge it is this a good idea did you do a good job of it and meeting these like 19 and 20 year olds who want to literally like solve world hunger or or get people vaccinated or uh or make life better for someone with a disability is just so cool yeah um I did some in-person judging in various places and things like a glove that can translate sign language
Starting point is 00:04:49 into spoken language. Oh, wow. So the signer wears the glove and signs and then your phone or whatever says the words. Just really, they don't know what they can't do. So they're amazing. That's really cool. Also joining us today is
Starting point is 00:05:06 guy davidson guy is the head of engineering practice at creative assembly makers of the total war franchise alien isolation and halo wars 2 guy has been writing games since the early 1980s he has now also contributed to the c++ standardization process particularly through sg14 the study group devoted to low latency, real-time requirements, and performance and efficiency, especially for games, financial, banking, and simulations. And to SG 13, the HMI study group, as well as LEWG, the Library Evolution Working Group. He's trying to get a matrix class into the standard. He speaks at schools, colleges, and universities about programming and likes to help good programmers become better programmers. Guy, welcome back to the show. Lovely to be back again. Nice to see you all, chaps.
Starting point is 00:05:44 And Kate, obviously. So, that's what the linear algebra proposal, the graphics proposal, everything is just down to just the matrix class. You want the matrix class. That's it. Do you know what? Yes.
Starting point is 00:06:00 I have suffered from immense scope retreat. A scope retreat the like of which no engineer has ever seen. In fact retreat the like of which no engineer has ever seen. In fact, the like of which every engineer has possibly prayed for at one point in their life. I just want a matrix. I just want a standard matrix that's interoperable with other matrices so that all the matrix stuff can happen.
Starting point is 00:06:19 You know, matrix with matrix. There's so many matrix libraries out there. So many. There's probably one in every studio. And if I write some great matrix code and then somebody else writes some great matrix code, so what? They're not interoperable. So really, I just want to establish
Starting point is 00:06:37 some vocabulary that says, look, this is what a matrix looks like in C++ and then maybe NumPy can stop eating our lunch. You don't hear that term scope retreat very often. No, I've never heard of it. You're hearing that scope creep all the time. Yes. What is the opposite of scope creep?
Starting point is 00:06:54 The opposite of scope creep is scope retreat. It never happens. That's why you never hear about it. All right. So, Kate and Guy, we've got a couple news articles to discuss. Feel free to comment on any of these and we'll start talking about the book. OK, great. OK, so this first one we have is a C++ game programming course on YouTube. And this looks like it's actually coming from like an actual university course where the lectures were done online,
Starting point is 00:07:23 probably because of COVID, and they just took all of the lecture recordings and made them available online. So if you have any interest in game programming, whether you're a student yourself, or maybe, you know, you just want to kind of catch up on things, it seems like a really good resource. It's absolutely great, actually. I'm delighted with lockdown that people have said, all right, everything's going online, let's just broadcast it. And also universities giving away material like this is pretty fantastic.
Starting point is 00:07:51 I've skimmed through a few of the chapters, and he's covering a lot of material in a short amount of time. It's like being in a wind tunnel sometimes. Just the amount of stuff he's fire-herding at you. But it's great it really is great if you've got the stamina you know you could try watching it at one and a half speed for that
Starting point is 00:08:09 full uh you know disengaged brain just absorb it and bypass your consciousness effect and it would be like uh after neo gets jacked in the first time be like i know game programming yeah yeah that's that's i think that's where we're going with this, isn't it? I'm looking forward to the next matrix film. I don't know about you. Oh, no, I'm, I'm,
Starting point is 00:08:30 I'm not because the, there was so far, there's only been one matrix movie, right? Let's be clear about this. Okay. My, my favorite was the second.
Starting point is 00:08:39 So be careful. Oh, wow. I know. Yes. I don't have anything else to say. No, you don't. It really was the second.
Starting point is 00:08:54 Yeah, this is great, though. Stop laughing, it's true. I was going to say, it looks like the course itself was actually given over Twitch. Yeah, it was Twitch stream. Well, that's where to reach your audience, right? Yeah. Precisely that. It looks like the course itself was actually given over Twitch, which I thought was really interesting. Yeah, it was Twitch 3. Well, that's where to reach your audience, right? Yeah. Precisely that.
Starting point is 00:09:12 Game programming is a great way to learn programming for a number of reasons. I mean, that's how I learned programming. But also, nobody dies. You know, if you're learning programming on, I don't know, nuclear reactors or medical imaging equipment or things like that. Yeah, the stakes are a little higher. They really are. The worst thing that happens when one of my games crashes, actually my games never crash, but the worst things that happen should on the off chance
Starting point is 00:09:32 one of my games crashes, you just restart it and spam the notice and it causes some flame. And then get on with your life. The worst case, though, really, is that someone sends you a death threat because their game crashed, right? I mean, we've heard plenty of stories about that.'t joke about that no i'm not joking yeah that happens right that does actually happen people get very very angry disproportionately so but you know
Starting point is 00:09:54 that's so weird yeah but i think partly they they believe that they could do it you know like everybody wants to write games and so they think they they could. Right. And so they're like, what kind of moron would, would write something that blows up in this situation? You know, like just your regular everyday programmer would write that actually. Thanks. How did you manage to leave that bug in the game? Yeah.
Starting point is 00:10:18 Do you think I did that on purpose? You strange individual. I wrote special. If this is Steve and he's right near the waterfall. Turn off his machine and turn on his kettle. Yeah. I have kind of wondered just philosophically if exploitable bugs at games are actually bugs or if they're features. Because then you get this whole speed running genre of people that are.
Starting point is 00:10:41 I couldn't possibly comment i know that that the one speed runner i know is quite happy to find you know mysterious things where if you put your shoulder in this wall you can go twice as fast and and whatnot yeah yeah that's profound dedication to speed running just to finding glitches oh goodness it's amazing really you've got so many other things you could be doing with your life you're looking for glitches in my game I just watched like a 30 minute video about the latest exploit from Mario
Starting point is 00:11:14 Kart 64 30 minutes? I think that's right yeah that's like it's crazy and they're still trying to figure out can they get through this level faster on a 30 year old game or whatever It's crazy. And they're still trying to figure out, can they get through this level faster on a 30-year-old game or whatever?
Starting point is 00:11:30 Wow, that is impressive. Yeah, they need to go and work in QA. We need people like that in all seriousness. We really do need people with that sort of obsessive attention to detail testing our games. Back in the day, that was definitely how people got hired. When I was at the university, there were people who would figure out how to send emails dated thousands
Starting point is 00:11:50 of years in the future or from non-existent accounts or whatever, and the administrators would just be like, come to my office, and you think you're going to get kicked out of the university, and instead you're offered a part-time job. Awesome. kicked out of the university and instead you're offered a part-time job. Okay. Next thing we have is a post from the Jetbrains blog.
Starting point is 00:12:13 And this is CLion 2021.3. Some of the headline features here are remote development, better data views in the debugger, Docker tool chain, custom compiler, type hints and more. So it sounds like a really big update to CLion, right, Jason? Yeah, I need to install this update. Yeah, I know. The remote development is something that Visual Studios had in for a while
Starting point is 00:12:39 to go from Windows to Linux. So it's nice to see other IDEs picking up that sort of feature. Oh, it's had it for a long time. We use remote development when we have engineers in other buildings and we want to be able to say... And the game crashes because we haven't finished it and we haven't taken all the bugs out.
Starting point is 00:12:56 It's great being able to attach to somebody else's machine and just get the calls back and the symbols and everything. It is a great feature. I do like Sea Lion, JetBrains stuff. It's great. Unfortunately, making Windows games, I'm kind of bound to use Visual Studio,
Starting point is 00:13:12 which is also a great product, don't get me wrong. I think that, you know, I look back 20 years ago at using IDEs and, you know, it'd be unfair to say it was a horror show, but not unreasonable. And, you know, they're just ergonomically so much nicer. It'd be unfair to say it was a horror show, but not unreasonable. They're just ergonomically so much nicer.
Starting point is 00:13:32 And JetBrains, it just feels nice. There's just a different kind of UI effort going on there. I'm a big fan. I'm a Visual Studio person, but I had a plan some years ago to learn all the major, not just IDEs, but compilers and editors and stuff so that if I was going to do workshops or training, that people could use whatever tool they wanted. And I would know how to turn on the blah, blah option in their compiler. And I'd be like, oh, just turn on, you know, F this or D that, and we'd be fine. But then I got sick. and I haven't been able to pick my project back up again
Starting point is 00:14:05 to become completely fluent in like five different editors and five different compilers. And I feel kind of the ghost of that when things like a new version of sea lion comes out and I should be good at that too. Too many tools out there. We can't learn them all. Yeah. But I love the competition.
Starting point is 00:14:23 It makes all the tools better. Yeah. Yeah, love the competition. It makes all the tools better. Yeah. Yeah, definitely. Okay. And then last thing we have is a post from Phil at the Sonar Source blog. And this is modernizing your code with C++ 20. And some of the new triggers they have here are really nice. They have a couple here related to the spaceship operator
Starting point is 00:14:45 jason other ones you want to talk about oh uh this well they're all interesting they're not always auto one i had no idea because i had never tried to do this before that in a generic lambda you could do decal type of previous argument i didn't know that that would compile. That's interesting. But anyhow, yeah, it's good stuff. Like Span, I don't know about you all, but I'm still getting in the habit of using Span, so having a tool tell me,
Starting point is 00:15:15 you should use Span here, you're like, I'm okay with that. Starts with and begins with transformations, starts with and ends with transformations. I think it all looks awesome. Yeah. I love linters. Linters are great.
Starting point is 00:15:29 You know, they just make your life easier and your code nicer, and it just fixes things. There are too many, you know, do's and don'ts, well, not do's and don'ts, but shoulds and shouldn'ts in C++ to hold them all in your head at once.
Starting point is 00:15:42 Can you feel me? Segway, by the way. Right. But no, having automated lint, it's great. It really is. Yeah, when you have something, whether it's the guidelines or whether it's, hey, we added a feature in C++20, to expect a person to go through and spot all the opportunities to take advantage of something, that's totally a job for a computer.
Starting point is 00:16:04 Yeah. You know? I was also unaware of this decal type of the other arguments to the lambda thing and the blog makes it sound like wow that's so awkward to type and it's much nicer to use you know templated syntax and i'm like it was also really awkward to know it existed so so you know this is much more intuitive to write as well as to read. There's a random comment in here that I kind of want to comment on the comment. Phil says, it's another possible surprise that support for C++20 is currently better in GCC and MSVC than it is in Clang. Which is totally true.
Starting point is 00:16:45 And I'm really starting to feel this because we're using, I mean, we were just talking about CLion and I'm using CLion exclusively with a lot of C++20 features right now on a project, toy project I'm working on, and I have red squiggles everywhere because the clang backend doesn't know that it's valid C++. But it compiles just fine because I'm using GCC because I need those
Starting point is 00:17:01 C++, well, I want those C++20 features. So that's unfortunate. Having said that, Clang support just got a rather remarkable fillip a couple of weeks ago because the reflection TS was dropped in
Starting point is 00:17:18 to a fork of Clang. And you can use it on Compiler Explorer. And if you read my Twitter feed, a friend of mine at work, a colleague at work, Clement Pirelli, he posted a blog about his experiences of using the Reflection TS. So, you know, I do find my feed, find his blog, do have a read about it.
Starting point is 00:17:39 It's quite interesting. And, you know, the TS is quite, you know, it's interesting. It's quite nice. You can do things like get the identifiers of enums and stuff like that. Is that English quite nice there, Guy? Meaning extraordinarily terrific? What? Sorry?
Starting point is 00:17:54 What did I say? You said quite nice. That's very high praise, yes? Yes. I'm sorry. British English. Quite nice is, my goodness, this is fantastic. That's where I thought you were going, yes. Yeah. Okay. Yes. I'm sorry. I English. Quite nice. My goodness, this is fantastic! That's where I thought you were going, yes.
Starting point is 00:18:05 Yeah, okay, yes. I'm sorry, I'm a slave to understatements. It's the Britishness. Compile time sucks, unfortunately, but this is just an experimental implementation, so I wouldn't take that as an indicator of trouble ahead for reflection. Not necessarily, anyway.
Starting point is 00:18:22 Well, that does sound absolutely amazing. The cynical side of me does have to say, but that's like a C++ 26 feature we're talking about right now, right? I don't know if we even make that. 29? Well, I think the thing is once you get past 26, all bets are off, really.
Starting point is 00:18:38 You know, the three-year delivery cycle is great. You know, it really is great, but I think, you know, we know what's in 23. We've pretty much shut the gates on 23. And all the things that we didn't get in 23, we're going to try and jam into 26. And I think reflection is one of those things that we really do need to take carefully. And we're still taking the executives in. There's lots to go on.
Starting point is 00:19:00 But we can't just sit in a room and talk about them. People have to actually try using it. So the TS is absolutely the precondition to getting it in a room and talk about them. People have to actually try using it, so the TS is absolutely the precondition to getting it in any version. It really is. Yeah, something the size of reflection. You can't just dump that on people and say, right, here we go, what's next?
Starting point is 00:19:15 We figured this all out, it's perfect. We're just having an argument right now on Twitter about the names of all the STL functions and how they're basically all wrong, which is terrible. You know, because they weren't, you know, shook out for years
Starting point is 00:19:31 with users who were allowed to change them. They were thought up all at once. About people for whom English wasn't necessarily their first language as well. It's, yes. Sorry. English is my first language in case you hadn't guessed. No, British is my first language, in case you hadn't guessed. No, British is your first language.
Starting point is 00:19:50 Oh, hush. Oh, don't start. Don't start that. I do not speak Scots, nor Welsh, nor Ulster Scots, nor Irish. I maintain that I am conversational in British English, but not fluent. Because even after years of watching British TV and having British friends, I mean, I've had British friends going back to like 87. I still sometimes hear a phrase and I'm like, I have no idea what you just said.
Starting point is 00:20:17 Our slang evolves at a terrifying rate. We're half the size of Texas and yet we have about 35 times the number of accents. All right. So we haven't mentioned the book yet. Do one of you want to give us, you know, first tell us the title of the book, a little bit about what inspired you to write the book? Maybe Kate, start with you? Sure.
Starting point is 00:20:38 The book has a fairly long title, Beautiful C++, and then as a subtitle, 30 Core Guidelines for Writing Clean, Safe and Fast Code because we were just trying to put good adjectives in as much as we could. And that's what it is. We took the core
Starting point is 00:20:54 guidelines, which is, I don't know, 600 or something, and grabbed I don't know, a million. We grabbed 30 of them and they're not necessarily the best. Sometimes they were chosen for being, you know, easily accessible and something people could use right away and other times because they were very far reaching and explained them because the guidelines themselves
Starting point is 00:21:17 are pretty terse. They say things like reason for performance. And then they just like, here's an example and they move on and we uh wanted to be able to relax and spend some pages on why this is faster or safer or more obvious or something more maintainable and uh and so that's what you get one chapter per per guideline stories code why this is a good way to live what did this process look like from going from like 6,000 core guidelines to 330? Was it like a roulette wheel dartboard? Well, we started with Kate's 10 guidelines that she presented at her talk in 2017
Starting point is 00:21:56 at CPP con. And she divided those 10 into a group of five, five sections of two. And it seems that, well, that worked. So why don't we just stick with that? And we looked at it. The thing is, it's impossible to, they're all good core guidelines. You know, they're of differing quality,
Starting point is 00:22:14 but they're all great and they're all valuable. And it's very hard to make that kind of choice. So really we were looking for any steer or any clue or any help along the way of narrowing down. So having had, you know, with five sections and two already chosen, that meant we only had to choose another 20, and they had to fit into that structure. So it just made life easier to stick to that structure.
Starting point is 00:22:36 Okay, okay. And it also kind of explains some of the motivations because part of the problem with the guidelines is, like, some of these are like, do this to make your code more maintainable and others are like do this to make your code faster and and so without understanding why it's very hard so that's why you know we're like these are to protect you from pain versus you know bike shedding is bad is just stop arguing just do it this way it's not worth conversation. And there are guidelines that are like that. That's interesting.
Starting point is 00:23:09 Do it this way because it's simply not worth arguing about. Yeah. Do it this way because Kate and Guy said so. Really, just that should be sufficient. Really, it should. You can put that right in the, you know, in emotional code, we talk about the defensive comment where you put,
Starting point is 00:23:23 I did this because this person said it was okay. Just do that. Yeah, do that. So what brought the two of you together to collaborate on the book? Oh, this is a long story. Isn't it? I'll just go light my pipe. I did this talk.
Starting point is 00:23:41 And then that same year, I went to China and I spoke at a conference in China, which if you get a chance, I recommend you do. Maybe not this year. And I met someone there who translated my talk live while I was talking. And we talked a lot. And he's a C++ aware person. And it turns out he also published books. So he had this great idea, we would do a guidelines book. And he had some really innovative and cool things that made me decide I would do a book after not doing any books for like 10 years. And we were all set, but I knew I couldn't do it by myself. I wanted a co-author. So I roped Guy in to be co-author. And then when the pandemic hit, this guy sort of went cold, just stopped talking and wasn't around. And he's not dead. He occasionally posts on Facebook, but I don't
Starting point is 00:24:23 think he's publishing books right now. But here were and i all like yes a guidelines book what a great idea so so we found a different home for it and then uh my life got super busy and why don't we write a book turned into why don't you write a book and i'll be helpful that's really yeah that's really what we did okay so which one was the you write the book and i'll be helpful i wrote the book i was helping i wrote i wrote 90 000 words and kate cheered me on from the side which was fine it was absolutely fine you know you know kate's a busy woman she really is and um although i am quite busy i i don't have you know i i just had more time available to me when pandemic kicked off, I was working
Starting point is 00:25:06 from home and suddenly I was gifted an additional two hours a day from not commuting. And I thought, what should I do with this two hours a day? I shall write 750 words. And that's what I did. I just wrote 750 words. And even when I, yeah, and even when I got writer's block, I just wrote
Starting point is 00:25:21 750 rubbish words and then came back and edited them when my writer's block subsided. I think, I really think that's the best way to work got writer's block, I just wrote 750 rubbish words and then came back and edited them when my writer's block subsided. I think I really think that's the best way to work through writer's block is to just write rubbish and then come back and fix it. It was a great lesson. And yeah, and I just wrote it, really. It was quite easy, ultimately. Yeah, we didn't have to come up with a plot, you know, or decide what was, how the characters would end up getting married in the end.
Starting point is 00:25:48 So that was okay. And, and so I would say things like, I think this example is, is terrific. Or I think this example is too long or sometimes, wow, this paragraph should be two pages earlier because it's an amazing paragraph that they needed to read before they saw the code or whatever.
Starting point is 00:26:01 And so I think I made it better, but I, I know I didn't type 90,000 words yeah actually arriving at 90,000 words was um because we didn't know how long the book would be we mean nothing we just thought right 30 guidelines that seems like a good number how about 30k yeah yeah yeah guys 30 that's good okay let's do 30. But then how long should the book be? Oh, 250 pages. Yeah, we were just plucking numbers out of the air. We just needed a number.
Starting point is 00:26:32 That's right. And you sort of expect that your publisher is going to be really strict on you, you know, like chapters will all be between 21 and 25 pages with six diagrams. No, they're like, eh, whatever. I'm sure it'll be good. You probably know what you're doing.
Starting point is 00:26:44 Yeah. It seemed inappropriate to say, eh, whatever. I'm sure it'll be good. You probably know what you're doing. Yeah. It seemed inappropriate to say that we didn't. We came up with a number of 250 pages. We said, right, well, how many words is that? And so I just picked the nearest book and counted the number of words on the page and said, okay, so that
Starting point is 00:26:59 I forget. Well, I'm sure we can all do the arithmetic, but I'll save you the bother. And, you know, it came up with 90,000 words. I thought, okay, so that's 30 items, 90,000 words. That's 3,000 words an item. That's okay. That's kind of like a long blog post. So I'll just write 30 long blog posts.
Starting point is 00:27:14 This will be easy. I'll have this done by Christmas. I was wrong. You didn't get it done by Christmas. No, last Christmas. Oh. It's a year late, but don't tell anyone. Too late.
Starting point is 00:27:30 What is time? Today is Thursday, the 17th of January. It's been that day for a long time. It's still April 2020, isn't it? Really. Well, you know, I feel like to be fair, though, Guy, Kate did all the hard work,
Starting point is 00:27:49 as I see it. Absolutely, yeah. Because if you had a well-defined structure for what this book was supposed to be to start with, that saved countless hours of moving things around. Yep, it absolutely did. I appreciate you're being slightly facetious,
Starting point is 00:28:06 but actually you're... I'm only being slightly facetious. I am actually being serious because, you know, I've done this too. Yeah. Early structure absolutely saves it. It really was just, okay, write 30 blog posts. I don't know about you, but writing a blog post is actually quite a lot of fun. It's nice.
Starting point is 00:28:19 You think, right, I'm going to write a post about order of parameters in function signatures. And that's a really tightly well-bound problem. And most of us, like if you poke us right, we will blurt out that many words. You know, like, why is air no bad? Whoa, you picked the one there, didn't you? You can nerd snipe anyone on that.
Starting point is 00:28:42 They will give you a lot more than 3000 words. Right. Yeah. And yeah, that's just do that. But the trick is to do that every day, no matter how you feel. Yeah.
Starting point is 00:28:54 I ended up doing, I think ultimately I sank into 750 words on Monday through Thursday and then 1500 on Saturday and Sunday. And then on Friday I'm, I cooked a roast dinner for my family and drank wine. So it seemed like not the right day to be writing words. That's how you can tell you're not 20 because you're sensible. Yes, that's right. But it meant that I was writing, what, 4,500 words a week.
Starting point is 00:29:21 So 20 weeks. It took longer than 20 weeks. How did it end up taking a year and a half it should have well that's what you just said yeah i didn't want to start writing until we actually had signed on the dotted line and yeah and in the meantime whilst you know whilst the pandemic was going on i was sitting there so just having ideas and writing bits and pieces and then but there came a point i think it was december about this time last year i've been right okay i'm just going to write this you know if if the worst happens i've got 30 good blog posts and i started writing over christmas and um i mean some weeks i couldn't
Starting point is 00:29:55 write for you know there was there was the accu conference and the stuff happened and i i had a i had a kind of a list of things which would which would take priority over writing. But generally, I think I finished the text in about 25 or 30 weeks. I think you had to do a whole extra chapter, right? Did we not do one and then realize that these two chapters are the same? They're different guidelines, but it's all the same thing. There was a chapter on concurrency, and I thought this is about – I think after I reached 12,000 words, I thought, I need to stop here. This chapter is turning into another book. And it was impossible. Some of the guidelines really are, you know, gnomically tiny. And you think, honestly, you know, you're stating great law here in 23 words. This is not suitable for a 3,000-word blog post. I mean, so some things like, you know,
Starting point is 00:30:47 keep the number of function arguments low. Here's an example of a function with too many arguments and typical stupid mistakes that people can make and three ways you can make it better. They're really easy. And then others are like, they're just like philosophy. So keep scopes small.
Starting point is 00:31:04 That is a chapter that will change your brain. I really enjoyed writing that one so much. You know, some of the chapters you can, I imagine, you know, if you, well, certainly if you know me, you'll read some of these chapters and think, Guy is going up the wall here with delight. I can hear a chuckle in the background. It's abstraction. I learned about abstraction. I used to think Ile in the background.
Starting point is 00:31:26 It's abstraction. I learned about abstraction. I used to think I knew what abstraction was. And then I wrote this book and I realized I know about a tenth of what abstraction actually, actually is. And it just became an emerging theme in the book. And I realized a lot of these guidelines are all about improving your abstractions. And you realize, oh, actually, that's an important thing to do, isn't it? Make your abstractions orthogonal and compact and factor everything together nicely.
Starting point is 00:31:52 And, you know, I imagine, you know, we've got talks coming up next year. I imagine I might try pitching a talk just on abstraction. I'm sure CPP Colm would love a talk on one hour. Well, actually, it is an abstraction, you know. Yeah. That's a good title right there. What actually is abstraction? Yeah.
Starting point is 00:32:07 I'm going to stop talking actually, because I could just, I could wait here for the next, I could improvise for an hour now on abstraction. It's been quite, it's been quite revelatory to me. Well, that's, that's a talk I'm working on is also on abstraction on, on the way we don't teach abstraction right now. Yeah.
Starting point is 00:32:24 So, you know what? We should probably collaborate somewhere. Yes. You know, if you teach people to program, you teach them to design, you teach them to sit around and look at their problem space and come up with abstractions for,
Starting point is 00:32:35 I don't know, five minutes or a week. And then they write code and then they're done, right? And you never come back to it. And the most important abstraction and certainly the biggest volume of abstraction is on running working code, discovering new abstractions in the code. And so that's, that's the talk. I'm, I'm, I got not much more than that at the moment, a little bit more than that. And hopefully we get to have conferences this year.
Starting point is 00:32:59 Oh, please, please. I'm missing all my friends. I have so many hugs to give. I really do. I think if we have conferences this year, is everyone going to be comfortable with hugs yet or not? You might have to just temper your expectations a little bit. I was at an NDC in Norway earlier this year. That was quite high.
Starting point is 00:33:23 I was there too, right? You were. You were. you were. In a way. In spirit. In a non-huggable form. Yeah, I couldn't give him a hug without looking like a strange person. Against the screen.
Starting point is 00:33:38 Cruciform. But everyone was quite friendly there, but I guess that's Norway. Conditions in different countries will change how – ACCU in Bristol is going to be full of British people. I don't know how huggy it'll be. I'm quite huggy. I don't know – Matt Godbolt, he's very huggy.
Starting point is 00:33:58 But I don't know about the rest of the delegates. There should be a pent-up demand, you know. Maybe we need coloured lanyards with our you know. Maybe we need colored lanyards with our names on. So we have red lanyards and don't go away. Don't hug me. I'm still not okay with it. Stop it. Stop. And green lanyards for hey, come here.
Starting point is 00:34:16 I'll be wearing a green lanyard. The sponsor of this episode of CppCast is the PVS Studio development team. PVS Studio is a static code analysis solution that helps enhance code quality, security, and safety. The analyzer detects bugs and potential vulnerabilities in C, C++, C Sharp, and Java code on Windows, Linux, and macOS. CppCast listeners can use the CppCast hashtag to get the analyzer's one-month trial version. To request the trial, use the link in the podcast description. C++ projects are getting increasingly complex. get the analyzers one month trial version to request the trial. Use the link in the podcast description.
Starting point is 00:34:47 C++ projects are getting increasingly complex, too complex for people to analyze them thoroughly during code reviews. That's where code analyzers come in. They notice everything the human eye misses, thus making code reviews more productive and enhancing code quality. Want to know more about the problem? Take a look at the recent article from the PVS studio team, C++ tools, evolutionatic Code Analyzers. The link is in the podcast description.
Starting point is 00:35:09 I certainly want to talk more about the book, but on the note of conferences, Kate, there's an upcoming Canadian conference, is that right? Yes, so before all the pandemic happened, a group of people, people periodically tell me there should be X in Toronto. Nobody ever wants there to be X in rural Ontario an hour or two outside of Toronto, but people want there to be X in Toronto for many, many values of X. And I always say to them, well, then if you started,
Starting point is 00:35:34 I'll help you. And somebody wanted a user group. And I said, if you started, I'll help you. And then to my astonishment, he started it. And there's a good thriving C++ user group, a meetup in Toronto now. So that was a surprise because most people say, great, and then they go away. But he actually did it. And then people started saying the user group should put on a Toronto C++ conference. And that's going to happen. So it's CppNorth. If you want to go to the website, it's cppnorth.ca for Canada.
Starting point is 00:36:07 The North is a misnomer, but I don't have an explanation about that. It's less than half an hour long. So North because Canada is north of the United States. Even though Toronto is south of Seattle and London and most of the places other than the United States. So it'll be, assuming we get to have it in July, Sean Parent has agreed to come and do a keynote. I've been twisted into doing a keynote. I think you'll see a lot of familiar faces and names. The call is supposed to go out in the new year. Connor Hoekstra is our program chair. And the early bird will probably open around then too.
Starting point is 00:36:45 And we're stealing a leaf from a lot of conferences. The early bird is your discount for trusting the program committee that will make a great program. So you won't know who's coming, but if you think we can put on a great show, cause we're going to, you know, when I was a kid,
Starting point is 00:36:59 we used to watch these things with Mickey Rooney, I think it was. And they're going to borrow some of mom's sheets and put on a play in the barn and that kind of thing. Just a bunch of kids that don't know what they're doing, having fun. I sort of feel that way about the conference. We're like, yeah, sure. We'll need three rooms for this. And we're choosing what time coffee will be every day. We're grownups and we know what we're doing. But I think we will put on a great program because people will submit and they will come and give great talks.
Starting point is 00:37:25 And I look forward to that. I do hope to attend, but I don't know if I will or not be able to at the moment. Everyone's in this boat, right? Like, I don't even know if I can drive to Toronto. Never mind flying, right? Right. So today, I could not go to England. I submitted to ACCU, but today I couldn't go to England.
Starting point is 00:37:42 I'd have to quarantine. And when I came home, I'd have to, I think, only just get a lot of tests, but that's annoying too. But, you know, July is a long way away. So I wouldn't recommend to book unrefundable plane tickets. Yes. Aeroflot still owes me for CPP Russia two years ago. Just saying, Aeroflot, if you're listening. If Aeroflot's listening. Well, I got all my plane tickets back from 2020, but I still do not have the refund for my train pass.
Starting point is 00:38:13 I buy a British rail pass to bomb around England on. And they're like, oh, yes, excellent. We'll totally give you your money back when we get a minute. And like every couple of months I write to them and they're like, we're very busy, very high volume. Sorry, sorry. I can only apologize, even though it's nothing to do with me. I really like taking the trains around England and all the English people are like, really, really? You think this is nice? I'm like,
Starting point is 00:38:39 you have not seen Canadian trains. This is super great. If I'm given the choice, I will take a train over flying. I don't even care. To be fair, I haven't been on any of those trains that you see on YouTube where there's 7,000 people crammed into one train car. Hanging off the roof.
Starting point is 00:38:57 I've never done that. But any train where I have a seat, I'm going to do that over flying. Even if it's a six-hour train ride. You should try the train from Cologne to Munich and then try going on to Prague and going through Central Europe. They're just the best trains. And you go through the Alps and it's amazing. I've done some of that. Yeah, about 30 years ago, I took the train from Klagenfurt in southern Austria to Ostend in Belgium. It was just an amazing journey. So, yeah, trains are great.
Starting point is 00:39:31 One trip from Switzerland into we were trying to get to Salzburg. And they kept wanting to route me north around through Germany and drop back down in because that's the faster route. And it was difficult to actually convince the train system to let me book the one that was straight through Austria, through the Alps. So we went through Innsbruck and took longer,
Starting point is 00:39:55 but it was, yeah. I did learn that that Valley is a little too narrow. And if you're in the train in the Valley, you can't actually see the mountains. So they have observation cars, which, which you have to book four months in advance and that sort of thing.
Starting point is 00:40:11 Right. Wow. Garden tools and train journeys. What's happened? Well, the garden tools probably got edited out by now. Okay. So don't worry about that.
Starting point is 00:40:21 If you're listening. But I do, but I do look forward to having conferences all over everywhere and to going to Europe and to going to the UK, which I guess is not Europe anymore, and to welcoming people to Canada. It'll be just nice to be normal again, you know? Yeah, definitely.
Starting point is 00:40:38 That's what I look forward to. I think the UK is still on the European tectonic plate, I believe is the argument here. I wouldn't put it past why my fellow countrymen are trying to shove us away into the Atlantic, frankly. Dig something. Dig down. Come on, boys, dig under. If we dig under Britain, we can move it. I guess going back to the book, you said you started off with the 10 guidelines from Kate's talk. Are there any kind of other key guidelines that are maybe worth going over?
Starting point is 00:41:12 Obviously, you know, listeners should go and check the book once it's out, though. Oh, there's too many. They're all good. Take, for example, we didn't have, I didn't have any constexpr in my talk because it was in 2017. And now, you know, constexpr is like a much, much bigger thing. So there's a whole guideline, which is super vague, typical guideline. Use constexpr for values that can be computed at compile time. Like, yes, that is what it is for.
Starting point is 00:41:39 Like, thank you. Use blue paint to color things that you would like to be blue. But so that's a great place to just wax poetic for a bunch of pages about what it's for, how it works, when it's good to use, what else it's good for besides just code you actually intend to ship. Yeah, and that was a good chapter to write because we have sample code all the way through. And I've shipped the sample code in Compiler Explorer. So right now, just yesterday, I finished it
Starting point is 00:42:10 because I knew I'd be recording this show. And so right now, you can go to godbolt.org slash zed slash cg30-ch0.0. I've memorized it. I'll supply a link for you later and you can check all 30 chapters out two of the chapters don't have any sample code but they have a link
Starting point is 00:42:31 which says there's no sample code here Sunshine and you can check it all and also there are links to buying the book and all that sort of thing but the context for a chapter was the most fun to write the sample code for because what I did was I wrote a function to calculate
Starting point is 00:42:48 sine x in radians using a Taylor expansion. And it's fascinating seeing which compilers say, oh, here you are, the answer's 7. Or which other ones say, oh, look, here's 4,000 lines of assembly for you instead. And also,
Starting point is 00:43:03 how many parameters do you take? If you say, I want it to 7 pounds of X, then some compilers will say, 7's too many, and will fall back to generating the code. Others will say, yeah, 7's fine. Come on. Come at me. More parameters. I can do all this in compile time.
Starting point is 00:43:20 It'll only take me 35 minutes. And so it's a great place to experiment with constexpr. I do love Compiler Explorer. MacCodbolt is a gift to the modern universities of Marvel. Yes. I mean, there's just so many things that are just easy. It gets rid of bike shedding.
Starting point is 00:43:38 Like I had someone argue with me about doing mod. You know, if you want to see if something's even or odd, you can mod two and see if the remainder is zero or not. Yeah, that doesn't fully work. No, no. You should bitwise it with one. Bitwise and with one. Oh, no, that's the one that doesn't work, right?
Starting point is 00:43:55 They both work. They both produce the exact same assembly. And one of them messes up with negative numbers, right? You can't compare the remainder to one. You have to compare the remainder to zero. Oh, okay, okay. Yeah. Thanks. Right, right, right? You can't compare the remainder to one. You have to compare the remainder to zero. Oh, okay, okay. Thanks. Right, right, right.
Starting point is 00:44:10 But other than that, you're laughing. But it's like, if you wanted bitwise and with one, if you somehow feel that's more readable, which most people don't, then it doesn't matter. You'll get the same assembly. And then you get in this argument about what's simple and what's readable.
Starting point is 00:44:23 Because if you're someone who's never met the modulo operator, doesn't know what the percent is for, and maybe hasn't been introduced to the concept of modulus, then they don't think simple at all to say, well, I just divide by two and then compare the remainder. They like the bitwise and thing. And the compiler's like,
Starting point is 00:44:41 whatevs, we could, you get in the same, you get in the same bits, no matter what you type in your file. And that really stops a lot of this arguing in its tracks, you know? Because, oh, it's faster. We have to care about speed. It's not faster.
Starting point is 00:44:57 It's the same. Compilers are a lot cleverer than you think. In your book for the examples, do you have the short URLs actually printed in the book to take you to Compile Explorer? No, I give you instructions on how to form the URL. Really, if you
Starting point is 00:45:13 start at cg30 chapter 0.0, there are links to all the others. But once you've done it once or twice, you'll work out how to form your URL and you can go and visit. We've put all the sample code in the public domain as well. We've put an explicit public domain license at the top,
Starting point is 00:45:30 so we do hope everybody else will be able to benefit from that code and use it to teach as well. That's cool. And sometimes a chapter will have three or four versions of the same thing. So if we don't have a lot of function parameters, like here's a version with a function with a lot of parameters, and now here's one way to be less parameters. And so that's all controlled with if-defs.
Starting point is 00:45:49 And then in Compiler Explorer, obviously you can define whatever macros you want, so you can light up the different sections one at a time. Yeah, it's just great. I was really pleased with the sample code and how that all worked out. And it also saves you, you know, the first couple of times around, because we wrote in Word, Word did things to code.
Starting point is 00:46:09 Oh, yes. It does, yes. It does. This is why I only use Markdown for writing things. Yes. That's because you're self-publishing, aren't you? Yeah, you have some control. They're like, oh, yeah, you can use whatever you like,
Starting point is 00:46:24 as long word document yeah you're thinking oh no can i do it in latex please that'd be great no right no but you know you paste that you paste uh that code into compiler explorer and you find out that's an m dash or curly quotes or whatever you know you didn't spot um so it saved us from that um and every once in a while it saved us from just you Um, and every once in a while it's saved us from just, you type the wrong thing and it looks okay when you read it in word. And then when you put it in an actual tool, you're like, no, that's not correct. I think before we run out of time, we should mention like, where is it available?
Starting point is 00:46:55 When will it come out? Opinions vary. Um, the, uh, the publisher says December 23rd. So that's cool. Uh, I don't, don't know how many people are getting it as a Christmas present. I mean, you can pre-order it now. So, so if there is someone in your life who would, who would benefit from it, that'd be great.
Starting point is 00:47:15 Um, Amazon has, uh, different dates in different countries. So I don't know what they're basing that on, but, um, soon, very soon it will be, uh, in our physical hands and I can't wait. An e-book or no? Yes, there is a paper book and an e-book available. Yes. And there's a bundle so you can have both. So you can grep the e-book, but you can take the paper book into the bath.
Starting point is 00:47:41 That is considerably more difficult to do as a self-publisher, just for the record. Okay. Okay. We'll definitely put links to the book in the show notes so listeners can go and grab that. Guy, before we let you go, you also have something coming up soon, a workshop, right? Yes. I'm writing or developing a workshop with a lady called Stephanie Brenham, who is in Toronto.
Starting point is 00:48:07 And we want to give game developers the opportunity to be better game developers. So it's a C++ training course for people who want to be game developers or who want to try that sort of thing. We really have just started on it. So we're hoping to present it a couple of times next year if we have in-person conferences. And it's a lot of fun, actually, putting the material together. We're only about 15 hours of material.
Starting point is 00:48:37 So look out for it. Do come and attend. It's a great excuse to go to a conference, actually, is to go to the workshops before and after. Because I know, Jason, you do plenty of workshops don't you and a normal season of my life yes obviously things are a little bit different now i'm also speaking it's i'm also speaking at accu next year i'm doing the opening keynote which is a terrifying privilege um oh it's fun opening keynotes the best because then you're done
Starting point is 00:49:05 for the rest of the conference That is the single consolation that I'm drawing from this offer, frankly is that I can at 10.31, I can walk off the stage and go drink tea Free person But also, you're under no obligation to
Starting point is 00:49:21 revise your talk at the last minute because of something brilliant that someone else said. And ACCU especially is a place where someone says something Monday morning and Monday afternoon someone mentions it in their talk, and they've got a slide for it, you know. Yeah, that's one of my favorite things actually about ACCU. It's about the right size for everyone to be interactively updating their talks
Starting point is 00:49:43 as the conference progresses. And since it's the opening talk of the conference, if anything goes wrong, they can't blame you because they're clearly, you know, are still sorting out the bugs for the conference. That's fantastic, isn't it? That's great. It's win-win, win all round, really. Well done. All right. Well, it was great having you both on the show today is there anything else you want to plug or anything before we let you both go Warhammer 3
Starting point is 00:50:11 I don't know Warhammer 3 is the game I'm currently working on when's that coming out it's coming out in February we're very close now and yeah please buy it it It's great. Buy all our Total War games, frankly.
Starting point is 00:50:26 They're all amazing works of genius. With no bugs. With no bugs. None. None at all. They're perfect in every way. Just a handful of user-specific settings that are... Yeah, that's right.
Starting point is 00:50:40 If you're one of the users who's been chosen, I'm sorry, but we hate you, obviously. They're great. They're great. You know what? Hundreds of hours of entertainment per title. I'm going to stop talking now, actually. It's just getting embarrassing. Do you want to tell us about it?
Starting point is 00:51:00 No, I'm hoping to have a slightly more peaceful 2022. A little more flying, a little less being home, but a uh, but a little less, uh, a little less deadlines. I am updating a bunch of my Pluralsight courses, uh, to be C++20 aware. Um, that'll, that'll keep me, uh, occupied for a while. Can you patch those courses or do you have to redo the whole thing? How does that? You can patch them, but they're trying not to, because it turns out that there have plenty of people who can't upgrade.
Starting point is 00:51:29 So if all the courses are always on the super latest greatest and you are an enterprise user who can't move to the super latest greatest, then there's no course that's good for you. Okay. So they're like, you know what? Leave your old course alone. It's not hurting anyone, but do, do one for the latest version. And so right now I'm working on a what's new. So it's entirely like spaceship operator and, and,
Starting point is 00:51:51 you know, co-routines like stuff that is actually new, but then I'm going to go to existing courses and make C++ 20 versions of them. So the algorithms course is going to get quite a makeover. Oh goodness. There's a lot of updates there. Yeah.
Starting point is 00:52:04 Yes. That's going to be a big project. But it'll be worth it because I think the algorithms are getting more usable now to get some of the problems with them are, in my opinion, ameliorated by what Ranges brings.
Starting point is 00:52:18 Cool. Nice word. It's like a professional word maker or something. All right. Well, Kate and Guy, it was great having you both on again. Looking forward to the book. Thanks for coming on. Thanks for having us. Absolutely lovely to be back on. Yeah. 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
Starting point is 00:52:44 for a topic, we'd love to hear about that too. You can email all your thoughts to feedback at cppcast.com. We'd also appreciate if you can like CppCast on Facebook and follow CppCast on Twitter. You can also follow me at Rob W. Irving and Jason at Lefticus on Twitter. We'd also like to thank all our patrons who help support the show through Patreon. If you'd like to support us on Patreon, you can do so at patreon.com slash cppcast. And of course you can find all that info and the
Starting point is 00:53:12 show notes on the podcast website at cppcast.com Theme music for this

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.