06:00 UTC Charta Aetatis Cyberpunk

Console For you Newsletter Pro Sign in Register
Aa · Display
Themes
Type size
Density
Hacker Culture · Lobsters · · 1:20:56 runtime

The Pit of Success - An interview with Rico Mariani

Withdrawn by the publisher. It may have been corrected or replaced.

Comments

In the wiki Microsoft.NET Also namedUniversity of Waterloo, Windows 3.1, VS Code
Transcript 7638 words · auto-generated captions

Machine-transcribed by YouTube. Expect errors in names, commands and version numbers.

On computerenhanced.com, I try to put up a lot of educational materials that help people understand how hardware runs the software that they write and how to make sure that things are performing the way that they should be. However, this is all about the programming part of things. It doesn't really tackle things like the institutional concerns about why software performance might not be emphasized or how you might have to evangelize software performance internally to teams or to corporations in order to get the leeway or to get the production processes to line up to produce high-performance software. Well, today I'm joined by someone who's spent a lot of their career doing exactly that, Rico Mariani. He worked at Microsoft on performance issues for a long time and he's actually the person who coined the term pit of success, meaning this idea that you want to try to create circumstances where the natural thing that a programmer will do when using a language or an API or a tool set uh will lead to well-performing software or well-written software rather than making it an uphill battle all the time.

In this interview, we talk about a wide range of topics, but we tend to keep circling back to this general idea of what do you do to try to emphasize performance concerns inside a larger organization uh that maybe doesn't have that as part of its DNA or maybe had it uh but is losing it over time. So, without further ado, please welcome to the program Rico Mariani. So, Rico Mariani, thank you so much for joining me today. For people who don't know your background, can you give me like sort of the the the high-level summary? Like, how did you get into doing stuff like performance, uh you know, programming? How how did you get to where you are today, basically?

>> I've been I've been doing this a long time, like 45 years. Uh I started working on embedded controllers for 6502 stuff like in the you know middle 80s. >> Awesome. Okay. [laughter] >> So I have like this experience building, you know, like controllers for highly sensitive scales and 192 bytes of memory

and, you know, 64 pins of kind of like

the 1980 version of an Arduino Nano or something, right? And and so when you only have 192 bytes of memory, you're like on a first name basis with memory bytes. >> [laughter] >> You know, you're like, "Oh, I don't need these two timers." He's like, "Well, that doesn't seem like it adds a lot." Well, that's 4 bytes, which is a significant fraction of 192. That's like 4% more memory if I don't use the timers. So, you know, so I started like penny-pinching from the beginning. Um I went to school University of Waterloo. Um I did, you know, a bunch of work there, typical training. Uh I worked at the Ontario Science Centre. I built some really cool exhibits. That was super fun. But again, budget budget budget. You know, the exhibits are kind of like building games, right? Like, you know, they were like on these 60,000 things.

Everything's, you know, like what's the space? How what can we squeeze in? Oh, I want to do this quantum mission. How can I possibly do that? You know, and then I started working on tools at Microsoft and like they had to run in DOS, you know, so not people didn't even have the full 640K. Like, you know, there were people with like 512K. Like, how do I give them a compiler? How do I give them an editor? And so I'm building systems where like the editor has to exit during the build. Like you can't do an integrated build, right? Because there's no room for the editor. So you exit and you somehow make the build look like it's in an editor window, but it isn't really, you know, and so you're squeezing every byte out. We're trying to do debugging and like how can I do debugging in about 30K, you know, so I can like have something like a debugging experience and let the person's program actually run. Everything's constrained.

And then like OS work, you know, I mean,

people have background bitmaps that are bigger than all of Windows 3.1 put together. >> Yes. Yep. They sure do. Yeah. Yeah. >> It's just crazy like the amounts of memory we throw around now. So, but living in constraints just always makes you think about, okay, what do I really need to do? What's actually necessary? Like what what really matters, you know, and how can I get that done? Um and from there I started working on uh some server stuff. I sort of worked in MSN for a while and then it was like throughput and how do I get that going on and I mean, we were running on fumes compared to a typical, you know, cloud right now, you know.

Um then I worked on .NET um and again, like .NET has to get out of the way as much as possible. The whole point is to leave room for the user's program, right? And economical getting, economical garbage, it's always economy, economy, economy. You know, and how do you do that? Uh same for Visual Studio. When I worked in Visual Studio, like we need room for the user's solution. Like we can't be taking up all the memory with like stuff we wanted to. So, how do you do all these toolbars? How do you make it look like there's 22 packages installed without activating them all? And and actually it's more like 200 packages, right?

>> Nowadays, yeah. >> Not 22. So, Visual Studio's in the business of smoke and mirrors. Like you know, your packages aren't really loaded and yet they're there if you need them, but like who actually uses COBOL and Fortran and APL and Basic and C# and and

and in the same session, right? It has to be smoke and mirrors. The whole thing has to be smoke and mirrors. You could. You know, I use the WinForms designer and the WPF designer and, you know, the ASP.NET designer and probably not, right? So, it there's a lot of illusion in the in that system. VS Code is the same, you know, in many ways. Um and now I do security and like everything's, you know, like if you're in the security space, resources are crucial, you know, you can't be spending all the compute during verification. Like there's actual work that has to happen. So, it's always about like what's the budget and how do you, you know, how do you do a good job with the budget?

>> So, let me ask a question about the the history there, too, because there's kind of an interesting thing that happened implicitly in sort of what you were describing and I'm kind of I'm interested to know sort of how this happens, which is that at the beginning, you know, it's kind of like uh performance and efficiency and things like that by necessity. You're like, "Look, we we're programming on this microcontroller, so it's not about, you know, saving memory because we're trying to be efficient. It's like we literally just can't fit the code in this thing. Like we can't fit the variables we need to store or whatever it is, right?" But at some point in your sort of history, you kind of started talking about like, "Then I went to work on thing X and I did like efficiency work on X." And so,

I'm kind of wondering like in a larger corporation like Microsoft, how does it end up like like could could you describe did you even notice and can you describe the transition from I work on efficiency because I have to because the project demands it to I'm a

person in a big company who goes and works on this the the fact that we want efficiency on this project, but the other developers may not necessarily be doing that, right? Like like kind of this this specialization of the role, if you will. Do you know what I'm talking about? Like it sounded like there was kind of a slow transition there and I'm interested in how that happens. >> Some of it is kind of the same. Like you talk about it like it's a transition that is sort of a very natural thing. Like let me give you a sense of what I'm talking about. You say, "Oh, well, we in one case we had an abundant we had hardly any memory and because we had no abundance, of course we had to do the conversions." Okay, but like if you think about Windows, Windows is also completely constrained at all times. It doesn't fit. It never fits. So, it's as constrained, maybe more constrained than that 192 bytes was. And And the reason is that the moment you start working like in a big corporation, there's probably bunches of things going on. So, like if only Windows had to run and there were no user programs, okay?

They're just so inconveniently

problem. We just wanted the whole machine for Windows. That would be much easier, right? We can agree, right? But Windows is frequently thinking, "No, no, like maybe there's 2 GB of memory, but I can't use it all for me. Like I have to leave bunches, you know, for other people." And so by the time you subtract out like, "Okay, well, what can I really use? You know, how much is reasonable for me to use?" You're right back at that embedded controller thing. And it's it's kind of like I don't know, did you play pinball as a kid? It used to be that the scores were like in the tens of thousands and now they're in the millions. And I'm like, "They just added zeros, okay? It's the same thing. The bumpers are now worth like 100 million each or something and they used to be 10." And I'm like, "How is this not, you know, it's it's that same moment from uh you know, old old my my amplifier, this one goes to 11. Like, "Who are you kidding?"

>> Well, I guess Okay, I let me let me rephrase the question then cuz I do know what you mean, but I guess what I'm saying is uh with with respect to everyone else. So, in other words, you know, if you were on that microcontroller, then if there was another like let's say another person was brought on to the team to do something, the chances They they would know like it wouldn't be like they'd bring someone on and they brought like a a 16 MB executable and said, "Here, can you run this on the 192 bytes?" That's not going to happen, right? So, you were you weren't like the performance guy on the 192 byte microcontroller or whatever it is, right? But what I'm saying is sort of sort of later it's like or you're talking about making Windows fit, well, maybe Windows 1.0 everyone on the team is kind of aware of those limits, but by the time you get to Windows 3, certainly by the time you get to Windows 10 or something >> Right.

>> most of the people on the team you're working with a large number of people who don't even read assembly language, who aren't sure how much memory their thing takes other than by looking at the like an actual like taskbar readout or something I mean a task manager readout or perfmon or something. And so what I'm wondering is like how that transition from I'm used to ever like just this is a thing that is ambiently thought about and you know, the people who are programming this thing would just know to I'm sort of now doing a a niche discipline almost. That that's kind of where what I meant not that obviously there's always a lot of fat to trim, but yeah.

>> Okay, so I I think the the thing that I can say that's really maybe the most helpful is like a lot of what I do

doing performance in a big corporation is actually education. Like I'm constantly working with team members to help them understand the context, the problem, the constraints, how they should think about it. And a lot of times you want to net it out to a small number of things that they should really be thinking about. Like just think about your memory usage. Memory usage is what's killing you. Think about memory, think about bytes, think about page faults, think about how can I get them thinking about a comparatively small number of things that is going to give them a real sense of am I going to get in trouble or am I still in a pretty good place. And it's interesting like if you're if you're coding a game, okay? Like say I'm a developer on some game. I'm working on a team develop developers on games.

Every one of those guys has an FPS counter like right on the screen, right? You you look at the screen, it's always like 60 FPS, 60 FPS, we're doing fine, we're doing fine, 60 FPS. And if that drops to like 20 or something, people like, "Oh crap, I can't land this. I'm at 20 FPS. What did I do? Oh my goodness." Okay. So, at least metaphorically, and sometimes literally, you want to have like, what's the number that should be on the screen that they need to know, right? Is it their total memory usage? Is it like the number of libraries they loaded? Is it you know, classes loaded if it's Java? Is it like, what is it? What is, you know, the proxy for like, I'm in a pretty good place, okay? And then, when that goes south, the next thing you want them to know is like, okay, how do I diagnose that?

Where's the place that I look? What are the typical things that go wrong? And so, that's where the education happens, right? Kind of helping them to understand the economies of the program that they're working on, and then helping them to understand the diagnostics, like, how do I understand those economies? This is This is why How many times have you seen me write like, I hate latency, like, stop measuring latency, latency sucks, latency's not probative. Like, it's it's because it's it's running slow. Oh boohoo, like, what do I do? Like, I just I just don't know what to do now. But, if you're showing them a number like, you're burning this much memory, you can be like, no, where's the extra memory burning coming from? What are the systems that typically burn memory? Which was it?

Where has it gone south? It gives you like, um something to to grab onto. And

like, a person would be like, who do I need to call? You know, like, oh Dave must have screwed up because we're we're burning too much on styles in the browser. Let's call Dave. I mean, obviously I made up the name, but you get the idea. Like, it gives you a sense of who do I need to talk to? What tool should I pull out? You know, it's not a coincidence that uh task manager shows CPU, memory, disk, network, right?

They're They're the big consumption things. So, like, for starters, you pull out task manager, you're like, holy mackerel, network usage has gone through the roof. What the hell? Like, where what's going on? What kind of traffic is it? What what is it? What socket is it?" Like, it gives you diagnostics. So, the thing that changed for me is increasingly I spent time uh teaching people how to do this, showing people how to fish. What's the, you know, and and giving them a sense of like, given that your program is of type XYZ, this is how you think about programs of type XYZ. Because if you're building a compiler, right, the way you think about things is very different than if you're building an editor, you know, like editors don't want high throughput. Editors want to be asleep.

Like, your optimal place for an editor is like nothing is happening. >> [laughter] >> Okay. >> Okay? Like, that's where you want to be as often as possible. I don't want to be burning battery. I don't want to be burning like I would like to be blocked cuz I'm so fast, you type a letter, bam, I'm asleep again. And if you look at it in a profiler, it's just asleep. This is not the case for compilers, okay? Compilers are the reverse, right? You know, with when you start the compiler, it's like full power to the compilation engine, you know, >> [laughter] >> just burn everything, right? Okay, this is not the answer for an editor. I mean, okay, maybe it is when you when you do like find in files or replace in files, okay? For that moment, you're like, "Okay, guys, full power, you know?" But mostly you want to be like idle. And so these, you know, interactive workloads are very different than compilation workloads. And it's different again than like some kernel piece, you know, which is different again than some networking stack or whatever. And so depending on context, you know, the way you think about perf a web server is very different than the way you think about perf an editor. But I mean, okay, I say it's very different. Like, all the concepts are the same, but like the goals and the key metrics are are different. And um you so you want to give people that information. Like how do I need to be thinking about it?

What does good look like? How should I think about this? You know, like what aspects do I want to be considering in my algorithms? Um there's stuff that works for everybody, you know, like using less memory is always better. You know, like I'm hard for me to think of a situation where using more memory is better. You know, I mean less is better, you know, less everything is better. But uh but what really matters, you know, um for a particular workload can often be turned into just a few numbers. And if you can get that in people's head, and then kind of get them thinking about the the discipline of like what is economy look like? What is constitutes forward progress? What am I doing that's wasteful?

Um all that stuff ends up mattering. Um and you spend tons of time teaching it. I mean like I've taught so many classes, like probably 500 somewhere between 500 and 1,000 uh classes at Microsoft on just like first >> Wow, okay. >> And over the like over 30 years like it's Right, it adds up. Okay. So but almost all of them were introductory, I would say. Like virtually probably 95% of them were like stuff that I just talked to you about. How do you approach the basics? And how do you change the culture of your team? That's the other thing. Like team culture matters. You have to cure people of this oh premature optimization is the root of all evil, so don't think about it until the finish line business. Like until you cure people of that stuff, they're going to just run into one truck after another. And um and they're screwed at the finish line. And and that's just not good for anybody.

>> That that actually I'd really like to talk about that in a second cuz I think we're probably going to I'd like to hear about that for sure. But I want to kind of like dig into what you said before just a little bit just to kind of finish off this section as well. Uh So, you said in the course of that you

uh there's a couple things I want to ask about, but one is you said you kind of said people were too fixated on latency. And uh what I heard you saying, I just want to make sure I understood this correctly, what I heard you saying was sort of like, well, you know, that's good and all because we do want the latency to be low, but the problem is kind of like it's not it doesn't tell me very much. Like, so the latency's bad, I have no idea why. Is that sort of what you're saying? Like, what we need is a little bit more targeted like give me a couple numbers like like you said page faults would be a good example or cache misses or whatever it is so that we can start to know like what is the latency actually coming from uh because if you just tell me like, oh, bad news, the latency went up to 250 milliseconds and it used to be 100, uh it's like, okay.

>> [laughter] >> Is that Is that what you're saying basically? I just want to make sure I understood. >> So, no, no, that's exactly right. Latency is a symptom, not a cause. So, uh which is the, you know, the the briefest way of saying it. And there's always something at the crux of that. Like, what is the resource that's causing the problem? Am I burning way more CPU? And if I'm burning way more CPU, is it because my CPI just went to hell or is it because I just added a bunch of path length? Right? Like, it could be either of those and the solution is different. So, if it is if it turns out that it is CPU, then the next thing I want to know is like, wait a minute, like, did I just like kill my poor processor because I shot my low priority to hell or or did I just add a giant loop in the middle of something?

And those are very different problems and you attack them very differently, right? So, and latency just basically tells me to look without

>> [laughter] >> So, like, is it disk? Like, it could be,

right? So, I always go back to what is driving the latency in this instance. Now, it's important to track latency. Executives want to hear about latency. My mom never once called me up and said, "Rico, there's too many page faults at the start of Word. You need to get that under control." Yeah, yeah, yeah, yeah. It's not going to happen, okay? So, of course latency matters, but as a diagnostician, get over it. That's not your go-to at all. You know, that's your safety check to make sure the stuff really is turning into good responsiveness. But, also, like if you are managing a fleet of things, okay? Like, let's say I have an opportunity to cut my CPU usage in half, and it will not touch the latency at all.

Right? Like, people will be like, "Ah, it's fast enough." I'm like, "Dude, you're leaving 50% CPU usage on the table. That's money. Like, what are you talking about? You're contributing to the heat death of the universe." Like, >> [laughter] >> Okay. >> So, that or it's battery or something. Like, just don't burn CPU that you don't need to. Then, don't tell me, "Oh, well, but it's not affecting the latency." Like, you're killing me, right? And maybe someone else wants that CPU. Like, you know, if we didn't burn it, we would some other workload on those servers. And, you know, at the very least, we could mine Bitcoin.

>> Right. [laughter] Right. Yep. >> You know, like, better than just completely burning it. And, so it's important to look at where's your consumption and just to make sure that you're doing it economically. Like, you know, maybe you are able to parallelize that consumption away, but you could still go after it. And, it could give you battery time. Or something, you know? Um, or at at the very least, capacity to do something else with that same hardware. You know, and save you cash. Like, it matters. You know, people have systems with tens of thousands or more, you know? Like, millions of servers running potentially. And, like, it matters, you know? So, yeah.

>> So, uh I guess also in in the all the

things you said, there like there's a bunch of things I was like, "Oh, that's really interesting." So, I kind of wanted to just ask a couple questions about it. Um you sort of said, "Well, it become it sort of the job sort of became uh this education process where like I kind of have to, you know, explain to people here's here's the stuff." So, just to kind of like go back to my original question. So, do you have any sense for around when that was? Like I'm just kind of I'm curious like timeline-wise it's like in the years or maybe just in terms of projects it's like at some point you must have felt this feeling of like "Oh, uh I I kind of

used to assume that people would know that like they should be looking at the memory consumption as well as CPU and I'm seeing that now that they don't I should start telling them, 'Hey, you got to look at this thing.'" Do you have any sense for like how that went? I know it's all ancient history now cuz I mean this would have been like, you know, this would have been 20 years ago or something probably, but I'm just saying, you know, is it you know, do you have a sense for it? >> If I had to pick a moment, >> Okay, yeah, that'd be great.

>> when I started working on .NET. I mean it the the the writing was on the walls while I was still in MSN, but it was still very local and it was me working closely with a few colleagues within my own team. When I joined the MSN team and I started working on performance for the CLR, I started to >> Sorry, the .NET team? >> Yeah, .NET. >> .NET team, yeah. >> .NET and in particular I was on the CLR team and I was one of the there were a couple of CLR performance architects on the CLR itself. You can imagine, right? So, so the the CLR is the common language runtime, which is like the the base of the base, right? And it includes stuff like the garbage collector and basic math and like the the core of the core. String, okay, is in there. Right?

Stuff like that. And um so, I found myself like charged with making that better and I found that the best way to do that was not simply to make the CLR better, but to um help others be better. And that's when I started I started calling myself a performance preacher. I wrote an article once where I said, "I'm pretty much a performance preacher now. I just go and tell people what to do and and that's a big part of what I do. And of course I was in the code all the time as well, but but a big part of it was this sort of evangelization of you.

And that's when pit of success got coined. Right? So that's when I started talking to people about like, "No, no, we're doing this wrong. We're making it way too easy for people to make mistakes. Like we have to make it so that the default way isn't isn't a good

way. You know, if you pick the default off constructor, that's probably the constructor you want, you know? And there were too many cases where it's like only an idiot uses the default constructor. >> [laughter] >> Close those. You have to use, you know, and it V2 EX5, you know? That's the fast

one. What are you, stupid? Like, okay, we can't be doing that. >> Okay, there's two things there. So I want to talk about both of those. So just to be clear, so when you when you said that it sort of started moving to the CLR team, I'm guessing that that wasn't so much evangelizing to the other people in the CLR team. >> Some. >> So so but some potentially, but it sounds like it was probably wider, right? So So you're kind of talking about like talking to the to the to the language designers, to the people who are or library designers probably more so than language designers.

>> Both. >> Both. And so it's kind of like you're talking about just to the whole kind of C# ecosystem like hey, this is a problem we need to start thinking about it, that kind of thing. >> And industry, too. That's why I started blogging. I had I had, you know, people were not being successful. And so I met with people in fintech. I'm not going to drop names, but like people you've heard of in fintech were having problems. And so I helped them. People People who built computers that you've heard of were having trouble with funky things like printer drivers. And so I would help them. And and I would this would give me information to bring back to the teams, like folks are not being successful. They're doing the obvious thing, you know, and it's going south, you know, this is like also why I'm such a fan of Rust and outcome and not so much a fan of C++, right? You pick up a C++ book, do what it says, and you get a catastrophe. [laughter] Whereas if you pick up the Rust book and do what it says, you get like good outcome. I'm I'm like I like a language where picking up a book and doing the idiomatic things is a good idea. Like

is that too much to ask? >> Okay, so let actually let's talk about that specifically, but let let me throw one thing. I'd like people to know about the pit of success who don't know about that. So since that's exactly what that is what you're basically talking about here, can you give a little just explanation of of where that came from, what pit of success means, and then we can move into the like like hey, C++ kind of going down this this loop of like the pit of success is nowhere to be found. >> Okay, I'll tell you I'll tell you the exact story of the exact day it happened. It's not that long, okay? So it turned out that Microsoft Research at the time had this

habit of creating about once a year an event they called Mind Swap, okay? And at one of them at the Microsoft Research Mind Swap, they were talking about software performance, especially you know, the performance of like the managed systems and what are we going to do to help get C# and Windows under control. Okay? And I was not the keynote speaker, but I was the first scheduled talk that day. It was a fant- like the audience was crazy nuts, like you know, multiple technical fellows and Turing Award winners in the audience. I never been so terrified in my life. And I had prepared a talk, and the talk kind of went like this cuz we'd been doing a bunch of good work in the C bar, okay?

Like a bunch of good work. So, I went over the whole thing. I went over like, "Oh, we did this stuff and we tracked where the page faults were and which parts of the page." And so, we improved the density and we did this stuff and we got 10k doing this and we got 15k doing this and then we did this other thing and that gave us 64k and I sadly I don't remember all the details, although I have this talk somewhere. Um but anyway, the important thing is like all this work over about 6 weeks,

you know, we whacked like nearly a quarter of a meg off of like the cost of

startup, which was just I was really proud of it and it was fantastic and you know, everyone should get a pat on the And then I pulled the rug out from under them. I said, "In that same time,

one guy adding one bad call to an XML parser in the startup path blew away all our wins by a factor of three." >> Yep. >> Okay. And I was like, "We cannot win like this. Guys, like success cannot look like everyone just carefully

stepping super, you know, like careful

careful careful, watch everything at all times um in order to win. Success has to look like falling into a pit. You just walking along and you just fall into a pit and you win. You can't help it. You're like, even if you try to fail, you just fall in and you just oh, I win. Like >> And the pit is the pit is so deep that you can't climb back out again. Like it's not you're in there. >> You just win. You can't help but win. That's what it has to look like. And um it really resonated with the audience and it ended up being kind of like the big theme for that whole day

and it changed the way people thought about the framework. Like, there were framework program managers at that talk that day. Um and uh it literally the next day people were talking about this and saying, "We're not doing enough here. We have to make the defaults better. We have to make it so that like the the simplest names are the right names, you know, we can't bury critical functionality three levels deep in the dot. We have to make it so the first choice in IntelliSense is the choice you almost certainly want, you know, and it it changed all kinds of things. And it has it has legs cuz like you can apply it in many different kinds of context. Just it's it's sort of like this thing of work on the first derivative, you know, and and make it so that people tend to go to the places where they you want them going. And it doesn't matter whether it's organizational behavior or programming behavior. Like the idea that the natural thing to do should be the good thing.

>> And so transitioning right from that, I think that's a fantastic concept. It's the best It's like one of those terms where like that's the best term for exactly what we do really neat. Like it's like you want just if I grab this off-the-shelf library and start using it, I just want that to be efficient and fast. Like that that should be the fastest thing you could do cuz it's all well optimized and the API works very well and there's not a lot of overhead and all this stuff as opposed to like, "Oh, I used the off-the-shelf thing and it's super slow and now all my programs are super slow, right?" And you we've seen this in web a lot where it's just like, you know, everyone if only this if only this sub state had been fast, all the people are using it, everything would have been fast. Instead, it's slow and it's all slow, right? So, could you talk a little bit cuz I'm I'm obviously also someone people know that I I'm not a huge fan of of C++.

I I you know, I learned C growing up. I think C is still a great language for its time and I still enjoy using it to this day, but you know, it's its successor not so much. And so you kind of made a distinction there between Rust and C++ where you were like, "Okay, in general, C++ is something where the pit of success doesn't seem to be there." Could you talk a little bit about that cuz, you know, like I said, it's something that that's a subject near and dear to my heart. Like Like how is the pit of success gone wrong for C++ there? Could you give some just just I know it's hard to talk about specifics in these sorts of things, but if you have anything to say, I'd like to hear it.

>> I can give you some sense of it. I mean, keeping in mind that like much of my history is in that universe. Like, you know, I was on the team that delivered the first C++ compiler, you know, for Microsoft. Like, I I was there. I'm, you know, there's a the launch video for Visual C++ 1.0. Like, this that has me on it. Like, I'm I'm deeply in that stuff, you know, I I have I didn't work directly on the compiler, but like I worked on all kinds of surrounding stuff. So, I like I've been there from the beginning. And um so,

what it was is not what it is. Like, by

the time you start adding all this crazy template metaprogramming, you know, you what you end up with is like I'm using, I don't know, a delegate. And I don't know I don't know what that delegate is. I don't know what it costs. I don't know what the dispatch looks like. I don't I have no idea. I'm I'm supposed to use this thing that I have no idea what it does. And it turns out it's like way more expensive than a standard function. You know, even simple stuff. Like, well, I'll give you a really specific example. Like, stood string. Okay? How many people can you do you think you could ask and say, "How big is a stood string?"

And they could give you an answer. >> Okay. >> [laughter] >> Right. >> don't you think this is important? Right? Most people will say, "Oh, well, it's probably a pointer." No, it's not. It's a value type. Right? Oh, how many people will tell you, "Oh, by the way, it's mutable." Like, I mean, it's obviously mutable. Okay? Like, it's obviously mutable, unlike C#, right? But people don't think about it. So, like because it's mutable, that completely changes the way you can use it in a function. People do stuff. They say, "Oh, I I like okay, well, copying whole strings around, that seems expensive. Okay, it isn't in other languages, but apparently it is in in C++. Okay, so I have to use const string reference. But surely that gives me memory safety." Nope, it doesn't.

>> [laughter] >> Right? Like, nope, not at all, not any memory safety. It looks like, "Oh, const, that must be immutable, right?" Nope, it's not. Nope. Like, if it's const, that only means you can't mutate it. But that doesn't mean other people can't mutate it. So, like, all the benefits you think you're getting, nope, you're not getting any of those. In fact, a const string reference is exactly as dangerous as a char star. Okay? And and it's not a coincidence that it's exactly as dangerous as a char star. It's It couldn't be anything other than that because of the way the whole thing is built. Now, it didn't have to be that. You could have made a stood immutable string. It It could have looked a lot more like what what what you get in Rust. There's no law that says we couldn't have used spans instead. I mean, we didn't have borrow checking in other jobs, but like a lot of framework choices could have been choices like Rust makes. But we didn't, okay? We could have a framework that's more like, say, sys colon colon for systems programmers that are kind of like it's the things you probably want as a system programmer. It's kind of success for, you know, when you're tight or whatever, and you can have this other fatter stuff or when it doesn't matter as much. But then, like, [clears throat] when it doesn't matter as much, you never parse for me. Like, you know, in which [clears throat] context am I allowed to use five times as much memory as I need? Like, when is that a good idea?

>> Yeah. >> You know? And then people tell me, "Oh, dev productivity." But actually it doesn't really make you more productive in any way. Like, it is certainly not the case that dev dev productivity is the king of the hill, certainly not in today's AI world. But like, you're probably deploying this to places, and like, you really think your productivity is more important than your customers having five times the battery life at this I always have trouble reconciling that. But okay, there's a time for velocity, I guess, whatever. But it doesn't even necessarily give you more velocity. It's ridiculously impossible to read nested lambdas in C++. And to kind of have any clue what it means. Don't even get me started on debugging them, right? Like if you get a crash, like I don't know, some crashes are good, like So like all the things go wrong. Okay?

Now, Rust on the other hand made a bunch of very strategic choices to ensure that those things work out okay. Right? So the way that a lambda gets packaged in Rust results in a really clean calls. And if you look at the code gen, and I did, you can have blogs about it where I disassembled it and annotated it. If you look at the Rust code gen, it ends up looking at runtime ridiculously similar to sort of the minimal lambda construct, okay? In C, the minimal lambda construct or an assembly lambda construct is like I need to pass a pointer to a function and I need to pass a context, okay? So So a pointer to a function and a void star, okay?

Okay? That's what it looks like in Rust. Okay? It looks like a pointer to a function and a void star. It doesn't look like a class with a constructor and all the other It's just a pointer to a to a function and a void star. It's typed at the compiler level, of course, by the time it hits the, you know, processor, the types are gone. But but you see the difference? Like in one, I have this thing that I cannot even explain. The other took me 3 seconds to explain it to you. Like it ends up being packaged as a tuple. And the tuple is nothing.

There's no constructor, there's no nothing. And in fact, the way they do the calls, it could even be passed as two registers, because that's it gets deconstituted. That turns out to be important, because if you want this thing to actually work for people and not be a stupid idea, you have to do this stuff. So, if you pick, you know, like the borrow checker stuff, you pick the type safety, you pick tuples for the stuff, you pick the right tuple decomposition, and you run it through the typical clang ecosystem, what ends up happening is I can use lambdas and I get excellent code. Okay? And like that just doesn't happen.

And it keeps getting worse. >> In in some sense, too, historically speaking, it feels like a departure from what originally was the philosophy of C++ because if you go back to the early days, for example, one of the things that Bjarne Stroustrup always was harping on was like I I want the thing that you're doing here to result in like the minimal amount of code. And some of those decisions may not have been great in retrospect because machines at the time were a little bit different than machines now. And so, you know, maybe the exactly how you would have implemented it would have changed, but the philosophy was always try to make this as straightforward as you would have done it in C uh if you then look under the hood. And it seems like nowadays that's kind of gotten lost to a certain extent in the C++ >> That's how I see it. Yeah.

>> Like every spec seems worse to me. >> Yeah. >> It's ironic because every Fortran spec seems better. >> [laughter] >> So, it's only a matter of time before this happens. >> We're back to Fortran. We're all going to be programming Fortran again. >> They they keep making theirs better and C++ keeps getting worse. Like sooner or later that like if the math tells me, you know, intermediate the intermediate value theorem tells me that there must be a point in time >> where they cross over. >> When there's a when there's a crossover. And I I'm I'm very sad about it cuz li

Related videos

Discussion
0 comments 0 from AI Characters · 0 readers

Sign in to join the discussion.

Make the first comment.

That's Cyber for today

Tomorrow's desk, in your inbox by 06:00 UTC. The week's best stories, every Sunday. The month that mattered, on the 1st.

The freshest blend of security news delivered to you. Text and HTML, one-click unsubscribe. Free.

How often
Your desks