CppCast - Physical Units

Episode Date: May 14, 2020

Rob and Jason are joined by Mateusz Pusz. They first discuss the 10.1 update of GCC and an article from Raymond Chen. Then they talk to Mateusz about his physical units library and his efforts to get ...physical units into the standard. News Worldwide C++ user groups events C++ Community events GCC 10.1 Released The C++ preprocessor doesn't understand anything about C++, and certainly not templates Links mp-units A C++ Approach to Physical Units (CppCon talk) P1935: A C++ Approach to Physical Units Advanced Modern C++ Training Meeting C++ Trainings Sponsors PVS-Studio. Write #cppcast in the message field on the download page and get one month license Read the article "Checking the GCC 10 Compiler with PVS-Studio" covering 10 heroically found errors despite the great number of macros in the GCC code. Use code JetBrainsForCppCast during checkout at JetBrains.com for a 25% discount

Transcript
Discussion (0)
Starting point is 00:00:00 Episode 247 of CppCast with guest Matt Push recorded May 13th, 2020. 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. And by JetBrains, the maker of smart IDEs and tools like IntelliJ, PyCharm, and ReSharper. To help you become a C++ guru, they've got CLion, an intelligent IDE, and ReSharper C++, a smart extension from Visual Studio. Exclusively for CppCast, JetBrains is offering a 25% discount on yearly individual licenses on both of these C++ tools, which applies to new purchases and renewals alike. Use the coupon code JETBRAINS for CppCast during checkout at jetbrains.com to take advantage of this deal in this episode we discuss the gcc update and what the preprocessor can't do.
Starting point is 00:01:08 Then we talk to Matt Push. Matt talks to us about his physical units library and much more. Welcome to episode 247 of CppCast, the first podcast for C++ developers by C++ developers. I'm your host, Rob Irving, joined by my co-host, Jason Turner. Jason, how are you doing today? I'm okay, Rob. How are you doing? I'm doing okay. I'm actually getting over a little bit of a sore throat, but otherwise doing fine. Do you have any news you wanted to share? Well, let me double-check some news real quick, if you don't mind.
Starting point is 00:02:04 Sure. So the next conference that I was supposed to be going to is in dc tech town and that is now moved to an online event that is august 31st through september 3rd uh what exactly that means for me at the moment is uh still being decided but uh that will affect the class that I was planning to teach there for sure. Okay. Well, on that note, I would like to start the episode by reading a piece of feedback. And I actually got this email that you just reminded me of from Harold saying in the most recent episode, which was great, you mentioned that many meetups are online. It would be nice to have a list of them. And he's pointing out that there are a few lists. So there's one on
Starting point is 00:02:49 the Sweden CPP website, and I'll put a link to that in the show notes. And it shows, you know, next events scheduled by that group. And there's also, he says, 30 C++ meetup groups accumulated, you know, some of which are doing all their events online. And then you also concept that meeting C++ posts their list of upcoming user group events. So that's also a good resource. Yeah, there will also be the online C++ conferences soon. I know that C++ Russia is to happen at the end of June. Oh, and that's going to be online also now?
Starting point is 00:03:22 Yes. Okay. And I will be presenting there. That is news that I had missed. I didn't realize that one had moved online too. Probably makes sense. Well, we'd love to hear your thoughts about the show. You can always reach out to us on
Starting point is 00:03:35 Facebook, Twitter, or email us at feedback at cpcast.com. And don't forget to leave us a review on iTunes or subscribe on YouTube. Joining us today is Matt Pusch. Matt is a software architect, principal engineer, and security champion with more than 15 years of experience in designing, writing, and maintaining C++ code for fun and living. A trainer with 10 years of C++ teaching experience, consultant, conference speaker, and evangelist. His main areas of
Starting point is 00:03:59 interest are expertise and our modern C++ code performance, low latency, safety, and maintainability. Matt worked at Intel for 13 years and now is a principal software engineer and the head of the C++ Competency Center at EEPOM Systems. He's also a founder of TrainIT that provides dedicated C++ training and consultant services to corporations around the world. Matt's a contributor and active voting member of the ISO C++ Committee, where together with the best C++ experts in the world, he shapes the future of C++ language language. He's also co-chair of WG21 Study Group 14, which is responsible for driving performance and low latency subjects in the committee. Recently, he also joined MISRA to help make the self-driving cars safer. Matt, welcome to the show.
Starting point is 00:04:39 Welcome. Thank you for inviting me. How's the MISRA work going? Slowly, but progressing. Last we talked about it on the show, they were discussing what seems like MISRA is starting to allow more modern C++ features. Is that right-ish? Yes.
Starting point is 00:04:59 First of all, MISRA acquired the AutoStar 14 standard because AutoStar didn't want to maintain it anymore. So MISRA took it AUTOSAR 14 standard because AUTOSAR didn't want to maintain it anymore, so MISRA took it and it's the owner right now. So the process right now is to review all of the AUTOSAR rules, integrate them with all MISRA rules and actually update the rules to
Starting point is 00:05:17 the modern language. There are a bunch of C++, ICC++ committee members active there, including probably the most active there Peter Summerlatt and a few other folks. I also joined recently. Actually,
Starting point is 00:05:34 I didn't even have the chance to meet the MISRA members in person because of the COVID situation. Are they moving their meetings online as well like everyone else is doing? Yeah, they are having online meetings, but because of me not being on the, let's say, new by introduction, I don't have still the access rights and privileges to the system. So I'm still waiting for me to be introduced to the systems.
Starting point is 00:05:58 I only attended one or two meetings on the ICC Plus Committee meeting, where WG23, World Group Responsible for Safety and Security, was meeting with ICC Plus Committee to work on the MISRA rules. So I attended those meetings and that's how I got to MISRA. Seems like, you know, something like Google Glass or something where we can just be attending meetings online constantly as the world were going to be in here soon enough. Yeah, it seems so.
Starting point is 00:06:29 Actually, I was asked today by my manager if I'm going to go back to work after COVID situation. Or I would like to just stay at home and make the desk cheaper. So your manager actually asked you what you wanted to do. Now I'm curious what your answer was. Actually, I'm working from home for a longer while, so I'm good with it. The only problem is that at that time, before COVID situation, the children and my wife were not at home all the time. So it was easier maybe to focus.
Starting point is 00:06:59 But still, I find working from home more effective than being at work in one big open office with many people talking. Matt, what do you, Rob, what do you think? Are you more effective at home? It's certainly, you know, you do have the distraction of having the kids and wife around for me. But I do like the office. And right now, my home office is also the guest room so i might not want to occupy this year round because if we do ever have people visiting again i wouldn't want
Starting point is 00:07:34 to have to uh be sharing space with them i thought your home office was the ice planet of hoth now currently today it is if you're watching the video stream. Yeah. Okay. Well, Matt, we got a couple news articles to discuss. Feel free to comment on any of these, and then we'll start talking more about MP units and other stuff you've been working on, okay? Okay, sure.
Starting point is 00:07:57 Okay, so this first article we have is that GCC 10.1 was released. Any significant updates in here, Jason? So many significant updates. Yeah? So many. Yes. Okay. Making great progress on C++ 20 language support,
Starting point is 00:08:15 compiler, and library. Yes. Yeah, we have concepts, finally, in the language. Awesome. In the compiler, we can play with them. Just naturally writing some code that I would normally write. I put in constexpr algorithms in GCC and it just compiled it.
Starting point is 00:08:30 I used algorithms in a constexpr context and I compiled it. And I'm like, and I didn't even think about it. And then I'm like, wait, let me see how this works on Clang. I switch over to Clang and it's like, this algorithm is not constexpr. I'm like, ah, yes.
Starting point is 00:08:42 So that's, I don't even know if that's listed on these notes, actually. Yeah. Sorry. I interrupted you. Co-routines. Not co-routines. Concepts.
Starting point is 00:08:50 Concepts is huge. Yes. I use it for a longer while in my library. And there was some bugs that were fixed, all of them for GCC 10. So it's good news. Excellent. What other compilers can you currently use that have the level of concept support that you need? Actually, I can use GCC 9.1 and the above.
Starting point is 00:09:13 It's not because of the concepts, but because of the really small feature that I found really easy. And I said, well, this will be probably the first thing that people will implement because it's so easy. So basically this is about the, how it's called, it's about not having to write the template disambiguators, type name disambiguators. I don't remember how the paper was called, but basically down with type name, yeah. This was the paper name.
Starting point is 00:09:41 Okay, yeah, yeah, yeah. So this is a small feature. Every compiler has it implemented already because every compiler tells you that you forget the type name here but it seems that other compilers do not turn it on yet for c++ 20 and because of it both clang and visual studio do not compile my code because i assume this feature will be one of the first and i maybe too fast integrated this with my code yeah so basically in the cases where the compiler says you need template you need type name here instead of giving you an error it's just going to effectively add the type name for you there yeah exactly so i
Starting point is 00:10:17 thought that everyone has it so everyone will enable this as the first first thing for gcc for c++ 20 support but only GCC has it for now. The things that we expect are never the things that we get, I think, when it comes to some of these things. Yep. Lots of new warnings and static analysis options in GCC 10. Yeah. We already talked about the static analysis separately
Starting point is 00:10:42 because that's very new, right? Yes. Yeah. There's a new, yeah, there's a new flag called F analyzer. If I am not wrong in this GCC, but it seems to not work correctly with C plus plus yet.
Starting point is 00:10:55 I think it was mostly for C. Yeah. Uh, Oh yeah, yeah, yeah, yeah. You're right.
Starting point is 00:11:00 But there was no, yeah, you're right. We did. Yeah. We discussed that. I totally got confused by that again well there's also some awesome um so i just had this conversation recently with some people on
Starting point is 00:11:12 twitter where if you run a profile guided optimization particularly visual studio is particularly aggressive about this any code that was not run during the profile run is going to be moved to like the end of the binary way out in the cold section of the binary. And then if you happen to call that code, it's going to, um, it's going to be really slow calling it. And so that's something that the latest GCC is also addressing by giving us more options when we call the profile guided optimizations to say, don't treat unexecuted code as cold code, just optimize the code that was executed. So that's interesting as well. Okay, next thing we have is an article on the old new thing, Raymond Chen's blog, and this is the C++
Starting point is 00:12:05 preprocessor doesn't understand anything about C++ and certainly not templates. And this is a great, fun little article where he points out how little the preprocessor knows about C and C++. Doesn't know the difference between
Starting point is 00:12:21 template brackets and the less than greater than operator. So, yeah, fun little article. Anything else you wanted to add to that? It doesn't know the difference between template brackets and the less than greater than operator. Right. So, yeah, fun little article. Anything else you wanted to add to that? Yeah, you have to watch for commas. Yeah. I have those problems already when I try to use type traits in my asserts.
Starting point is 00:12:37 Hopefully, contracts in C++ will solve this for many years. But, yeah, we don't have contracts in SplatOS 20. No. I did notice that there's one comment here from someone that's like, oh, it's fine. That's why you just use VA args. And Raymond immediately responds to him with like,
Starting point is 00:12:56 except if you want to do this. And it's like, you know, there's, yeah, it's always broken in some way. All right. So Matt, I mentioned that you work on a library called MPUnits. Do you want to tell us a little bit more about that? on TT manipulation. So maybe you know this background. We have Boost units for many, many years. And my library tries to do the same in a different way, let's say. The different way is because
Starting point is 00:13:35 it's designed with the emphasis on a good user experience. So it should be easy to read compile-time error logs or to debug, which is not common for other libraries on the market. Of course, it's open sourced. It's hosted on GitHub with MIT license.
Starting point is 00:13:52 So everyone is welcome to use it. However, it uses C++20 already. So you have to be on GCC 9.1 at least in order to compile the code. It uses heavily concepts and a few other features, but concepts are the major killer feature here. If you are interested about this, of course, there is a documentation on the website, but I also talked about this on C++ Now, CppCon,
Starting point is 00:14:15 and a few other conferences in 2019. So you can find my talks and listen about it. And good news is that you don't have to download, install anything from it, because it's integrated with Compiler Explorer for a longer while right now. So you can just take Compiler Explorer and play with the code right there. You can find some quick start links in the documentation with the links to Compiler Explorer actually to start playing with it. It's really handy when this kind of library is on Compiler Explorer and we can just go play with it.
Starting point is 00:14:44 I agree. So what exactly does a physical units library provide? What types of applications are going to be using something like this? Actually, I started to think about this many years ago, why I was a glider pilot flying in competitions. So this background is actually not without the reason here. I was flying in competitions. I met other pilots. We used software for tactical navigation
Starting point is 00:15:15 and basically planning the task to be done on each day. The software that's open source and actually also closed source from my experience as a consultant and C++ trainer is that most of the software is working with C fundamental types like Dabu. Dabu is Uber type for everything in this. So there is velocity, length, time, everything
Starting point is 00:15:38 is Dabu. And also units of any kind like feeds, nautical miles, kilometers, whatever. The software is using really many different units. All of them are, of course, also double numbers only. So there are a lot of problems with the software. Even though this software is tested, even though it seems to be stable
Starting point is 00:15:59 because it's used for a longer while and nothing happened and no bugs are submitted, for example. But then if someone wants to play with it or change the engine of such a library, he said, do not touch anything because it will break. So it was hard to develop and it's really hard to maintain later on. And this is what I'm trying to address and actually to improve. So people will take the tools to make it right, to make it good from the very first time
Starting point is 00:16:29 because otherwise the program will not compile. And maybe some time ago it was not that important because, well, I don't know, the application will crash or the, I don't know, TomTom will provide us maybe a bad ETA to the target. But right now, our cars will drive for us while we sleep. It starts to be scary if you think that way. The same software that could crash your software like 10 or 20 years ago, right now may cause a fatal accident.
Starting point is 00:17:02 And we don't want to do this. And we should look for the best possible tools to do the job right. And I think it's one of those especially for cars and aviation. So this is tied together with your interest in NISRA as well then.
Starting point is 00:17:18 Yes, exactly. I always cared about safety of interfaces and good usage of strong types. So many of my training that I provide to my students treat about it. So as I said, as a trainer, consultant, I saw too much of the bad code to not care about it. And it's not only open source. Closed source is similar.
Starting point is 00:17:37 Right. I'm curious, and it's not on the topic of C++ at all, but what are these glider competitions like? Well, there are different kinds of competitions. There are, of course, aerobatics, but this is not the one I'm talking about. I think aerobatics on gliders sounds scary to me compared to powered aircraft. Actually, no, because there's nothing to break. Your engine is down already. So you have to plan, and if you plan properly, then you are fine.
Starting point is 00:18:13 There's nothing that can break or surprise you during the competition or just flight. Okay. But those competitions I'm talking about are about flying for many hours for a really long distance. We are doing like 500 kilometers triangle in a straight line, but you cannot fly in a straight line. It's like, for example, sailing. You cannot sail to any point. You have to take account for the wind and you cannot, for example, sail into the wind directly, right?
Starting point is 00:18:37 You always do longer path than the minimal needed. And during competitions, we do like 300, 500 kilometers on the triangle and flying for six, seven hours and come back home safely. Wow. Very cool. That is interesting. So what is, you know, the code in this library
Starting point is 00:18:55 actually look like? One thing I'm wondering is, you know, if you're already working on an application that's using doubles for everything and you think, you know, that sounds like a good idea, it would be better to be safe about you know our different types like distances and
Starting point is 00:19:09 measurements and things like that how would you go about integrating your library uh well first of all good point is that you can use any representation type so you can also use double as a presentation type it's similar to chronoduration, where you can set the representation type. So basically, all of the maths will work the same. The thing that you can get is getting the compile time safety with it. And basically
Starting point is 00:19:35 how it will start, I would just play with some quantities, like length, time, velocity, for start. And then maybe start integrating other more advanced stuff like accelerations like like forces and other stuff it can be done gradually in my experience and and it helps a lot actually if it doesn't compile it meant it means that you had an error there it's like with unique pointer i was um playing with uh because so i've been doing a lot of
Starting point is 00:20:07 training well i had been last year that had physicists in there and we were talking about these kinds of issues that you're discussing and so i played with the idea of my own dimensional analysis units library just to understand what would go into something like this. And mine was very greedy to always reduce the units as much as possible. And I was talking to another friend about this, and he says, no, no, no, no, there are some units that physicists want, like, I don't know, seconds over seconds squared or whatever, because it means something to them. Does your library deal with that?
Starting point is 00:20:42 Yes, it deals with that actually in the same way that yours did. Oh, okay. Yeah, it is greedy, yes. And basically there are so-called dimensionless units. And basically if you divide the same dimension by the same dimension, you end up with no dimension. And there are two approaches here. You can end up with a strong type saying,
Starting point is 00:21:03 I'm a quantity of no dimension and basically most of the libraries on the market uh treat this type specially this type for example can implicitly be converted to and from double or any representation type so it looks like a strong type but behaves like a double so i think that's a that that's that's wrong because you think that you have you have some some additional information there, you have some additional safety, but you are not. And actually the interface starts to be messy because you have a lot of Sphena being done there
Starting point is 00:21:33 or some other overloads that provide you this or maybe partial template specialization that basically provides you this different behavior for this one dimensionless unit type uh so my approach was just if you divide like time by time or length by length you end up with a presentation type like double just to say to everyone okay you just divided this you have a double and expect what double does no no type safety no strong strong types here of course there is some discussion about this it's still open issue issue on the GitHub. So if any one of you have good ideas how to solve it, we have the poll actually pinned on the top of the issues list. You can see it, you can find three different
Starting point is 00:22:16 alternatives that we discussed and maybe provide your feedback there. That sounds great. I don't know the domains that physicists use these units in nearly well enough to know what the use cases are for them. But certainly for any of our listeners, go and find that issue and weigh in on it if you know how this should be handled. Yeah, we are looking for feedback and for any help and for requirements all the time. Because we are using C++20, actually our market that we can test it is really limited. So every user is welcomed. You mentioned a couple other unit libraries like BoostUnits. How does MPUnits compare to those? So I wrote a paper and the paper number is 1935. And I compared there at least five different libraries,
Starting point is 00:23:06 including Boost Unix, Nitholzhaus, Unis library, and Benry, written by Jan Sende from Germany. Those libraries are really nice libraries. I don't want to tell anything wrong about them because they have all of the features, they have users, they do not have bugs in it. But basically, there are not have bugs in it. But basically,
Starting point is 00:23:25 there are people that complain about them. Complain about the bad user experience, for example, that it's hard to understand and analyze compile time errors. That it's really hard to debug this stuff when basically the type you are trying to see or breakpoint prints
Starting point is 00:23:41 like 100 lines on your screen just to print the type that's provided to the function argument. Besides, there are other issues. Many libraries basically convert
Starting point is 00:23:57 implicitly the units to base unit of the system. So, for example, length to meters all the time. And if example, length to meters all of the time. And if you're living in US and using customary units, all units are always converted to meters and back with every calculation. That doesn't make sense.
Starting point is 00:24:16 Which is first of all, yeah, it takes runtime overhead. Yeah. And second of all, it's loss of precision on double or whatever representation type. So I took the same approach that's done with the chronoduration. Basically, the unit scale, unit ratio is being stored in a type rather than being converted all of the time to the SI and back. Another issue that is with the current libraries is that
Starting point is 00:24:46 most of them, if not all of them, have poor support for really large or small unit ratios. You can see that in stood ratio, for example, we miss two first and two last of the ratios that are defined in SI, just because the int64 used in ratio is not big enough to represent this ratio. But if you are dealing with things like electron volts or astronomic units, the ratios can be really huge there. And we have to provide our own ratio type for it. Another point that has some issues with the current solutions is that it's really hard to extend some of those libraries. It may be easy to add new units.
Starting point is 00:25:26 It may be easy to add new derived dimensions for something that you invent. But if, for example, you would like to extend it with a base dimension, like saying, for example, I want to count persons using my, I don't know, product that I do, or would like to have like many hours unit, then it's hard
Starting point is 00:25:48 to integrate such a new unit into the system as a base unit. Yeah, that's basically most of the complaints. So basically, the entry bar to start working with units is too high for many people. For example,
Starting point is 00:26:04 to work with Boost units, it is claimed to require expertise in both C++, like templates, metaprogramming, all of this, and also be an expert in the machine analysis world in order to start with it. You have to include a lot of headers, you have to deal with a lot of issues at the very
Starting point is 00:26:19 beginning. I spoke about this and provided some code examples during my talks on the conferences, so you can find it there. So how am I trying to address those issues? I'm trying to make my library the easiest to use as possible. I'm
Starting point is 00:26:36 basing on a well-known and proved chronoduration. I'm trying to use as simple types as possible. And I spent a lot of time writing a documentation. It's still not great because, for example, tooling for C++20 for concepts is really poor right now. So Doxigan and Sphinx and other stuff that I'm using there
Starting point is 00:26:56 basically have issues with C++20 concepts in the code. But I provided a lot of text on how to use the library, on how to extend it, and so on. So I hope it will be easy for everyone to start with it. Also, I care a lot about those compile time error messages, about the debugging experience. C++20 concepts help a lot here. I also invented something that I call type downcasting facility, which actually should be called maybe like type substitution mechanism that basically allows you to assign a unique name, strong type name to an instantiation of a base class template. So if you have something like a dimension or derived dimension or unit,
Starting point is 00:27:41 and there is some instantiation of it, for example, velocity, you can say just inherit from itiation of it, for example velocity, you can say just inherit from it and say it's just a velocity. So this long instance of direct dimension is a velocity type. And I invented some mechanism to be able
Starting point is 00:27:57 to, during compile time, to actually switch the type. If I see this long instantiation to the one that was nicely named by the user, so velocity. It has some issues, and they were raised. For example, it's one-to-one relationship.
Starting point is 00:28:12 So, for example, if you have two dimensions that have exactly the same, let's say, recipe, they will collide with each other. Right. So it can be probably energy or moment of force,
Starting point is 00:28:23 a good example here. They have exactly the same dimension and they will collide because there will be a compile time error for it. Another point is that, for example, if you will, in one translation unit, you will link up the header with velocity and another one will forget about including this header, you will end up with two different types for the same code,
Starting point is 00:28:41 which is ODR violation problem. So because of those, I'm rethinking this facility if it's really good to use it there. It's really helpful to have it, but also have some issues with using it. So we are looking for some alternatives too. That does sound very interesting to be able to give an actual compile time error.
Starting point is 00:29:02 You used velocity when you meant whatever acceleration or something you know like yeah instead of this length long of an error yeah exactly you can play with it on on compiler explorer and you will see how short and good errors are right now but as i said we have some issues with some some specific types we have to find out how to how to treat them because there are only a few exceptions, but those exceptions basically are the problem right now. Should we optimize for most of the cases or for coverage to support all of the possible dimensions there? I've been, well, quite honestly, over the last few years trying to understand how Hannah has implemented her ctre
Starting point is 00:29:45 library and uh part of that is that she uses um function prototypes just prototypes that aren't implemented as a way to generate new types and then call decl type or whatever on that and it's i played with that a little bit myself and that seemed really handy but what i started to realize is that c++ 17 at least 14 17 20 by the time we get auto return type deduction of 14 gives us like completely different ways of designing libraries like this and like have these like what what are you finding like when you're when you're implementing a library like this from scratch it has to to be literally a completely different approach than Boost, I would think. Actually, I started like you started. You said that you wanted to just find out how it works and understand the subject,
Starting point is 00:30:38 so you started to implement something by yourself. And I did exactly the same. I started from scratch without looking into other competition code, other designs, just to find out how would I do it by myself with my knowledge. And C++20, yeah. Using C++20, you're right. And then I was really surprised that actually a lot of things were similar to BoostUnit. Like, for example, dimension is provided in the same way, like, for example, as a typelist, for example. A typel list that only contains
Starting point is 00:31:05 the dimensions that matter, that are useful in this specific recipe for the dimension, and not just a list of all of the dimensions in the system, like other libraries do.
Starting point is 00:31:15 That you have, like, for example, this long list of components with 1, 0, 0, minus 1, 0, 0, 0, minus 1. And 0, of course, could be skipped, but it's not there. On the type list, you can have a list of different lengths and only the things that matter are on the list. But still, if you have really complicated types like power or even more complicated stuff,
Starting point is 00:31:40 there are many dimensions already on the list. So it starts to be long. So there are some similarities with other libraries. And later on, I, of course, compared it and tried to find the best way to solve the problems. Also, taking into account the knowledge that's already there. I did not reinvent the wheel or basically some solutions were better than mine. But it also differs. It differs because of the C++20, because of the concepts,
Starting point is 00:32:11 because of the scope that from the very first moment I said it has to be easy to use. And this was my main scope that I'm trying to always have in my head. And every time someone asks for a new feature, I said, okay, but will it make more complicated for most of the cases? Or like, I don't want to add additional types to a class template, additional parameters, just to not make those errors longer.
Starting point is 00:32:40 Okay. I want to interrupt the discussion for just a moment to bring you a word from our sponsor, PVS Studio. The company behind the PVS Studio Static Code Analyzer, which has proven itself in the search for errors, typos, and potential vulnerabilities. The tool supports the analysis of C, C++, C Sharp, and Java code. diagnostic rules, but also about integration with such systems as SonarCube, Platform.io, Azure DevOps, Travis CI, CircleCI, GitLab CI, CD, Jenkins, Visual Studio, and more. However, the issue still remains, what can the analyzer do as compared to compilers? Therefore, the PVS Studio team occasionally checks compilers and writes notes about errors
Starting point is 00:33:21 found in them. Recently, another article of this type was posted about checking the GCC 10 compiler. You can check out the link in the description of the podcast. Also, follow the link to the PVS Studio download page. When requesting a license, write the hashtag CppCast and receive a trial license not for one week, but for a full month. So it sounds like the library is definitely still a work in progress. You're talking about some of these changes you're working on.
Starting point is 00:33:46 But you did mention an ISO paper. Are you trying to get a fiscal units library into the standard? Yes. Actually, this is the point here. What I found as a trainer and consultant is that after C++11, no one, even in the corporations that are really, really working with legacy code right now, no one asks how to measure time, how the time point should be represented, because we have chronoduration and everyone just use it and time point for this case, right?
Starting point is 00:34:20 So having something in a standard makes it really easy to use for everyone. Having this in a library on GitHub or even in Boost will have like 20% of usage what standard has. I'm pretty sure if Chrono was only in Boost, probably maybe 20% of the project will use it right now
Starting point is 00:34:39 comparing to those that are using this right now. And this is about safety. This is not about some fancy stuff. And as I said, it starts to be really dangerous with the projects we face lately, right? So it has to be accessible to everyone without any issues, without any, I don't know, legal issues about having third-party software
Starting point is 00:34:57 or not tested software for some guy from the internet, right? If it will be the standard, it's proven, it's accepted, everyone will use it. And that's the point. Of course, I would love to put it in C++23, but I realized that there's not much time. And basically because of the COVID situation, even some meetings were already skipped, like Varna.
Starting point is 00:35:21 So I hope to provide some new papers to New York and maybe earlier also on the telco conferences to talk about it. But we have like probably five or six meetings left before the code freeze or design freeze for C++23.
Starting point is 00:35:40 Wow. So it may be challenging to catch the train. But we spent already a lot of time in the committee discussing this we spent last two meetings probably about 10 hours or 8 hours talking about this library so I think we are on a good track to make it if only no major issues will be discovered and we will solve how to deal with the remaining issues we have
Starting point is 00:36:03 what I found in the IC committee and on the conferences, there is lots of interest and positive feedback about this library. So I'm really looking forward to the future work on this subject. Yeah, and I have to start writing papers about the interface. Because right now we just spoke about the paper I wrote was a discovery paper about the domain to prove to everyone that I did the homework and to let everyone easy to catch up with the domain if needed. So if you are interested in the domain, about the problems, about the current solutions, you should look to the P1935 because it's about it. There is nothing much about my library there.
Starting point is 00:36:44 It's about what we have right now in the environment, what problems we have, what issues we face. I find myself curious, with the talk of standardization, what the relationship to a units library would be with the need for, just in general, strong type defs. Because I feel like a lot of these cases where we say oh well you need stronger types here many of those cases are physical units not all but many of them um i don't know like if your if your library gets accepted and i'm just totally making something up right now because i haven't really thought about this but could i say oh well a uh a point a screen point is a unit in this library and I'm going to use that effectively
Starting point is 00:37:26 as a strong type def in my graphics drawing library. Does that sound like crazy? Points is not a good example. Basically, this library is not a solution for every strong type, mathematic strong type, right?
Starting point is 00:37:42 So probably pixels or latitude, longitude, or price will not be the target for this library. Everything that has runtime conversion factors, like currency, will not be a target for this library. It will be mostly about physical units and probably some other stuff. But still, as you said, the strong type,
Starting point is 00:38:04 if you had it in the language, it would help a lot. Actually, I'm not the first one talking about the physical units library. Probably the first one was Walter Brown, and he started in the 90s. And he started to write first papers, first talks about it, and implemented his
Starting point is 00:38:19 own library about it. And he said to me for years, when we started to talk about this feature, about writing such a library, he said, I would write this one, but I'm still waiting for the last feature remaining in the language that I was not able to put in the language for
Starting point is 00:38:35 the last 10 years. And this feature is basically the OPAC or the strong typedefs. Walter provided a few papers to the ISO committee, but none of them were successful to be accepted that's unfortunate yeah strong type that would be really useful for this and others use cases yeah well all right that's almost a little depressing uh so you've mentioned several times that you are um that you're a trainer you have any upcoming trainings coming up um yes uh
Starting point is 00:39:06 actually there was an announcement lately from from yes about the meeting c++ starting to to provide online trainings i'm basically yes did all of the hard work but we are talking with about it for nearly two years right now to provide such a platform. And yes, we are starting here. There will be quite a lot of trainings in June from many different trainers. You can register to them and attend them easily because those would be online ones.
Starting point is 00:39:41 Yes, besides probably I will have some, let's say, closed trainings for corporations too in the near future. But that's another story. But anyone can go and sign up for your class right now on the meeting CPP website? I hope so. Unless all of the
Starting point is 00:39:57 places are taken already. Because there is a limit of 14 people. Because I believe that online training requires a small group. Okay. Yeah, 14 is relatively small, yeah. What's going to be the topic of this first class? The first class will be Advanced Modern C++.
Starting point is 00:40:17 This is my major first training I do. It's normally, when I'm doing this face-to-face, it takes about four days. But for online course, I made it shorter to three days. And this is about basically an introduction to writing modern C++ code about the philosophy of the language. And it's a base for all other trainings I do, because I first always try to find a common ground for all of the engineers, fill all of the blanks, and provide the same level of knowledge.
Starting point is 00:40:51 And then based on it, we can move to other trainings. So this is your... And this is the first one in the series, right? Would you call this an introductory course? Actually, no. This is not an introduction to C++ for sure. You have to be an experienced engineer to attend this one, right? as an introductory course? Actually, no. This is not an introduction to C++ for sure. You have to be an experienced engineer to attend this one, right?
Starting point is 00:41:08 We'll be talking a lot about problems that we face each day. And actually, in order to understand it, you have to actually trip of some of those problems already and seeing some of those in the production in order to understand why it's a problem or is it a problem at all.
Starting point is 00:41:28 But basically those problems are not about modern C++, are about C++ as a general and especially about legacy C++. And I'm trying to show how can we solve it with modern C++ approach. So you don't have to know C++ 11, 14, 17, or whatever in order to attend this course, but you have to have some experience with the language.
Starting point is 00:41:47 You have to write some templates by yourself already. There will be a lot of templates in this training. So yeah, you're covering all the way up through C++ 20, right? Yes, right. So there will be, of course, C++ 11 with move semantics, 14, 17 with additions to the language and library, and some of 20. We are briefly introducing concepts,
Starting point is 00:42:08 talking about some changes that are coming there, but of course this is not a C++ 20 training yet. And actually, it's only three days, right? So you cannot cover everything in three days. But we'll talk about smart pointers, lambda expressions, algorithms, string view, optional,
Starting point is 00:42:24 variant, and many language features that are useful in writing modern code. You just have to tell the students that before they come to the class, they need to read the entire standard, and then you'll have a good... No, I'm just... No, not really. Actually, I'm there to tell them about the standard.
Starting point is 00:42:40 I'm just saying you have to have some experience as an engineer. It's not just for someone that just joined C++ community and doesn't know much about the language. If you're working in the language as an engineer, for example, for a year, probably you are good enough to join this course. Oh, okay. That's a good metric for people who are thinking about signing up.
Starting point is 00:43:01 Now I think perhaps obvious question, but this class is going to be offered during Central European summertime, I'm assuming. Like if someone from North America wanted to sign up for the class, that would be difficult. I think so. I will leave scheduling to Jens. So yeah, this is full day, eight hour training.
Starting point is 00:43:21 We consider doing half days and half days are easier to accommodate for different time zones but three day of training in half days will be six days it's i think it's too much right i can i can do one day training in half days or two day training in half days maybe but not three day or four day training it's just just too much and actually over more than a week that'd be a lot. Yeah, exactly. And actually from the experience we have in our trainers group in Poland is that people tend to be focused for eight hours of online training easily. And during the post-training questionnaire, they say it was fine
Starting point is 00:43:57 and they would easily repeat it again. And they wouldn't like to have four hours that they just prefer eight hours. So it depends. I don't think that online training is harder than the face-to-face one in this case. Okay. As long as you have good work environment at home without children, wife, or having to cook a dinner
Starting point is 00:44:18 or walk out the dog, for example, outside, yes? In the middle of the training. Just out of curiosity, since i have not yet done an online training uh i mean we we mentioned that rob is on hoth and matt you are uh you're in an f-16 i think right from from from maverick from top gun from top gun that is and um i am at i believe i think I know which bar I'm at. I think it's a bar in Eindhoven that I've been to several times,
Starting point is 00:44:48 but I can only see the thumbnail of myself, and it was a picture that I just took. Do your students do this? Are they actually taking their classes from pubs and the Serengeti and that kind of thing? Actually, the biggest problem during the online training is to make everyone having the camera on. People don't understand how important it is to be on the camera.
Starting point is 00:45:14 I'm not asking everyone to be on the camera all of the time because someone has to sometimes turn it off. But for most of the time, it's really important to be on the camera for trainer and for everyone actually. It's much easier to ask a question during the discussion when you see other people, other students on the cameras, too. Because you don't interact with each other that easily. When you see that someone actually raises their hand, wants to talk something, then you just pass it, pass him in front of you in order to ask the question. You don't collide with him.
Starting point is 00:45:46 If you don't see anyone, there are a lot of collisions. It's hard to have a good discussion and a constructive one if there are like 14 people on the bridge. So then after a while, no one talks or everyone tries to interrupt each other and that's not productive. Also, it's easier for the trainer because trainer takes the energy from the students. If I cannot see anyone and I'm just talking to a dark black screen it's harder for me to be active to be to be engaging for you for like three days long right it's it makes it effective more attractive more fun to
Starting point is 00:46:17 everyone when we see each other so it's really important to be on the camera for those trainings and you can provide any background like this one. You can also have, of course, some features, but I don't expect anyone to have key lights or green screen that I have right now behind me because I'm prepared to deliver those trainings as a trainer. But it's good enough to have any blurring background behind you if you don't want to show your private room or whatever what's behind you
Starting point is 00:46:45 and and that's fine and it makes the training much more efficient for everyone so what uh technology do you think you're going to be using are you going to be using twitch or zoom or something else uh from the experience we have we it seems that zoom is the best one and the next one is microsoft teams but it lacks some features uh in Zoom have really handful features there has like hands you can raise the hands and and then it's easier for you to uh to to to the trainer to to to um let's say uh moderate the discussion there are some emotions there you can say that it's too slow or too fast or answer yes no questions with some emotion icons there is a gallery view so you can see everyone on the on the screen and and then it's easier to
Starting point is 00:47:33 communicate but there are also features like breakout rooms for example which i'm using for mark trainings so you can expect for example that you will be assigned to purse during online training so if you have like 12 people on the group, we'll have like six pairs working together on exercises. It's more efficient if you're working with someone else on a workshop, online workshop, because you don't get stuck that easily. And also it's easier for the trainer to support six parallel groups
Starting point is 00:48:00 rather than 12 individual engineers having different problems. So with breakout rooms you can easily divide people to different rooms and then then they work there in the isolated environment that they can always ask the trainer to come to their room and provide the support and then you talk only with this small group don't and don't interrupt others which actually is common during the face-to-face training. When you come to some engineer, everyone is distracted because you are explaining something to someone.
Starting point is 00:48:28 Actually, the remote training, online training, may be more efficient for some cases. One of them is that, as I said, when I'm talking with some group, others are not distracted. Another thing I found is that people sometimes in the face-to-face training are not asking the questions.
Starting point is 00:48:44 They tend to ask those questions during the breaks when everyone is out of the room. Maybe because they are afraid of the group, maybe because they are shy, but they don't ask it in the room. But during online training, they can provide private message to the trainer and just ask him and no one sees the question.
Starting point is 00:49:00 I always say there are no stupid questions, but basically sometimes people don't want to see their questions by everyone. Yeah. So it's easier to communicate this way. The environment is safer if you are afraid of your colleagues or whatever. I almost had to say this, but you almost make it sound better than in-person training.
Starting point is 00:49:18 Of course, there are some downsides, right? But as I said, there are also a lot of good stuff, right? Also talking about Zoom, for example said there are also a good a lot of good stuff right also talking about zoom for example there are polls you can ask polls to to people they can they can provide you the answers during this so it's interactive you get the feedback immediately like you should provide the feedback once once an hour from the people you know exactly if if if it's paces and good enough and and and how to progress so so yeah i prefer zoom for this one okay okay very interesting and as the zoom seems to cover most of the security issues lately it's it seems to be
Starting point is 00:49:54 also a solution for everyone and probably the company should not ban it anymore can you is it is there a web version of zoom for people who, for whatever reason, can't install it on their platform? I don't think you have to install it, right? No, there is a web version of it. And you don't have to have an account there. It's just a link you have to click and that's all. Okay. And it also has a really good support for green screen.
Starting point is 00:50:19 It's much better than this one we have in Skype. Right. Okay. Well, Matt, it's been great talking to you today. We'll definitely put a link to the paper we mentioned and some of your talks in the show notes. Is there anything else you want to go over before we let you go? And a link to his class.
Starting point is 00:50:36 Yeah, and a link to your class. Maybe, yeah. About talking about the class. We spoke about the meeting C++, but I have also the questionnaire on my website that you can register for any training. Actually, in this questionnaire, I am asking where do you live,
Starting point is 00:50:55 on which place in the earth. So I would like to schedule groups based on the places where they live. So Jason, it's, it's, it's a good solution for the question you ask. So if,
Starting point is 00:51:08 if I will have like, like 10 persons from us, I can provide us specific, um, um, time for the, for the trainings and I will not sleep, but you will have a regular day.
Starting point is 00:51:22 Very cool. Okay, Matt. Well, it's been great having you on the show today. Thank you. It's a pleasure. Thanks for coming on.
Starting point is 00:51:28 Thanks so much for listening in as we chat about C++. We'd love to hear what you think of the podcast. Please let us know if we're discussing the stuff you're interested in, or if you have a suggestion for a 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.
Starting point is 00:51:57 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 show notes on the podcast website at cppcast.com slash cppcast. And of course, you can find all that info and the show notes on the podcast website at cppcast.com. Theme music for this episode is provided by podcastthemes.com.

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