Skip to content
PodSubs
ShowsPeopleGuestsJobsNewsEvents
More
BlogPodCred
Menu
ShowsPeopleGuestsJobsNewsEventsBlogPodCredNetworksSign in
Join nowSign in
  • Shows
  • People
  • Jobs
  • News
  • More
    • Guests
    • Events
    • Blog
    • PodCred
    • Networks
    Join nowSign in

Two's Complement

Two's Complement artwork

Lightning Round

Oct 11, 202643 minAudio
ShareXLinkedInFacebookWhatsAppEmail

Ben gives his house to an AI named after GLaDOS, and Matt makes the compiler build a Z80. A dying USB dock threatens to end it all.

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.

Matt GodboltHey, Ben.

Ben RadyHey Matt.

Matt GodboltWe are in some kind of... catastrophe. Catastrophic situation where my computer keeps crashing, or rather my CalDigit docking station keeps dying with USB. So this may never go out. So I'm talking to you, and then maybe this is the only time this will ever be heard. So what are we going to talk about today?

Ben RadyI think we could do... some discussions of some personal projects that we've been kind of kicking around with Claude. I have two.

Matt GodboltOkay.

Ben RadyIt's almost like, I almost want to feel like we're doing these in like lightning talk format because it's like these.

Matt GodboltOkay, let's do that.

Ben RadyPart of...

Matt GodboltBecause I may disappear at any time.

Ben RadyRight. So we're reducing the scope of each iteration so that, like, if one fails, then we've at least committed the.

Matt GodboltWe've. This is a redundant array of inexpensive.

Ben RadyYes. Podcasts.

Matt GodboltPodcasts, yeah. That has a terrible acronym.

Ben RadyOkay.

Matt GodboltLet's not say that one out loud.

Ben RadyOh.

Matt GodboltDon't think about it.

Ben RadyRight.

Matt GodboltYeah. Okay.

Ben RadyYeah.

Matt GodboltGo. Tell me about one. I've got several on the desk next to me, so you go first, and then we'll take it in turns.

Ben RadyYeah, yeah, yeah. So a few years ago, me and my oldest child, we were exploring our basement, let's just say. And we are like, oh, here's the control panel for the Brink security system that was installed in our house when it was built, you know, 20 years ago, whatever, which is now obviously totally useless because we don't pay for Brink security. However, looking at this control panel, this does not seem as complicated as one might think.

Ben RadyI think these things are just switches, and maybe it's a little more complicated with motion sensors because they require power, but surely we can figure this out.

Matt GodboltOkay.

Ben RadyAnd this was... Yeah.

Matt GodboltSwitches as in like... network switches here, or switches as in literally up and down buttons?

Ben RadyNo, just like... when the door is closed, the circuit is closed. And when the door is open, the circuit is open.

Matt GodboltOh.

Ben RadyRight. And the default state is closed so that you know the system's working.

Matt GodboltIt's...

Ben RadyRight. Like if there's a loop through the circuit.

Matt GodboltOh, oh, I see. Yeah, yeah, yeah. Okay, yeah. Right.

Ben RadyYeah.

Matt GodboltSo an actual switch, except, you know, yeah, right. As you described.

Ben RadyYeah.

Matt GodboltOkay.

Ben RadyYes. And, you know, this was like, obviously there was AI and other tools back then, but it wasn't quite as prevalent. So we did a little digging and we're like, oh okay, yeah, no, we figured this out. It's not that hard. The doors and the windows are just a circuit. It's just a switch. And when it's closed that means that the device is closed, and when it's open that means it's open, and it fails open, so you know the alarm goes off, something is wrong. And then the motion sensors are the same thing but also require 12-volt power.

Matt GodboltOkay.

Ben RadyRight. So if you give them 12-volt power and you let them kind of warm up for a second, they will then close,

Matt GodboltOkay.

Ben Radyindicating that there's no motion. And then if they see motion they will open back up again, the circuit will open. Right. And that is the extent of the part that is wired into the house.

Matt GodboltOkay. And this is... These motion sensors are like the little things you see up in the corner of rooms that are essentially infrared light.

Ben RadyYeah.

Matt GodboltI think it's an infrared light and then a kind of clever...

Ben RadyI think they're infrared detectors. Yeah.

Matt Godboltclever... reflect... yeah, a photo receiver that notices when things move in some way or something, I don't know. I watched a YouTube video that was very impressive and then it's immediately forgotten. But yeah, okay, so...

Ben RadyYeah.

Matt GodboltBut it looks like a switch is what you're saying.

Ben RadyRight, right.

Matt GodboltOther than you power it.

Ben RadyIf you give it 12-volt power, it acts like a switch. It just goes on and off.

Matt GodboltAll right. I have questions about that because if you give it, like... In order to give it 12 volts, it needs to have a zero volts for it to flow through. So where does... are there like two connections to it?

Ben RadyWell, there's additional leads. Yeah, it's not with those things.

Matt GodboltAh, okay.

Ben RadyIt's not just two wires. Actually, also, interestingly.

Matt GodboltAha.

Ben RadyAll of these things use Cat5 cable. It's just that only two of the cables matter for most of them, but the other ones

Matt GodboltAh.

Ben RadyThere's two additional ones that carry the 12-volt power for the things, and I have a feeling there might be other things too.

Matt GodboltIs...

Ben RadyI hope. Yes.

Matt GodboltIs that the same as PoE or is that different again?

Ben RadyI don't think it is PoE.

Matt GodboltNo. Okay. Right. But obviously it uses... it also uses Cat5.

Ben RadyYeah. Like, I think the electricians just wired it with Cat5 because they're like, we're running these cables, might as well use Cat5. Right.

Matt GodboltSo. Right. Anyway. Got it. All right, anyways.

Ben RadyIt's all low power, so who cares? So this is what we did two years ago. And so... Kit was very much like, we need to name this thing GLaDOS from Portal.

Matt GodboltOh. Right.

Ben RadySo we built. We built this whole, we built an Arduino circuit that interacts with all of these switches and replaces the Brink's circuit board that was there. We wired it into a Mac mini that we have that's sitting in the same utility closet. We wrote a little Python app using asyncio that, like, talks to

Matt GodboltOh.

Ben Radythe Arduino over serial connection and serves up a web interface that has, like, the layout of the house and shows all the zones, and yeah, we went in with, like, SVG and mapped out all the zones and where all the windows and doors and all the motion sensors cover and all of that, and there's like an event log and all this stuff, and it was super cool. And we did this as a project, yeah, like two years ago.

Matt GodboltWow.

Ben RadyAnd then, like, it was, I don't know, three or four weeks ago, maybe a couple months ago, it stopped working. And I went and investigated and I'm like, well, obviously I'm not going to do this myself. So step number one in this investigation is get Claude running as like a systemd service that will automatically restart in case I screw something up.

Matt GodboltHa! No! Oh no.

Ben RadySo now I've got Claude running on this machine.

Matt GodboltNo, oh, right, right. Not... Claude running as a systemd service. But Claude setting up a systemd service to keep the thing running. Is that what you were saying?

Ben RadyWell, no, actually it was both. So it was...

Matt GodboltOh.

Ben RadySo I basically wanted to make sure that I could always remote into this thing, even if it rebooted or restarted or anything else went wrong. So I'm like,

Matt GodboltRight.

Ben RadyClaude... And of course, I'm telling Claude to do this, but it's like, yeah, I made a systemd service that runs tmux, that runs Claude.

Matt GodboltAh. With remote control or whatever.

Ben RadyAnd then that has remote control enabled so I can go and connect to it.

Matt GodboltYeah, yeah.

Ben RadyAnd obviously I can SSH into this machine too. It's not like I can only access it with remote control.

Matt GodboltBut now you can be out walking the dog and just bring your phone out and say.

Ben RadyExactly. And I can talk into my phone and be like, hey, Claude, can you make GLaDOS do this thing? And then it'll be like, yeah, sure, fine.

Matt GodboltIt's kind of scarily, you know, how commoditized that has become, so easy. I'm so used to it. And yet, yeah, so many questions, so many flaws. But anyway, carry on with your... And the fact that you called it GLaDOS doesn't really help the whole argument here.

Ben RadyYeah. I was just... and that's, that was going to be the punchline of this whole lightning talk, is I don't know if it's a good idea to have an LLM in charge of a system that was, like, you know, designed to be malevolent and evil and just, you know, torture humanity with experiments.

Matt GodboltOh, I'm sorry. Uh-oh. Yeah.

Ben RadyBut that's what I'm doing. So, okay, fine. But the... But I did this. I'm like, all right, well, what's going wrong? And of course, it just diagnoses the issue and says, oh, the Arduino's gone bad. You need to replace it. And I'm like, okay, fine. I'll flash it. And then it handles, like, updating the firmware. And I'm like, all right. Cool. That was super easy. Let's connect it to the sump pump. So I took a picture of the sump pump label and it's like, oh, yeah, there's an RJ11 connector that you get. I'm going to give you the Amazon link. You can order all these parts. It's actually going to be real simple.

Matt GodboltThe listener can't see that I've just got my mouth wide open. It's just ordering parts. What do they call it? Meat pipe for Claude now?

Ben RadyYes. Yep. I mean, meat proxy. Meat proxy.

Matt GodboltMeat proxy and the credit card.

Ben RadyYeah. And I'm like, yeah, that sounds great.

Matt GodboltYeah.

Ben RadyAnd, you know, again, the sump pump actually just like acts like another on-off switch. It's almost like this was intended to be wired into security systems in the same way. It's like, okay, that makes total sense.

Matt GodboltRight.

Ben RadySo I got to get the simple RJ11 cable, plug it in, snip a couple of wires and wire it into the Arduino. And now I have the sump pump support. I was like, okay, cool, that was great. I've got a UPS, a universal power supply, that's also connected to all these things, it keeps my internet running when the power goes out, and

Matt GodboltI think uninterruptible.

Ben RadyUninterruptible power supply. Did I say interruptible?

Matt GodboltHe interrupted you. No, you said universal. And I couldn't miss the opportunity to interrupt you to tell you that you'd said it wrong.

Ben RadyYou know, it's almost like I could have done that on purpose.

Matt GodboltOn purpose, if only... Our listener knows that we made no effort to organize this ahead of time because...

Ben RadyBut yeah. You would think, well, whatever.

Matt GodboltAnyway, yeah.

Ben RadyYes. So I have this, the UPS, that is the battery backup for the Mac mini, for, you know, the router and the cable modem and everything else, and it's got a USB port on it, and I'm assuming that was for control, and I'm like, so I take a picture of the

Matt GodboltYeah.

Ben Radypower supply and it figures out the model number and it downloads the specs and everything else. It's like, oh yeah, no, you can just plug a USB... you know, USB cable into the back of this thing and then plug that into the Mac mini. And then I've got it from there. And then it's like, yeah, cool. Great. And now I'm monitoring my household power through the UPS through NUT, which is the Linux you know, package that you use to monitor these types of devices. And I've got a new page on.

Matt GodboltOut of interest, is the whole house on the UPS or is it just like critical equipment?

Ben RadyNo.

Matt GodboltYeah. I was going to say, because I had one downstairs until it ran out of power.

Ben RadyIt...

Matt GodboltThe battery, like, died, the lead acid battery in it. And I was like, I only had a computer plugged into it.

Ben RadyYeah.

Matt GodboltAnd even then it would only power the computer for like 30 seconds while it shut down.

Ben RadyRight. Yeah, no.

Matt GodboltBut it did monitor and it would tell me, oh, by the way, there had been a power event, which you know is useful to know.

Ben RadyRight. Yes, yes. And now I've got it sending alerts to me.

Matt GodboltBut.

Ben RadyI mean, I had the alerts before, like the whole burglar alarm system we wired into Pushover, which is a super cool.

Matt GodboltOf course. Oh, yeah, little, like...

Ben RadyNot an ad, but I like Pushover a lot for these kinds of notifications.

Matt GodboltYeah. Yeah. I forgot about that. Yeah.

Ben RadySo Pushover notifications for, like, if the power goes out, it's like, yeah, and it can monitor the battery levels and be like, you know, you've got 30 minutes left. You've got 15 minutes left. Whatever you want. And then I can tell it to remotely shut down the computer to save power so that we can preserve the internet access if we need to, you know, keep the Wi-Fi running, but we don't want to necessarily have the computer running.

Matt GodboltRight.

Ben RadyAnd so all of this is basically just me randomly sending messages to, you know, Claude in the middle of the day being like, yeah, do this and then order this thing and do whatever.

Matt GodboltIt's actually pretty impossible now, I can't think how this could go wrong. You've wired a malevolent AI, you've given it a license by calling it that, and then you've given it

Ben RadyRight.

Matt Godboltaccess to your power, internet, and remote door controls.

Ben RadyRight. Right. And so all it's going to take is for this instance of Claude to accidentally scrape some Portal lore about what GLaDOS is and how it should behave for it to, like...

Matt GodboltIt. It knows.

Ben RadyYeah.

Matt GodboltIt knows already. It's already in the training set, dude. I mean, like, oh yeah, you are...

Ben RadyYep. Yeah.

Matt Godboltyou're in trouble.

Ben RadyYou know. This is... This is what we're...

Matt GodboltIt... Is that? That looks like a...

Ben RadyAnd then the next thing I'm going to do is connect it to my garage.

Matt Godboltautomatic repeating rifle behind you that you've got and some kind of tripod thing with an orange light in the middle?

Ben RadyYeah. Uh huh.

Matt GodboltIs that... Did it tell you to put that together?

Ben RadyYeah, you know, sentry turret, you know, and just wire that directly into the burglar alarm.

Matt GodboltYeah. That's right.

Ben RadyYou know, it's just airsoft. It's fine. You know. It's not going to kill anybody. Yet.

Matt GodboltOh man.

Ben RadyThe laser turrets are next.

Matt GodboltSo where are you going? What's next with this?

Ben RadyYeah. So the next step is I'm going to hook it up to my garage because I want to be able to tell if my garage door is open or closed. And then the next thing after that is that I want to actually be able to.

Matt GodboltYou know, the way that I do that is like this.

Ben RadyRight. Well.

Matt GodboltIt's, yeah, the listener did not see, but I craned my head out the window or towards the window.

Ben RadyYes. Look out the window. We have this nasty habit of leaving our garage door open and then going somewhere. And then we've done this enough to be paranoid about it.

Matt GodboltAh.

Ben RadyAnd so there's this thing of like, did I remember to close the garage door? And then it's like. So step number one is I got a security camera that is rated for cold temperatures because, you know, where I'm in Chicago, and even though it's a garage, it's not an attached garage, I think it's cold. So I got a security camera that is like local network only,

Matt GodboltYeah.

Ben Radyrated for cold temperatures. I'm going to put that in the garage and then I'm going to teach GLaDOS how to do image recognition to tell whether or not the garage door is open or closed because I also want the pictures. But, you know, I could just, and I might still just hook up like a sensor to the garage door to tell whether it's open or closed, but I want to do this the hard way.

Matt GodboltI mean that would seem simpler.

Ben RadyIt is. It's not about simpler. This is about like.

Matt GodboltYeah.

Ben RadyHow much complexity can I throw into this thing by just typing words into a robot and just see what happens.

Matt GodboltYeah.

Ben RadyAnd so that's kind of what I'm doing here.

Matt GodboltAnd the answer so far is pretty much everything.

Ben RadyYeah, turns out you can just throw whatever you want in there.

Matt GodboltYeah. Yeah.

Ben RadySo that's my quick lightning talk on how I'm empowering a malevolent AI to destroy my family.

Matt GodboltI... Yeah. I can't top that, Ben.

Ben RadyWe should have finished with that one.

Matt GodboltThat's kind of it now. I think we're 12 minutes into the recording. Yeah, no, well, I mean, you know what I've been up to recently. Well, I've been doing a whole bunch of things obviously. I've forever got Compiler Explorer on the back burner and I'm trying to find ways to lighten my burden

Ben RadyMm-hmm.

Matt Godboltin terms of, like, the boring, automatable or semi-automatable work, you know, reviewing some pull requests which are almost rote, or, you know, servicing requests like, can you add compiler X, it's just like GCC only slightly different, and there's a lot of things that, again, AI can automate most of that stuff. But the thing that I'm having the most difficulty with on that is

Ben RadyOkay.

Matt Godboltas I think all of us are who are trying to use this in a principled way, is trying to find the right amount to use because it's really, it's really convenient to walk the dog and say, okay Claude, agent, whatever. Yeah, just review these 10 PRs from random people. If they look good to you, merge them in. But then those 10 people are like, did... Did... Did somebody... Look at this properly. Am I...

Ben RadyYeah.

Matt Godboltas a human, am I valued, is my contribution valued, and I want to make them feel like

Ben RadyYeah, yeah.

Matt GodboltI looked at them, and not, I got my robot little lap dog to go and do it for me, even though that's kind of... you know, maybe. So yeah, trying to find the balance there is really difficult for me. I definitely want people to feel valued. But on the other hand, I have very, very finite time, and the pull request list just grows and the number of issues grow and do...

Ben RadyYeah.

Matt GodboltUltimately, most people on the site just want to have the compilers there and have it work and all that. And so I'm going to try and find that thing. That's a difficult multidimensional optimization for me to do personally. Certainly. And making it amenable to other people also using AIs to do some of the work. So I can say to them, look, if you have Claude or Codex or whatever, then just point them at this doc and do it, you know, and it's human readable as well so you could use this as well, but like, realistically speaking, you don't have to babysit four different PRs, I can do that, you know, the machine. So that's one part. The other part is one of my emulators, which I've been going great guns on. I've been doing a whole bunch of work behind the scenes

Matt Godbolttarting up and doing all the to-dos and going through the massive issue backlog of, like, hey, wouldn't it be cool if, for my BBC Micro emulator, which has been a ton of fun. And yeah, most recently I've been updating my... the way that it processes input, so it's running in a web browser and you're playing, like, 1980s absolutely unfair Twitch games that are like... run dead.

Ben RadySu...

Matt GodboltOh, you didn't jump on the right frame.

Ben RadyYeah, right.

Matt GodboltOkay, fine. And I want to be able to, like, replicate those, but you know, there's kind of a lot of things going on between the keyboard, you know, there's the classic Google question, like, what happens when you press a key, is only exacerbated by, you know, when you're running an emulator in a web browser, how...

Ben RadyRight. Right. Yeah.

Matt Godboltfar is it between you pressing the button on the keyboard and it actually taking effect and you then seeing it. So there's like two different latencies there. There's a key press to logic of the game latency, and then there is latency from logic of the game and it presenting to you.

Ben RadyYeah.

Matt GodboltAnd there are two parts to that. There's the physical, like, screen-based view, like, and they're obviously, you know, there's graphics and there's double buffering and there's also post-processing to try and make it look like a telly and all that kind of stuff, as well as, like, you know, just the actual, like, emulation part, which is actually the easiest part of all of this. Then there's also the audio, and a lot of stuff goes off audio cues. And then you've got this really fine line between. If I have a massive two second buffer, then I will never, ever drop and you won't hear a horrible click in the middle of, like, playback, but

Ben RadyRight. Yeah.

Matt Godboltit's two seconds behind, so now you're like, oh, it feels like I'm disconnected.

Ben RadyYeah.

Matt GodboltThere are some things that you can take advantage of here. I haven't... implemented all of these yet, but there's some cool tricks. So one thing you can do is, you know, multi-threading of a sort. The audio workers can live in a separate thread, and then what I used to do is, like, send messages to the audio worker saying, here's another 1024 samples, play these out, and, you know, keep a small ring buffer ahead of you and try and keep this minimal, you know, try and not get so far ahead that it's backed up and not so far behind that it drains, ever, in the sort of time slices that we've got. But

Ben RadyMm-hmm.

Matt Godboltit then occurred to me that that's not how a... I'm gesturing wildly to the desk, which is just out of shot for Ben and definitely out of shot for you, the listener. The BBC Micro on my desk here. That's not how this works. What you do is you send across the bus values to registers that are on a chip. And that chip just keeps making that noise until you tell it not to. And so what I can do is I can now send not the sort of synthesized buffers, but I actually send the commands along with timestamps about when in the virtual stream of events that these happen. And now I synthesize the entire audio stream as if it was, like, a separate component, as indeed it is. It's just a bunch of counters and flip-flops, right? It's all the stupid sound chip is, and a noise chip. And so that means that if you do alt-tab away from the BBC, it no longer goes pop, clack, crack, and, like, break up with the audio. It just keeps making the same noise, just as if you, like,

Matt Godboltleft it plugged in. Now that's not perfect. You know, if you're doing one of these, like, sampled speech things, where, you know, the CPU is running at full blast, just changing the volume up and down as fast as it can to sort of... try and make it like a sample, and then you alt-tab away, obviously, you then actually hear the weird noise that it would make if it wasn't doing that all the time. But for the rest of the time it means you've got this really buttery smooth audio frame that is really tight to current time, and then if it does drop, instead of having a really hideous noise you just carry on with the same, as most of the time you can't tell the difference because, you know, the CPU wasn't in fact changing the audio at that point in time. Now I can't quite do that with the video.

Ben RadyYeah.

Matt GodboltBut what you can do is you can... play a bit of fun and games by running ahead, or allowing the video, the presented frame. And then if you know that you're like two frames ahead, if somebody hits a key or any other external stimulus, you can backdate those.

Ben RadyOh, okay.

Matt GodboltSo you just go back two frames to the state that you kept.

Ben RadyIs this like branch prediction, but for...

Matt GodboltYeah, yeah, yeah, yeah. You predict that nothing... I mean, in this instance, you predict that everything continues the same. But if you discover that it doesn't, then you can go back two frames and go, oh, actually, the Z key was down.

Ben RadyYeah, yeah. Yes, right.

Matt GodboltNow run forward two frames or three frames, now by the time you've caught up.

Ben RadyThat's clever.

Matt GodboltAnd then it's not perfect because you will see those two frames that were, like, wrong, and, you know, Twitch game people will go, oh, whatever, but if you've just missed a jump you'd probably prefer to see one or two frames of the character having fallen off in it, followed by the character then jumping. Looks a bit too good to be true.

Ben RadyYeah.

Matt GodboltI haven't fully implemented that. I have got the rewind. So I can just rewind time and just play back. So that's what I usually do when I miss a jump. And then, but

Ben RadyYeah. I feel like you get that in, like, fighting games and brawling games too, where it's like, but the animations at least. It's like, oh no, actually the user pressed this key and this was blocked.

Matt GodboltThere's a bit.

Ben RadySo you get the first couple of animations of the hit landing, but then it backs up.

Matt GodboltYeah. And definitely in network games where there's a bit of prediction as to what's going on and before it finds out, no, actually, that it just snaps to a new position.

Ben RadyAnd yeah. Yeah.

Matt GodboltSo there's some cool things.

Ben RadyInteresting.

Matt GodboltSo do you have another? That's my five-minute segment over. I've got one more after this, but we can certainly talk.

Ben RadyI got a quick question, actually. I'm kind of...

Matt GodboltAh.

Ben Radyembarrassed that I've never asked you this before, given your affinity for

Matt GodboltOh. Awkward.

Ben Radyfor emulated games and stuff. But I remember from my youth playing games on, you know, the Sega Genesis and the Nintendo and Commodore 64 and all of these other games. And there would be this phenomenon where when the, you know, usually it was like the end fight was getting super intense and the game clearly never expected to have this many sprites on the screen at the same time, the game would slow down. And, you know, eight-year-old me thought this was just the game giving me a break because it's hard to navigate all the little whirly bits on the screen. And it just got a little slower. But you know, obviously now I realize that it's like, no, that loop just took too long and now the game is slowing down.

Ben RadyIs there anything special that you need to do to accommodate that fact in an emulator or does it just naturally happen?

Matt GodboltIt 100% falls out naturally. Yeah.

Ben RadyOkay.

Matt GodboltWhat's typically happening behind the scenes is the game is, you know, processing as much as it can, and then it will wait for the next VBlank before it, like, flips the page. And it's not like modern games where... you're always measuring the time because you may be on a 100 hertz monitor or 120 hertz monitor or, you know, your CPU's faster or slower or whatever, you've got all this variability. So you kind of... there is no "how many frames per second is that". It is just free-running as fast as it can and dealing with the fact that time is variable each time. On these machines it's like, well no, the mains power supply comes in at 50 hertz, the TV runs at 50 hertz, therefore the obvious thing to do is to lock everything to how many frames at 50 hertz, and that's your timing

Ben RadyOkay.

Matt Godboltlooks like constant. And so if you just take slightly more than 50 hertz then now you take two frames and now you're running at 25 frames a second or 12 and a half or whatever it is.

Ben RadyYeah, yeah.

Matt GodboltAnd now suddenly it's a bit chuggy. So I don't have to do anything special for that. Now, there's some arguments that say that maybe if you can, as an emulator writer, if you can detect where the idle at the end, you know, waiting for the next frame is going to be, and assuming the game does nothing other than sit there waiting for an interrupt to come in or something like that, you could actually run the game turbo, turbo speed up to the point, and then sync.

Ben RadyYeah. Yeah.

Matt GodboltAnd now you suddenly don't slow down anymore at the end of those, in those games it runs at the same speed because, you know, your computer is effectively infinitely fast now and it's just like, I get a frame's worth of game in every frame. But then there's so many other things that go wrong when you start doing stuff like that, as you know, all the clever timing for changing colors halfway down the screen as the raster is coming out starts to go

Ben RadyMm-hmm. Right, right.

Matt Godboltwrong. But, you know, yeah. So no, it comes for free if you're emulating authentically at the speed of the computer. But...

Ben RadyYeah.

Matt GodboltYou know, that's also, that's its own, there are layers, levels of accuracy there where you can just say, roughly it's a two megahertz. So, you know, we just do this many instructions on average, or you go, no, no, each cycle of every instruction is actually measured at the correct time. So the bus write happens at the third cycle of the instruction, all that kind of stuff, which is lots of fun.

Ben RadyYeah, okay. Okay, cool. All right. Well, there's my tangent. What do you got next?

Matt GodboltOkay. Oh, I got me. All right. I thought you had another one. I got another one. I mean, it's actually related to this in a way. In fact, it segues in naturally. So I'm off to CppCon next week. Yes. This, in fact, Sunday. Oh, gosh. So our listener now will know where, when we're recording these things and we're about to put another one out. So yeah. Yeah, confusing. I've got a couple of presentations there, but then all focus is on October, where I have a presentation at C++ Under the Sea, where I have to present, and it's announced now, a new version of my Spectrum emulator.

Matt GodboltAnd in fact, I'm wearing my Spectrum. It's a shame we don't record the videos for these. I know. It's just too much of a pain. We'd have to actually make an effort of our appearance. But Ben is wearing a... a, yeah, Chicago Bears cap for everyone there, and I'm

Ben RadyI am indeed. Go Bears.

Matt GodboltAnd I am wearing a ZX Spectrum T-shirt, so that kind of tells you everything you need to know about the pair of us, really. Anyway, I have to update my Spectrum emulator, my C++ Spectrum emulator, because that's what I said I'm going to talk about.

Ben RadyT-shirt?

Matt GodboltExcuse me. And the way that I want to update this is to use some of the latest C++26 tricks. So we've talked, I think, about reflection, and did we talk about reflection before? I'm having a moment of, like, you know, deja vu here.

Ben RadyYeah, we did. And reflecting on it, I believe we did.

Matt GodboltYes. Ha ha! Touché, sir. Excellent. But reflection is all about, you know, statically understanding what the shape of objects look like. And C++ gives us some tools to do that now in C++26, which is fantastic. And at compile time, we can do some magic. But one of the things that we can do with that is that we can take something we found using reflection, say like the field of a class or the enum of an element in an enum, the number of it, yeah, an element in an enumeration, something like that. And we've got some kind of thing, object, it's called a meta info, we get at this thing and then we can kind of turn it into a human readable string, which means, hallelujah, we can finally enumerate all of the enums

Ben RadyYeah. Yes.

Matt Godboltin an enum, and go "case", you know, build in C++ an automatic... turn the case into a string of that, each enum value into the string of it, which, you know, is like the one and only use for reflection.

Ben RadyYeah, yeah. Right.

Matt GodboltThat's not true. Obviously, serialization, deserialization, it's useful to go over all of the elements of a structure, a vector and print out debug information. All that good stuff. But it occurred to me that you can use this for evil as well. And so my talk is about how to take an abstract description of a CPU in its own, like, language, like what I invented, which is essentially a bunch of bit masks that say opcodes matching this bit mask

Matt Godboltneed to do things that look like this. And so the opcodes list itself is, like, you know, 001XXYYY, and where the Xs and Ys stand in for any bit of the value there. But I want to be able to do something with the Xs and Ys.

Ben RadyYeah, cool.

Matt GodboltI can declare what Xs stand for and what Ys stand for.

Ben RadyMm-hmm.

Matt GodboltSo I get up to 26 different, like...

Ben RadyOkay.

Matt Godboltthings I can describe using this format.

Ben RadyYou can't get uppercase and lowercase with that.

Matt GodboltI could probably do that as well. Yeah. But that allows me... And then I can write what the disassembly looks like of that. And I can map the Xs, look at index into this list of things. And this is all, like, in my own language, my own DSL.

Ben RadyOkay.

Matt GodboltAnd, you know, normally that would be the input to something like a Python program that would then churn out a massive, you know, switch statement in C++. It would print it out to stdout, you'd write it to a file, you'd compile it, and then you'd be off to the races. And that's kind of how you build these things.

Ben RadyYeah.

Matt GodboltBut I realized that I can use the two new things, the #embed, which allows me to, like, #include a file as, like, a blob into the code base. So I can do... char, you know, char my CPU description equals, open quotes, or no, no, it's actually open squiggles, and then next line #embed the file, close squiggly quotes, and it's as if you've just put the sequence of, like, 65, comma

Matt Godbolt67, you know, for like A and C, whatever, that block.

Ben RadyYeah.

Matt GodboltAnd what reflection gives me is the ability to run things at compile time in a consteval block that are just like... just do this now. Like, literally, as the compiler is reading through the source code, it hits a consteval block and it's like, oh, I have to run this code now.

Ben RadyOkay.

Matt GodboltAnd I can do things like, hey,

Ben RadyYeah.

Matt Godboltparse that string, break it into the instructions, and now I can build a table of instructions that look like that. And there's some other tricks as well that go with it, in terms of, like, I can do name lookup and stuff like that. But effectively I can build the engine for a Z80 from an abstract description of a Z80, all in the compiler as it's compiling the code the first time around. It takes ages. I'm not going to say. The cool thing about this is it's a very, very, very systematic way of describing a CPU and, like, things like how long each cycle takes. And yeah, of course, I still have to have code that says this is how numbers get added together.

Matt GodboltThis is the ALU. But like, most ALUs have, like, well, here's the eight operations of an ALU. And of course, they are indexed by one of those XXYY or PP or QQ, whatever. You say, like, no, I just want to look up the function, which is, here's a table of the names of... ALU 0 is add, ALU 2 is subtract, whatever. And so it falls out pretty naturally. And in a couple of hundred lines of this... Sorry. A couple of hundred lines of this Z80 description, the entire Z80 with all of its undefined opcodes, all of its multi-byte opcodes, all of its weird edge cases just naturally fall out. And it's...

Matt GodboltBeautiful. I love it.

Ben RadyNice.

Matt GodboltAnd it takes ages to compile, but it is the most efficient Z80 emulator that I have written yet. This is the fourth iteration in the same code base of this, and so I'm excited to present it to people and hopefully blow people's minds about, like, I'm still on the fence about whether this is a good idea. You know, all great ideas like this start out with, like, is this genius or terrible?

Ben RadyYeah. Yeah, so preoccupied whether or not you could, that you shouldn't, that you didn't think about whether you should, right? Yeah.

Matt GodboltAnd I'm like, I'm 50. That's... Yeah, and that's kind of part of the idea of it. You know, and everyone that I've spoken to is excited about reflection because of the actual reflecty bits.

Ben RadyYeah.

Matt GodboltAnd I'm excited because it gives me a new power and a new thing that I can do that I couldn't do before, which is not unrelated to looking at structures. So that's another side project. And yeah, that one has... I'll be honest, I have used AI to help me here.

Ben RadyHmm.

Matt GodboltIt's my idea. I've been through the code myself a number of times. I'm going to have to go through it one more time, but a lot of it was me fleshing out stuff and then saying like, can you just finish this off please, and, like, here's all of the difficult opcodes but I don't want to have to write all of the intermediate ones, can you just fill this in for me, and getting some feedback and refactoring and whatever. So I felt like morally, you know, I think we talked about this before about whether things are fun, I've had a ton of fun discovering this. And I'm still a little bit like. It is mine. It's my idea. I can explain it to you. I know how it's working, but it feels a little bit like.

Ben RadyOkay.

Matt GodboltBut I got my friendly robot intern to do it, so it doesn't feel quite as mine as that. But I'm hoping over the next month, as I research it more and present it to people, it feels more like code that I wrote. But that's going to be an interesting part. And I'm wondering whether or not I should add a section in the talk about this. I think it's going to be the forefront of everyone's mind, is, you know, like programming is as we've discussed, you know, something we love doing and, you know, most of the time, though, we're doing it for a job and certainly in a conference, I'm presenting it in the context of, hey, most of us here are being paid to do this. So, you know.

Ben RadyRight.

Matt GodboltIt's what our employers want us to do. But there is a bit of, like, but I like it. And so I think that's going to be an interesting, hopefully a bit of human interest

Ben RadyYeah, yeah.

Matt Godboltfor it too. What else you got?

Ben RadyOkay.

Matt GodboltWhat else you got? Or what questions or what?

Ben RadyOne more that I could probably talk about as a follow-up to the GLaDOS thing, where it's like, you know, once I was like, all right, I'm going to take a picture of the sump pump and then Claude's going to figure out what it is. I can take a picture of the interruptible power supply and then figure out what it is, is I'm like, oh, well, I could just do this with everything.

Ben RadySo I'm just going to do this with everything. So I started going around my house, taking pictures of all my appliances and the, like, labels on the side of the appliances. And I was like, get all the user manuals for all these things, figure out what maintenance they need, and then tell me when I need to maintain these things. Like, oh, there's like an anode rod that's in your water heater that no one ever remembers to replace, and it's like you need to replace that every two years, and I'll set a reminder and tell you when you need to replace it, it's like, oh great. And I'm slowly building OpenClaw essentially by doing this, but I'm just like, yeah, whatever.

Matt GodboltOh yeah! No, but I think that, yeah. Yeah.

Ben RadyYeah. And I'm just like wandering around my house being like, oh, microwave, dishwasher, refrigerator.

Matt GodboltI... There's a...

Ben RadyWashing machine. Like, yeah, I've never given a second thought to any of these things. And now I suddenly care by proxy.

Matt GodboltYeah, I think that's it. Right. You know, so some of this, you know, people are saying, is AI a benefit? And I'm like, well, it got me excited about a whole bunch of stuff that I'd left lingering for a long time. So maybe for that alone... it seems like maybe an expensive thing to justify that, but you know, I kind of

Ben RadyRight. Yeah.

Matt GodboltI definitely did. I, yeah. Similarly, my OpenClaw equivalent thing is messaging me every day wishing my wife a happy birthday on my behalf for me and reminding... you know, I'm like, no, no, just tell me what's going on in my diary, you don't have to like editorialize that much, but it's convenient and useful and it kind of nags me, hey, you said you'd check in on this friend and I'm like, oh yeah, I did. So you know

Ben RadyYeah.

Matt Godboltit hopefully, you know, helps. Of course I could do this with calendar apps, you could do this with... And ultimately, and I was raging about this on, not Twitter, whatever, Mastodon thing, Bluesky the other day, like,

Ben RadyOkay.

Matt GodboltI came home and I said, the magic wake words to my listening device, which is by a big web search company. And the reason I'm saying these is so it doesn't do it now in the background.

Ben RadyOkay. Right.

Matt GodboltAnd I say, wake up words. Play some music. And it's been working forever. I just come home and say that and it came back and it said, playing, and then I can't quite... I tweeted what it was, but like it played something that wasn't what I said even slightly.

Ben RadyYeah.

Matt GodboltAnd I'm like, what? And I said, no, play some music. And it says, playing the playlist, some music. I don't know. It says something else in between, which is even more crazy. And then the last one was a playlist called some music, which someone has clearly put in just for me.

Ben RadyYeah. Yeah.

Matt GodboltThe third song of which, incidentally, was Rick Astley's Never Gonna Give You Up. So I felt like completely owned that. I listened to it.

Ben RadyYep.

Matt GodboltI was like, this is cool. This is all right, actually. But I'm like, Google, for the love of God, I give you... I'm an unapologetic, well, no, I'm apologetic. I'm sorry. I'm an apologetic Google fanboy. I used to work there. I liked the company, or I like the company. I've stuck with them through thick and thin, and it doesn't make any sense that I do still. But they have all the information about me. They have every photograph I've ever taken. They know every person that's in them that is related to me so that I can kind of send people... but lovely things like this, synergies between these departments. And they have somewhat decent AI. Some of my best friends work for their AI company.

Matt GodboltAnd yet, here I am in a room filled with their sodding devices, and it can't answer a simple question about...

Ben RadyYes.

Matt GodboltAnything.

Ben RadyYeah.

Matt GodboltI mean, like, I want that to work.

Ben RadyYeah.

Matt GodboltWhy does it not just work?

Ben RadyYeah. Why is this so hard?

Matt GodboltIt just... Ah!

Ben RadyWhy is this so hard? Yeah, I used to have a competing device, you know, created by an online bookseller.

Matt GodboltAh. Oh, right.

Ben RadyAnd I, in a fit of rage one day, because it started, like,

Matt GodboltYeah.

Ben Radyasking me all kinds of irrelevant questions and giving me notifications that I couldn't figure out how to turn off. It's like, no, all you guys are going in the trash today. And I just walked around the house, picked them all up and threw them in the trash.

Matt GodboltI...

Ben RadyAnd yeah, that was fun while it was new and kind of interesting and sort of worked.

Matt GodboltYeah, I can see that.

Ben RadyAnd now I'm just like, get the hell out of my house.

Matt GodboltAnd. I'm warming to your thought. I mean, okay, with the massive, massive asterisk of Claude is very much online and outside at the moment.

Ben RadyOkay. Yeah.

Matt GodboltYou're building a lot of the infrastructure inside your house and people have talked about Home Assistant. They replied to me on my tweet and said, you know, have you considered our lord and saviour

Ben RadyYeah, yeah. Yes. I've gone down the rabbit hole of Home Assistant a couple of times now, actually.

Matt GodboltHome Assistant. Right. So I could see that being a cool set of projects.

Ben RadyYeah. Yeah.

Matt GodboltBut yeah, this thing about it is I just want it to work and I don't want to have to tinker with it all of the time. And for the most part, the little devices were that, they just did what I needed them to do, which is very, very little.

Ben RadyOkay.

Matt GodboltMainly, you know, activate music and stop playing music and they integrate well with YouTube Music, which I got forced onto after Google Music, whatever, more things to not like about the company. Yeah, but maybe I should go down that route. I know.

Ben RadyI mean, one of the things, and I'm doing this with all the appliance stuff, is I'm keeping it real dumb. You know, we've talked in this podcast before about the power of files. And I'm just like, everything I'm having Claude do, it's just storing as Markdown files on a server that is, you know, the Mac mini that is connected to, you know, the super powerful malevolent AI, whatever.

Matt GodboltYeah.

Ben RadyI'm sure it'll be fine. But it's all just files. And so like in a future world where it's not Claude, it's some open weight model that I'm running on my own hardware,

Matt GodboltRight.

Ben Radyit works essentially the same.

Matt GodboltAnd. It's how a reasonably sensible personal assistant would have created a directory structure and file structure, and it's mostly well-written.

Ben RadyRight? Yes, yes, exactly. Yep.

Matt GodboltNo, exactly.

Ben RadyYeah.

Matt GodboltThat is a really weird thing, that's the democratization of data that Markdown files represent, right, compared to, like, I know some...

Ben RadyI know. Yeah.

Matt Godboltvendor lock-in.

Ben RadyA Word document.

Matt GodboltNative database file.

Ben RadyI mean, they're... they're

Matt GodboltOh, gee.

Ben RadyOpen now, but, like, you know, there was a period of time where it's like, you couldn't get anything out of there. It was a pain in the butt. So

Matt GodboltYeah, yeah, no, for real.

Ben RadyYeah.

Matt GodboltYeah. All right. I've got one last thing because we're actually remarkably.

Ben RadyAll right.

Matt GodboltDespite us having no idea what we're going to talk about. Knock on wood, my little CalDigit has survived.

Ben RadyDon't knock on the CalDigit.

Matt GodboltI'm not, I am. But yeah, next, just out of shot, is my BBC Master in pieces and my latest proud purchase, which is an oscilloscope. I've long coveted.

Ben RadyOh yeah. Okay. Yeah.

Matt GodboltEveryone else having like an oscilloscope in their background and whatever. And now I have one on my desk. It's so much fun to play with and such, you know, silly things. And I've been looking at stuff like the noise, the capacitors on this because it's very old. A lot of them are dried out. They don't work anymore, but it works well enough. The power is ripply. The TV output, for example, is actually rubbish. If I plug in the RF cable on my, I just get a picture that rolls almost.

Ben RadyMmm.

Matt GodboltAnd it's because... I think either the capacitors are gone or the modulator is dead, and I've got a spare modulator, but I want to prove to myself which one it is first before I, you know, by probing it and, you know.

Ben RadyYeah, yeah.

Matt GodboltBut, you know, we've talked before, when I was away, I went off on how TV signals work. And so I can get to the composite port, which is like not an RF modulator. So it's not up in the hundreds of megahertz. It's just that. It's just a DC signal with wiggles in it. And I can probe that and now I've taught myself to kind of read the output by just, you know, moving around on the thing and kind of there's the beginning of a line, this one's got a bright color in the middle of it and then it's dark after that, you know, that kind of stuff. It kind of feels cool, I feel like I'm in The Matrix. But another thing that I did recently to rubbishify appropriately the emulator, so we're kind of back to the emulator, is I took some very close...

Ben RadyYeah.

Matt Godboltrecordings. I took this microphone, this boom microphone, and put it right up next to the speaker and I played a sequence of tones, I wrote a little program to go through all different sweep up and down through tones, different timings and whatever, and I built essentially a model of how that sounds for real coming out of, like, a... crap two-inch

Ben RadyOkay.

Matt Godboltlittle speaker such as you would have had in, like, a case on an old, you know

Ben RadyOkay. Yeah. Huh.

Matt GodboltAnd it is remarkably accurately awful when I now boot up the emulator by default and it goes, and it sounds like it sounds like lunchtime at school at the computer club when there were, like, a room full of these things that we were all playing with.

Ben RadyOw.

Matt GodboltIt's fantastic. I've got options. I also then tapped to add, like, a... just the other side of all the audio filters but before the speaker itself, so I could get, like, a more authentic... maybe my speaker is knackered, you know, but this is what happens with the literal audio circuitry. And that's when I discovered that there were some capacitors that are probably past their best. So you can kind of go for the, this is what it sounds like outside the computer. This is what it sounds like if you were to have bodged in some headphones at this point.

Ben RadyHa, yeah.

Matt GodboltAnd then this is what it actually sounds like if you assume massless, frictionless, spherical cow, square waves that are square, which is what's actually coming out of the chip.

Ben RadyYeah, yeah.

Matt GodboltAlthough.

Ben RadyRight.

Matt GodboltI plugged the oscilloscope into the actual chip and they're not very square at all. They were very ripply and that's what made me think maybe something else is going on. So there's a whole

Ben RadyOh man, that's super cool.

Matt Godboltline of... But that's been a lot of fun. Yeah, lots of fun here. Again, helped by our robot because I'm not necessarily the best at these kinds of things, but more of, I'm an idiot.

Ben RadyWow.

Matt GodboltWhy is this not working? And it says, oh, are you on AC or DC coupling? And I'm like, oh, I didn't know that was an option. Oh, click. And of course, I could have found out myself. I'm sure if I'd Googled it, it would have been the same.

Ben RadyRight.

Matt GodboltBut nowadays, if you Google it, you're going to get the AI answer first anyway. So I don't know.

Ben RadyRight.

Matt GodboltI don't know. Where are we? What is going on?

Ben RadyYeah.

Matt GodboltI'll tell you where we are. We are 40 minutes into a podcast that was looking like it was either not going to happen.

Ben RadyWe were going to do two lightning talks and then it was going to crash, right?

Matt GodboltOh.

Ben RadyUh-huh. Yeah.

Matt GodboltThat's right. So I guess we should probably pause here and maybe we can continue.

Ben RadyAll right. Yeah. This is a perfectly cromulent podcast.

Matt GodboltWe've got more things. I don't know. I'm just trying to think to myself now. I do have a day job as well, and I run a reasonably successful open source project. Everyone's now thinking, what, do you ever see your family? I don't know what you're saying.

Ben RadyWell, when they walk past in the podcast, you know, that's...

Matt GodboltWhat? That's true. Yeah. Do we have any? I don't know that we did this time. And now I'm wondering how many ears are listening here. Oh, no, I think probably. Yeah, school kicking out time, isn't it? Yeah. Well, friend.

Ben RadyOkay.

Matt GodboltI've enjoyed this. Thank you for letting me talk at 100 miles an hour at you and to hear about your.

Ben RadyYeah, it's good. Yeah, it does. That's how we work.

Matt GodboltGLaDOS thing. Yeah.

Ben RadyThis is good.

Matt GodboltAnd I guess we will catch up next time.

Ben RadyNext time.

Open the transcript file

Hosts and Guests

Nobody is credited on this episode yet.

Credit the people on this episode

Be the first to rate this episode

More episodes

All episodes
  1. Pay Up, Nerds

    Nov 14, 202638 minAudio

    Ben brings a 1976 letter from Bill Gates, and Matt brings the after-effects of last night's pub. The hat gets out of the rabbit, a squirrel is briefly involved, and nobody downloads a computer.

    Credit the people on this episode

  2. Is Programming Still Fun?

    Sep 11, 202644 minAudio

    Ben asks a question that violates Betteridge's law. Matt rediscovers the joy of coding like a caveman on a plane with no WiFi.

    Credit the people on this episode

  3. The Tinfoil House

    Aug 15, 202638 minAudio

    Ben's friend is locked out of their AWS account and Matt's AI has decided he's a hacker. The escape route runs through a cheap computer, a mesh network, and Neal Stephenson.

    Credit the people on this episode

  4. Never Twice the Same Color

    Jul 10, 202644 minAudio

    Matt records from the wrong continent and explains how he taught his computer to be a 1950s television. Ben guesses his way to the secret of the colo(u?)r burst and wins today's podcast.

    Credit the people on this episode

  5. Programming in English

    Jun 14, 202632 minAudio

    Ben sets out to learn Rust by only reading it, while Matt wonders if you can learn to land a plane from a book. Also: is snark a portmanteau?

    Credit the people on this episode