Episode 172: 🇺🇸 Sean Parent on Flash, Chains & Memory Safety
46 minAudio
In this episode, Conor and Bryce interview Sean Parent about Adobe Flash, his new library and idea called Chains and his latest thoughts on memory safety in programming languages and C++. Link to Episode 172 on Website Discuss this episode, leave a comment, or ask a question (on GitHub) Twitter ADSP: The Podcast Conor Hoekstra Bryce Adelstein Lelbach About the Guest: Sean Parent is a senior principal scientist and software architect managing Adobe’s Software Technology Lab. Sean first joined Adobe in 1993 working on Photoshop and is one of the creators of Photoshop Mobile, Lightroom Mobile, and Lightroom Web. In 2009 Sean spent a year at Google working on Chrome OS before returning to Adobe. From 1988 through 1993 Sean worked at Apple, where he was part of the system software team that developed the technologies allowing Apple’s successful transition to PowerPC. Show Notes Date Recorded: 2024-03-07 Date Released: 2024-03-08 Apple TrueType Adobe Flash Conor’s Metric 6.4 DEMO (Stock Screening Program) Adobe LightRoom Adobe Photoshop Express asm.js Pinnacle Studio NVIDIA Tesla NYC++: March 2024 at Adobe ft., Sean Parent Sean Parent’s Chains Talk Sean Parent’s chains Library C++ Senders and Receivers NVIDIA/stdexec - Senders - A Standard Model for Asynchronous Execution in C++ Circle C++ Compiler CppFront Intro Song Info Miss You by Sarah Jansen https://soundcloud.com/sarahjansenmusic Creative Commons - Attribution 3.0 Unported - CC BY 3.0 Free Download / Stream: http://bit.ly/l-miss-you Music promoted by Audio Library https://youtu.be/iYYxnasvfx8
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
Sean ParentYeah, I mean I think the information coming out of Department of Defense and and the White House is filled with a lot of hyperbole, uh, but at the base of it it's not wrong. Uh just uh you know, in working on this chain library at one point I accidentally wrote uh T instead of decay type T. And the result was I captured a reference instead of a value. Uh even though the code looked like it was fine, the type was not.
Sean ParentAnd that meant that I had a use after return on my stack, and it cost me half a day to debug the thing.
ConorSean Harry debugging his problem for half a day. There's hope for all of us.
Sean ParentYeah, so it's too easy to make a mistake like that.
ConorWelcome to ADSP the podcast, episode 172, recorded on March 7th, 2024. My name is Connor, and today with my co-host Price, we interview John Parrot from one of the New York Adobe offices and chat about Adobe Flash, his new library, and idea about function composition called chains, and his latest thoughts on memory-safe programming languages in C. And we're live.
BryceConnor, why are we in a cab?
ConorTurn your game down. Uh testing, testing. We're in a cab because uh we went to the wrong Adobe offices. We are going to interview Sean Parr.
BryceConnor, what was the one job that I gave you? Listen. I asked Connor, hey Connor, can you get the address of where we're going? And then we show up at the wrong building. So now we're gonna have like 40 to 50 minutes to interview Sean Parent. We are currently um at Broadway and uh 28th. Yeah.
Conor28th, 20th. Uh, listen, folks, I'd like to clear I'd like to clear my name here. We were at the correct Adobe office for the meetup. And it was That is true. It was unclear that Sean was going to be at a different Adobe office.
BryceBut Connor mentioned that, hey, Sean said that the office is really near his hotel.
ConorI did.
BryceAnd the office that we were going to is not near his hotel. And I said, well, maybe they have a second office in New York.
ConorI didn't think that there was no possibility of there being a second office in New York. It's New York. It's New York, of course. I mean, literally, when I when I worked at Amazon, they have like six offices in Vancouver, which is like a fraction of the size. Anyways.
BryceBut uh Should we bottom out on that reduced by key thing?
ConorNot yet, not yet. I'm clear my name. But my point was is that I don't think it's unreasonable to assume that uh Sean would be at the Adobe two hours before the meetup happens at that building. You're you're not wrong. And um Yeah. Oops, my bad. And that's why we're recording in the back of the cab right now.
BryceBeautiful. Yellow New York City cab. Not an Uber, not a lift. It is nice. It is nice, yeah. Just stick your hand out and it captures them. It's wonderful.
ConorAnd now, yeah. Now we're gonna go to the correct Adobe Office. Uh we gotta get out of the we gotta get out of the uh I was gonna say elevator, but it's a taxi. I'm gonna clink these microphones. We got two mics now.
BryceYou have a wonderful day. Okay, well, same to you, brother.
ConorTry not to forget. Thank you, sir.
BryceFirst ever pod recorded in a cab. Alright, give me a microphone.
ConorUh here, tick dick, wait.
BryceThere's a possibility. There's a possibility that we've swapped mics, which would make your editing life so much harder.
ConorYeah, not really, honestly.
BryceOkay, good. Then uh then we should swap mics. The main office is the fourth floor, the upload and the 18th bar. Awesome. Thank you. Thank you so much, sir.
ConorAlright, folks, we're going to the fourth floor.
BryceSee, see the uh further south you go in Manhattan. The further south you go in Manhattan, the hotter the elevators get, and the smaller the elevators get.
ConorDamn.
BryceThis one's got a little small, weird door.
ConorI don't think they have a reception. Um we are outside of the Adobe Floors. Union Union Square offices. Please check in at reception.
BryceWhere is reception? Reception, I think, is downstairs. No, that seems too long.
ConorI think we should just uh we just message Sean. Two NVIDIA employees try to break into Adobe offices.
BryceAdobe is a weapons-free workplace.
ConorThis is ADSP the podcast, episode 172. I think.
BryceOh, there is Sean.
ConorLook at that, like magic. Perfect time. Sean just popped out of the elevator.
BryceYeah. This was a series of unfortunate events. We we did not think that it was possible that there were two Adobe offices. No, that's not true.
ConorWe literally, I said, I didn't say that New York didn't have two. I just said, why would Sean be at a different Adobe office than the meetup? I was wrong about that fact. You definitely were.
BryceThis was your fault and I and I changed it.
ConorNo, is it my fault? I'll take the blame. You know, I'm Canadian and I'm apologized on behalf of uh the two Americans here.
BryceAlright, let's um let's wait.
ConorAre you not able to get into these offices either?
BryceNo, no.
ConorNo. I was gonna say, we're all we're all locked out.
BryceAlright.
ConorAlrighty. This is where we steal the IP, folks.
BryceYou know, I've never been to Adobe in an office that does not have nice art.
ConorWell, I mean it kind of is like the creative company, you know?
BryceExactly. Okay.
ConorWell, whisper, like we're in a library.
BryceVery quiet.
ConorWhat has this podcast become, folks? Let's take the picture after Five after. All right. Open concept, folks. Okay, go to the right. All right. Thank you to the lady that helped us get the directions to the room.
BryceI really hope that you keep this all in coming. Oh, yeah, definitely.
ConorHear what we're saying. Alright, we've successfully snuck in to our second Adobe building. This one has Sean Parent in it. And we'll make sure we got the gains right, you know. Who knows about the audio quality of our little cab ride there? Good to good to have you back on the pod, Sean.
Sean ParentThank you.
ConorYou were we were talking about room names and you were explaining.
Sean ParentYeah, well, Bryce mentioned he did not uh or he was seeing a pattern with the the room names on this this floor. Um and I said in San Jose, when they put in the West Tower, which is our first first headquarter building, they named all the the conference rooms after fonts, alphabetical, which made it very easy to find the right conference room, alphabetical by floor. And then when they put in the East Tower, somebody said, Oh, I see, some of the fonts in the West Tower are named after cities.
Sean ParentSo they continued that theme since there's fonts like New York and our East Tower, uh, all the conference rooms are named after cities, which is very confusing because now if you have a meeting in New York, which building are you in? There's a font called New York. There is a font called New York. So there are many fonts named after cities.
BryceSo I guess fonts is not the first thing that comes to mind when I think of Adobe, but I guess it is one of the things that you do.
Sean ParentYeah, so yeah, so we have a uh significant font business, and uh there's even a Warnock font, which is uh uh uh design influenced by our founder.
BryceSo have you ever had to deal with any interesting programming problems related to fonts?
Sean ParentNot at Adobe. I actually worked on uh uh what became TrueType, which was Apple's uh and Microsoft's font system. And most of the development started at Apple, and it was part of the QuickDrive GX project, and I worked on the QuickDrive GX project. So I worked on on bits of that, uh largely trying to optimize how you uh render uh uh uh quadratic veziers.
Sean ParentSo Apple's font system was based off of quadratic Bezier curves where where uh Adobe everything is is uh uh cubic.
BryceSo I heard a story, and I don't know if this is true, but I heard a story that on Windows the little spinning logo is actually a font because their font system is so optimized, it's just the best way to do a little spinning logo is just a series of glyphs in the font.
ConorI have no idea if that's true. Well, you've got you've got the topic.
BryceYeah, I do have the topic.
ConorWe don't even know if Sean has anything to say about this, but Bryce assured me though that the next topic, because you have questions and he better have answers.
BryceSo Well, there is something else that Adobe is known for or was known for in the past that uh we've not talked about here. Usually I think these days we think about Adobe, we think about Photoshop, we think about generative AI. But uh it used to be that uh most people knew Adobe because of Flash. And I remember when I back in the day, when I was a kid, all the cool websites uh used Flash. And you, Connor, didn't you you said yesterday that you used to be an ActionScript wizard?
BryceI don't even know really what ActionScript is.
ConorActionScript was the language that you programmed Flash in, and I wrote well, a couple different applications, but one was like a pretty it was terrible code. I didn't know what I was doing back then, but it was like a stock technical analysis program, and it was amazing because it was so fast. Like I originally wrote it in Visual Basics 6, but like drawing all those little rectangles, and every single time you hit a button and it had to display everything, it just crawled to a halt. But flash, you can just basically like redraw everything, and it's silky smooth, like doesn't matter how much stuff I put on screen.
ConorAnyway, so I put ActionScript 3.0 at like my expert languages at one point. But anyways, yeah.
BryceYeah, so did you did you have anything to do with Flash? Did you have any involvement with Flash?
Sean ParentUh very little. So uh Flash came in uh when we acquired Macromedia, so it was initially a Macromedia product and it came in through an acquisition. And uh when I came back to Adobe from Google, uh our CTO was big on Flash and decided that we were going to write all of the mobile products in Flash. And we had just started this project called uh uh Adobe Revel, which was a consumer version of Lightroom and eventually kind of morphed into Lightroom Mobile.
Sean ParentUm and we did not want to code uh uh uh Revel in Flash. And so we had a plan uh because Revel was going to largely be a uh a tablet-based product, so it was gonna be centered around the tablet. And the idea was to then feed into uh a Lightroom on desktop, and then Adobe had a product uh called uh uh Photoshop Express, which is still there in the App Store, uh but has very little to do with actual Photoshop.
Sean ParentAnd so our thinking was to repurpose Photoshop Express uh since it had kind of uh the camera tech and stuff, and to tailor that as the way to feed the ecosystem and get pictures into this consumer product standpoint or consumer product line. And uh so we had just started working with a team that was doing Express to morph it into what we needed. And uh uh when this mandate came down, we decided to sacrifice uh uh Express to get rewritten into Flash.
Sean ParentAnd uh so that eventually got done, and then it was like a two-year effort, and then it was scrapped.
BryceWhat was it written in original?
Sean ParentUh it was written largely in C. Uh so with a bit of of uh uh uh uh objective uh C ⁇ at the front end side. Yeah, but you know, our CTO thought that that was the way of the future and that hardware would get faster, faster than it would matter, and uh and uh uh uh was not the case.
Sean ParentSo yeah, so so Express got written, rewritten and into Flash, and it never shipped because the you know it took them two years to get to feature parody uh to what they had two years ago, and it w it just was all around a w a worse experience. Um so that got scrapped, so we were very thankful that we didn't take Revel down that that path. So, you know, I had some tentative involvement with Flash during the during those times.
Sean ParentAnd then about the time Flash was almost canceled or about to be canceled, right? For people who don't know, the reason why Flash was cancelled was it just had uh uh an unbelievable stream of security issues. Uh uh it was written as uh as an old Netscape browser plugin, and so it plugged into your browser, and and that was a C API, and so it was running outside of a sandbox, and one of the big reasons why people liked Flash is because it could axe give your website access to your operating system and your operating system capabilities.
Sean ParentUh the problem with that is it gave websites access to your operating system and your operating system capabilities. Um so it became a big uh uh a big security problem, and there was a stream of exploits against it, and they got patched and patched and patched, and that kind of sucked in so many resources it was decided that uh that it was untenable to maintain it. There were a couple efforts to to sandbox it or to rewrite it at the time it would have been into uh asm.js and pinnacle, which were precursors to WASM.
Sean ParentUm both of those rewrites were were internal, but uh we couldn't see a way to to roll them out because being sandboxed, they cut the capabilities off from the the desktop. And so even though you would be able to run some sites in them, the main business that we had for Flash was not around games, which is how most people know uh Flash content, but it was around uh uh a corporate business where corporations developed their in-house applications to be written that way, and all of those required access to the operating system.
Sean ParentAnd there wasn't a way to provide that without opening up a bunch of security holes. So it got killed. Uh this was right at the time when the first software technology lab uh uh uh was in the process of being nuked and there was a point there briefly uh uh where the team got redistributed and I ended up reporting into uh the flash organization, but now it was the flash authoring tool, which was in the middle of a big rewrite on top of HTML5.
Sean ParentAnd so I got to that assigned to that team.
BryceWhat what what's the name of that tool? Is it is it a product these days?
Sean ParentUh yeah, I I think it still is. I don't even know what the name of it is now. For a while it was just called Flash, which was very confusing because I can't imagine why. I can't imagine why. Yeah, yeah, yeah. Uh yeah, so so I got assigned to that team for a little while. I spent like less than a month consulting with them, and this was when I was uh uh we were trying to figure out what was going to happen with uh uh software technology lab. And then I had a uh sabbatical, and so the day before my sabbatical, I got called into a meeting, and they said, Well, we wanted to have this straightened out before you left on sabbatical, and the decision is we're we're distributing the entire team all over the company.
BryceAnd uh That's the word it's my my uh my girlfriend, it keeps every time before vacation, her boss, like the day before vacation, boss schedules a meeting, and then it's always some bad news, and then it just like it ruins the whole thing.
Sean ParentYeah. Yeah, so so my sabbatical was spent looking for another job. And uh yeah, so I came back and resigned.
BryceWas that when you went to Google?
Sean ParentThat was when I went to Google, yeah.
BryceHave we talked about Sean's time again? We have, yeah.
ConorThat's the famous that's the famous uh rotate store. Yeah, that's where rotate comes from.
Sean ParentSo that's the little involvement I had with Flash.
BryceUm I got what I I wanted out of that.
ConorMy my thinking is like uh, you know, it makes the flash renaming to Flash for a different product makes uh Microsoft Teams new Teams not seem so bad because they prefix at least a new.
BryceWe work at NVIDIA. I don't think we can give anybody shit about product naming because ours is pretty bad.
ConorTesla.
BryceWe got we named Tesla first, and then you know Tesla at NVIDIA is the name of a business unit, a product, um, a micro architecture, and uh like a particular uh GPU skew.
ConorWell, in my ivory tower, and then I do my research in, and I wasn't aware of all that.
BryceSo essentially my business unit is called the Tesla business unit. Uh that's what the HBC business unit was called back in the day. Tesla was the name of uh the first NVIDIA um like real compute architecture back in the day.
ConorWell, we've got halfway through the episode, and we've still got 25 minutes until Sean needs to go to his next meeting. So maybe in the last 25 minutes, we might get to a couple more topics. You can give us we are T minus 25 minutes from Sean's next meeting, but T minus one hour and 55 minutes from the New York C meetup being held at the other Adobe Office, which we already have badges to, because we went there a little earlier, as you heard. Uh you're gonna be speaking. Do you want to tell us about uh your talk and uh yeah, what you're gonna be talking about? Sure.
Sean ParentUh I'm gonna be talking about well, this is uh kind of a draft of a talk about a draft of a library about uh half an idea. So we'll see how this goes. Uh so I've been talking with mostly with Eric Niebler about senders and receivers. I looked it up. It's more than eight years we've been having conversations around this. And I I built the the STLab uh concurrency library, which is mentioned in the sender receiver uh proposal as prior work and and some inspiration there.
Sean ParentAnd uh I've had some some issues with sender receivers, and and one conversation that I've had with Eric repeatedly is at the end of the day uh I think senders and receivers are just a way of doing function composition. So basically all that they are are you're doing you're you're composing a bunch of functions, which then you're going to execute, and those functions describe uh uh asynchronous um uh you know or concurrent uh operations and and you're effectively building a program and then running the program.
Sean ParentAnd it's a somewhat functional language that you're that you're building them in. Uh uh but the sender receiver interface doesn't readily expose that. You've got you know uh some complicated concepts that have multiple interface calls on them for setting values and setting exceptions and setting stopped and getting the stop tokens and uh and and it's this very uh broad interface that doesn't look like under the hood uh like just function composition.
Sean ParentAnd and so a couple weeks ago, literally like a day less than two weeks ago, that I had this thought about, well, if you just took a sequence of functions and stuck them in a tuple, uh that you could use a fold expression to execute them flat in sequence where the result of one feeds to the argument of the next. And could make that work. And uh so I wrote a little symmetric code to do that, and then I started to think how do you go from there uh to building up the rest of the capabilities that you would have in sender receivers.
Sean ParentAnd and got pretty far and and and had some insights uh along the way, but the work certainly isn't isn't complete at this point. Uh but it's got some interesting aspects to it in that the the the structure of these things, I call them chains. Uh uh it's it's really just a two-dimensional tuple of tuples under on under the hood. And that's maintained and exposed. The structure of them is very simple but when you want to actually do something with them uh you can wrap an algorithm algorithm around them that trans transforms that structure into a new structure and then executes that new structure.
Sean ParentAnd what that means is is like in senders receivers you would say uh uh then and hand it a lambda and what that is in senders receivers is is is what is it? It's a sender adapter closure. Right? So it's taking a lambda and it's capturing it in a sender so and adapting it to the sender interface and giving you back a new function a function in quotes uh uh uh uh uh which is a sender that accepts a sender and returns a sender.
Sean ParentSo it's this complicated little thing. And in my model then lambda expression is just take the lambda expression and append it to the end of the tuple. Uh uh that that's it. And then all the magic happens when you go to execute this all the transformation to execute it. And and I think there's some some significant power in there. So I've shown that I can do the you know transfer the execution onto onto other threads or other execution contexts and I can inject uh uh uh in the transformation cancellation tokens and error handling um uh you know these functions are free to throw exceptions if they want to throw exceptions all of the handling of that is handled outside and then and injected into the system.
Sean ParentSo that's what my talk is about and that's that's the idea and I kind of build it up from from first principles and I start with the ideas that led to me building the ST Lab concurrency library and what are the problems with the ST Lab concurrency library and why senders receivers are one potential way to to solve that problem. The punchline at the end is is I'm not quite sure where to go from here. I've discovered some things that are broken in std exec and and and the realization that at the end of the day this is just a which we're building it up as a functional language we would like to prove that it's computational computationally complete.
Sean ParentSo I've nerd sniped the uh the the the std exec authors uh uh into trying to figure out how they do that inside of std exec and and trying to fix the issues that I've raised which are mostly around the split operation in uh senders receivers which is a required operation if you want uh if you want to prove you're computationally complete um for Connor you have to be able to implement uh an S combinator and an S combinator repeats a term and that's a that's uh a split.
ConorWe love that the Starling bird we love the starling K is the Kestrel K is the Kestrel S is the Starling. Yep. In this talk it'll be I think Adobe records them. I remember seeing uh or was that when Sean Baxter was at Bloomberg? I mean hopefully this will be recorded um and it'll be on YouTube at some point.
BryceI'm sure at some point Sean will probably give this talk at some other conferences too.
ConorThis is true. This is true yeah but the eager the eager and avid listener will uh will want to see it as soon as possible but um we I mean we were chatting about this was it two nights ago on Tuesday when we were at sugarfish and this time you explained it well I think the same way maybe slightly different details but it made me realize that I actually in a first edition of a different tool that I was working on at work I did something not exactly similar but I was trying to store views in these tuples.
ConorAnd uh like the C20 and 23 uh views. Because at one point I was trying to like lazily build these up and then just like launch them at the end, but that ran into just like massive compile time problems because the larger those things grow without actually you know invoking them, the slower and slower the compile times get. And because I was like automating this stuff I was doing something super terse and then it would explode into this massive thing. So then the alternative I thought was like what if what if I can just store each of these as like you know a slot in a tuple, whatever, with of of some arbitrary length.
ConorAnd it worked up to a certain point, but then I just ran into a mess. I'm not like a crazy template metaprogrammer so I was probably doing some stuff wrong. But I remember like you know trying to store lambdas in tuples because like lambdas have unique signatures and you had to stamp out a bunch of different like are you and then you and then you said you're using fold expressions which I was not doing. Is there like a bunch of tricks that you're using to do this or or it's it's it's not much of a trick.
Sean ParentI mean if not in my slides but if if you um uh uh so if you've got a tuple of functions and you can call uh std apply to basically split those out into an argument pack. And so now now you've got got uh an argument pack of functions and then you can take the uh uh uh uh the arguments that you want to call it with and you you turn that into a you capture that itself into a tuple whatever the arguments are and wrap that into a little struct that's got a pipe operator and that can then then feed the next function and capture the result of it as a pipeable entity.
Sean ParentAnd so now you can just say my initial arguments pipe my arguments pipe you know dot dot dot and you've got a fold expression that will execute the complete sequence of tuples flat.
ConorI mean it is it is a cute trick.
Sean ParentI definitely I definitely think uh that would have been useful in uh in my failed attempt to do that then then I just start I switched to Python and made up on C and you know dynamic interpreted language that's a lot easier folks than just shit stuff on the fly uh well you know I I'll I'll admit when I was starting to to build the code I got lost in the type signatures pretty quickly and I was like like okay I'm just gonna start with make it work with an any right we collapse everything to an any, make it work with that and then then figure it out halfway to Python basically.
BryceHalfway to Python yep yeah it's interesting because um one thing that I and to some degree Connor have been working on recently has been looking at how do we paralyze range pipelines. And one of the challenges with that is that um if we have like a range pipeline that has a filter somewhere inside of there, we got to go find that filter and we got to replace it with some other operation that introduces some tombstone values and then later we remove them and there's all sorts of other optimizations that we got to do or we have to be able to inspect the whole pipeline.
BryceAnd because of the way that range pipelines are built today, which is where they're recursively they're nested um it's a little bit harder to do this um this decomposition and optimization. And you know if instead of being this nested structure if they were um uh represented as like a tuple of of views or a tuple of things that were going to be applied together it would be so much easier things to be composed instead of things already composed.
BryceExactly exactly right yeah because because like the I think maybe the realization that we didn't have was that um like with ranges the the reason that they come to you already composed is because there's you know that there was in the serial world there's really just sort of one way of composing them. But um but actually or sort of naively there's just one way of composing them but actually you might want to do optimizations or transformations or compose them in a different way, you know, uh uh apply some different thing to them.
BryceAnd so representing them in in the uncomposed form um and that gives you a lot more flexibility.
Sean ParentYeah and that's that's what I found is you can you can inject like I said all the all the structure you need. And so instead of in the sender receiver model where you're pulling through a message for what happens if there's an exception and messages for stops and things like that, that interface impacts every single level all the way through the pipeline because it all has to be composed together. If instead you say just give me the structure all of that information can be injected after by just transforming that structure.
Sean ParentAnd and when the structure is flat it's pretty it's it's pretty simple to do and um uh uh since these are all you know it's a it's a tuple of tuple of functions and they can be lambdas but you could also have a type in there which is your filter and so now you can scan through the tuple of tuple and pull out particular types. So if you have additional information you want encoded in there you can encode it in the type system and and and pull that out as part of the transformation.
ConorI wonder too if uh it depends on how it was implemented but like if you have an ability to avoid one of the worst parts of ranges which is the the errors at compile time because I'm even as a ranges expert and you know I'm not Tristan or Eric level uh but you know I've spent quite a bit of time playing around with ranges every once in a while I'm running into my first few errors it's just like this this wall. And it's like it's not wrong. It is technically the type and it's just this nested crazy thing.
ConorYou might run into the same problem but potentially there's an opportunity to like avoid that.
Sean ParentYeah. It's potential at this point the error message that I most frequently get is uh tuple doesn't support the call operator and that really means that some piece of my tuple in my fold expression is gone and it doesn't tell me since it's within the fold expression it's like one of the 20 things you have in this pipeline is bad. Right yeah and and that's um uh that's a pain I've got some thoughts about how to to well there there's there's a couple things.
Sean ParentRight now I'm building things where everything takes you know auto dot dot dot as the args and and which means you're able to build these very generic computational patterns uh but that also means when you actually call it with you know invoke it with 42 and something goes wrong because there's a type mismatch in the path that you're completely lost. And so so one of the things I'm playing with now is is what are the trade-offs between having the developer declare the the the the the interface for the entire construct up front so that as you append each thing you can say okay if I know what the interface is then when I append the first thing I can see well will it take those arguments and then what does it return?
Sean ParentAnd when I append the next thing I can say will it take the thing that's returned from the previous thing and so on. So I can type check the entire path.
BryceYeah it's it kind of I think you make a it's a very interesting observation there and I think the pro to do better you have to not diagnose either when you're folding or once the thing is folded. Because the problem is that the folding operation you end up with this recursive structure and then if something bad happens down deep in the structure then it has to roll up the stack. And even like if you don't explicitly do that, just the way that the compiler diagnostics is are going to work is it's gonna tell you well this failed here and you know and then this is the failure in the the source and then that was in this context and this context in this context and it'll walk up the stack trace.
BryceBut if you've got it as this linear chain of tuples um then you maybe have some other options where you can do some checking before you do the fold where you you just go through each pair and say like do these things, you know, does the first one connect to the second one does the second one connect to the third one and that could I think give you better diagnostics and give you the more of the flat diagnostics that you'd get from uh just if you were writing like straight imperative code.
BryceSo yeah I think that that that has some real um potential there to give you better diagnostics. I don't know whether it will help the other challenge that I think a lot of people have with ranges is um around compilation time um but uh and same same for senders um I don't know that this helps you there per se because ultimately at the end of the day you're still doing the same composition um but I think it may really help with the diagnostics. It's very interesting.
ConorYeah I mean I'll link in the show notes this has nothing to do with C but I saw in a talk by Jose Josephim the creator of Elixir as they have a big pipeline. It's like not even just a library, it's the whole way the whole language works. And they showed this little demo in a Elixir live book I think is what they call it. It's like a Jupiter notebook but they just rebranded it and you build up your little pipe expressions and then if you have a problem they just like in the notebook you can like toggle off each one of the pipes like if you got a functional map or a reduction or whatever.
ConorAnd then like you there's a little hamburger bar and you can slide them around and stuff. So I was watching this and I was like oh my God like when you've got a problem in C with ranges it's just like you know a wall of template mess whereas over in this dynamically typed language they're like well check out this little demo of debug and like you could as the final thing you could pipe it to uh like a debug print or something and then in the notebook it shows you at every stage like what the current you know value. Anyways it was just amazing.
BryceSo I'm not saying we're ever going to get to that but uh there is hope out there uh that you know things can be better uh and uh you know that's uh that's why we have you on the show so we can give you a bunch of work Sean and uh you're gonna go write a C committee paper of course and give us a full reference implementation.
Sean ParentSure and and you know first now that you got me thinking about this idea I'm gonna go write a C interpreter just so we can do this. That'll be a good weekend project I'm sure.
BryceSo I got a great thing for us to close on. So uh so the White House tells us no more C. What do we think?
ConorSo this is Gemini 1.5 talking about this the other day too it's uh C20 concepts is too unsafe for anyone under the age of 18. So uh apologize to our younger listeners out there that uh paying the $20 a month if you're a younger listener please uh hang up now.
BryceBut uh but yeah what what do we what do we make of this?
Sean ParentWe talked about this last time I was on. I'm it it's no surprise that that that this is is coming. For corporations, I think there's going to be some amount of of risk management that has to go on and Adobe's certainly in that boat. My team's on the hook for uh uh developing the roadmap uh the memory safety roadmap for for Adobe and and how how we approach that had an absolutely terrifying meeting with our security team yesterday on this on this very topic. Yeah I mean I think the information coming out of Department of Defense and and the White House is filled with a lot of hyperbole uh but at the base of it it's not wrong.
Sean ParentUh just uh you know in working on this chain library at one point I accidentally wrote uh T instead of decay type T and the result was I captured a reference instead of a value uh even though the code looked like it was fine the type was not and that meant that I had a use after return on my stack and it cost me half a day to debug the thing.
ConorHear that folks the luminary Sean Harry debugging his problem for half a day.
Sean ParentThere's hope for all of us it's too easy to make a mistake like that. And a lot of times uh the wrong code looks better than the right code and that's a problem and this was one of those cases.
BryceThere are some people that are either trying to define a safe subset of C or tools or things to make C safe or who claim that C ⁇ is safe. Do you do you buy the the the the argument that C is fundamentally unsafe and and that there's that there's no hope for it or do you think that people in environments that care about safety can find a way to continue using languages like C it's just a matter of defining the rules and the guidelines um the to make it to define a safe form of C So I think there's like Herb Sutter CPP2 which he states that one of his goals is not provable safety but uh my team's looked at his proposals and we've given him some feedback.
Sean ParentWe actually think he's very close to being able to prove safety. He wouldn't have to compromise much to be able to do that. He doesn't seem interested in it at the moment but maybe that will change with the the current legislation. I think the work that Sean Baxter has been doing is very promising but of course that's one guy on a non-open source project. I hope something comes out of it if nothing more than other people steal ideas from it. We talk a lot about memory safety in the abstract both without a clear definition of memory safety is and losing sight of what the goals of the memory safety are.
Sean ParentAnd and safety properties in general are tools to help prove correctness of code. And you know if you to prove partial correctness of an application you have to you have to demonstrate that it satisfies a a set of safety properties. And memory safety being being one of those but but the goal from a security standpoint is something called a non-interference property which is both a safety and likeness property and the memory safety is just in support of non-interference.
Sean ParentAnd the basic idea with non-interference is that a a uh uh a defect in uh in one piece of your code should not affect another piece of your code. It should limit the the blast radius. So when you're really talking about non-interference properties things like shared pointers become a problem but any shared immutable state becomes a problem. Sharing indices to the same array is another way to share information becomes a problem.
Sean ParentRight? So even if you're outside of the outside of the pointer space. And C doesn't give you any tools to help you build code that satisfies a non-interference property. Even if you you could go through with C and you could say every place where it's undefined behavior, I'm gonna insert a runtime check and ta-da, C is completely safe. Your program will probably never terminate because it will run so slow, but it will be very safe. So at one end that's completely doable and then the next end is is is how much can you how much performance can you get back through optimization knowing that some of these checks are unnecessary and then how do you structure your code to to guarantee that those optimizations kick in and and what are the what are the guidelines for that.
Sean ParentBut then you're still left with a piece of code that looks like a piece of C ⁇ code and and probably needs a redesign. And when they're talking about memory safety it's it's you know 70% of the of the uh exploitable CVEs uh according to Microsoft and Google that they see uh well that leaves another 30% of the problem so so even if we fixed all the memory safety problems we wouldn't have like super bulletproof software you know it's like your your ship's going down it's got three holes in it and you're like well we got a way to patch two of them yeah right?
BryceWell and also if if if everybody's programming memory safe languages then attackers will will it will spur innovation and new new ways of attacking uh software there will always be attacks yeah there will always be attacks so I think eventually the changes have to be you know much deeper and and and and much more radical than just shoring up C.
Sean ParentThat said like a Photoshop alone has 30 million lines of C code and and it's not going away anytime soon.
ConorHow long did you say that uh that flash rewrite took uh you know two years? How many lines was that probably you know like uh I don't know maybe 500,000 tops right so that's like a factor of 30 million carry the I think it's just two so it's like four years is all you need. This is true we have maybe late here in my watch. Be sure to check these show notes either in your podcast app or at adsphepodcast dot com for links to anything we mentioned in today's episode as well as a link to a GitHub discussion where you can leave thoughts, comments, and questions thanks for listening we hope you enjoyed and have a great day line of my podcast line our tagline is chaos with sprinkles of information
In this episode, Conor and Bryce chat with Zach Laine about C++26 Reflection vs CRTP, AI, kids & more. Link to Episode 313 on Website Discuss this episode, leave a comment, or ask a question (on GitHub) Socials ADSP:...
In this episode, Conor and Bryce chat with Zach Laine about the C++26 contracts fiasco. Link to Episode 312 on Website Discuss this episode, leave a comment, or ask a question (on GitHub) Socials ADSP: The Podcast:...
In this episode, Conor and Bryce talk with Zach Laine about his career and the career changes he has made. Link to Episode 311 on Website Discuss this episode, leave a comment, or ask a question (on GitHub) Socials...
In this episode, Conor and Bryce talk about Bryce's next chapter and where he is leaving NVIDIA for. Link to Episode 310 on Website Discuss this episode, leave a comment, or ask a question (on GitHub) Socials ADSP: The...
In this episode, Conor and Ben chat with Jason Turner about default construction in C++. Link to Episode 309 on Website Discuss this episode, leave a comment, or ask a question (on GitHub) Socials ADSP: The Podcast:...