Two's Complement - Are We Remotely Productive?

Episode Date: December 14, 2024

Matt and Ben unpack the mysteries of remote work and programmer productivity, with a side of two's complement philosophy. Featuring unexpected insights, hallway chat nostalgia, and the radical notion ...that writing less code might actually be winning.

Transcript
Discussion (0)
Starting point is 00:00:00 productivity is bad. Hey, Ben. Hey, Matt. Again, we're going to have to come up with a better intro. But it's cliched now. We actually are a caricature of ourselves doing our own intro. Yeah, we can't not do it. If we don't do it, then we're doing a bit.
Starting point is 00:00:35 Whereas if we do it, then we're just introducing the show. I suppose so. Right. I suppose so. Since I've started doing like little cold intros as well, I've then lost the bit where we introduce each other and that kind of stuff. So, you know, maybe if we do mix it up a bit. Anyway. Hello, friend. What are we talking about today? Well, we're talking about, I think we're talking about remote work.
Starting point is 00:00:57 Well, which is apt because on Fridays, that's exactly what we both do, which actually enables this very podcast. Although I did just have a tangent idea oh maybe we should i don't know all right no let's do it right tell me a tangent idea come on everyone this is like this is how planned these are this is like a a five minute pre-tangent to the remote work episode how about that do it I believe that it's, I believe, you know, software engineer estimates time. Shocker. Oh boy. Two hours later,
Starting point is 00:01:29 we're still talking about this. I thought it could actually, this like just popped into my head just as I was, you know, we were starting up the show here, is we could do a, like 10 minutes on. Now it's 10 minutes.
Starting point is 00:01:44 On five minutes on two's complement the data storage mechanism not the podcast like you mean two's complement the yeah how how you store numbers yeah right it's like when you're storing numbers in binary like you can use two's complement storage to do that. And why would one do that, right? Why would one do anything but two's complement? Right. Well, that's the point. Yes. So I think if you like sit down and you like sort of teach like a sixth grader binary,
Starting point is 00:02:14 right, it becomes fairly easy to understand. And you're just using, you know, normal integer counting numbers. And you're like, all right, well, this is the one's place. This is the two's place. This is the four's place. And you add all these things up, right? And then you're like, and OK, so computers can only store so many bits. Maybe you've heard of an 8-bit computer.
Starting point is 00:02:35 Maybe you've heard of a 16-bit computer. They can only perform operations on so many bits, right? So you can see how it would be pretty easy to just store regular old integer numbers in this thing and have the computer operate on them and then you might ask that sixth grader well okay but what about negative numbers and the first thing that they're probably going to say is well i guess you could use one of the bytes or one of the bits, I'm sorry, to indicate whether the number is negative or not. And you're like, OK, cool. Yeah, that works.
Starting point is 00:03:09 It's a fairly obvious thing. It's how we do it in decimal. After all, we either draw a little minus in front or we don't. And that's kind of our one bit of sign. Yeah, it makes perfect sense. But yeah, we're done here. End of five minute. End of five minute thing.
Starting point is 00:03:22 And then you say, OK, well, what happens? So that's true. and you can do that. like writing minus zero right like the negative zero and you're like well i guess that's i i wouldn't write that down would you write that down i wouldn't so let's just not write it down right let's just not write it down let's just all agree that setting the sign bit to one and having all of the other bits to zero is just a dumb thing don't do that it's just a dumb thing but then but then you could see like but okay the computers computers don't like it when we waste things they they don't like that they want to try to use everything one 256th of all the possible representable numbers in an 8-bit thing is is just a don't
Starting point is 00:04:23 use me i mean it could be a what about nan or you know null or empty you know we could use it you could use it for something like that but another way to devil's advocate this for what is yes yes it's like we can do it and it will work but there is a better way and that better way is called two's compliment no okay yeah It's called two's complement. Do-do-do-do-do-do-do-do-do. No, okay, yeah. And in that world, we use that to just represent a completely different number. Mm-hmm. I actually don't remember which side of the negative chain that is.
Starting point is 00:04:59 Do you remember what it is? Well, negate and add one is kind of like the way that i internalize it but it closes the gap between uh zero and minus one in terms of the number of the bit pattern representation um which to me is the other thing that makes um two's complement numbers really elegant it is that most of the circuitry dealing with numbers doesn't need to know if it's signed or unsigned because it just works it works the same way whereas if you treat the sign bit separately you now actually have to encode the rules about some of the things that can happen with negative and positive numbers so it is a really clever trick, and you'll be hard pushed to find a computer that doesn't use
Starting point is 00:05:48 two's complement to represent its numbers. But until very, very recently, the C and C++ standards required that, or not required, the C and C++ had made no assumptions about the representation of numbers and so certain things were defined but not defined were left as undefined behavior you know you couldn't rely on for example adding one to the highest possible number to get it to wrap around to negative whatever okay yeah because and and you know that's usually a good thing because like nobody really wants that to happen right if you add let's talk in fact about the the two's complementing aspect of this here is like you know we have this strange now lopsided number where the highest number we can represent with say eight bits two's complement is 127 but the lowest is minus 128 which is kind of displeasingly asymmetric right and that also
Starting point is 00:06:44 means you can't just unary negate any number and get another number because it's if i have minus 128 and i get the negative of it like oh whoops can't represent 128 anymore so there are some weird edge cases as well we've kind of pushed them around rather than at the zero point they're now at the extents and so it's kind of reasonable that if you added one to 127 and you suddenly got minus 128 you probably didn't really mean to do that you didn't want that to happen and so it's left this undefined behavior and so compilers can usually optimize around that and say look you're not we weren't expecting you to do this therefore i'm not required to do it this way for example um it may be that you use a bigger
Starting point is 00:07:26 representation than an 8-bit value when you're using a signed 8-bit value and that means that the carry rules don't work the same way but it's also not supposed to happen so the compiler might be able to use a 32-bit register instead of an 8-bit like shift and rad and shift and add all the time things like this but very recently um the the they gave up on pretending that computers aren't two's complement. And they actually accept that all practical computers these days are, in fact, two's complement. And I forget exactly the ramifications of this. Those who know me well know that I don't really participate much in the C++ standard-y type stuff. But that one just came up on my radar.
Starting point is 00:08:02 So I apologize for not having the – especially when you just dropped this on us at the beginning of this podcast i haven't researched it in any meaningful way and i have a very loud mechanical keyboard so i can't even google it while we're talking well i also have a loud mechanical keyboard and nothing prevents me from doing that short of me having to edit out the cracks in a minute but no pass filter but no what an awesome idea yeah the the idea that uh yeah we've we've named our our podcast after a very i think a neat trick it is a neat trick it's very elegant yeah um and there's just something abhorrent to me as a programmer about having any sort of mechanism that just allows for nonsensical values by its structure right like if i can ever find something where it's like those types of problems
Starting point is 00:08:55 just aren't possible that is always going to be a better solution and this does that very well absolutely correct by construction is the sort of way that I've always sort of internalized that. Yeah, yeah. That's the phrase people use. I will note that in the original Knuth book, so The Art of Computer Programming, all the various volumes, the mix architecture. So Knuth is just such a legend for me for two reasons. reasons one he wrote like the book or the books on all algorithms which are like the most um abstract things like how to sort numbers all the hundreds of ways you can sort numbers very abstractly but then he wrapped around on the you know talking of numbers that wrap around he wraps around to the exact other side where he then implements them in assembly code in a computer that doesn't exist that he made up so
Starting point is 00:09:45 that he can demonstrate the the purity of his algorithms using this invented machine the mix nowadays they use there's a risk-based one that has you know m mix or something like that but the one i remember growing up as a kid oh gosh uh reading um was the mix one and the amusing thing about that is and i and forgive my readers, listeners, whoever they are, will hopefully forgive me if I get this a bit wrong. It is a sign bit based computer that is decimal. It stores numbers decimally with a sign bit. So you do in fact have plus and minus zero. And then to your point about waste, Knuth goes as far as micro-optimizing his own made up instruction set for a computer that
Starting point is 00:10:33 doesn't exist to implement algorithms that are like all about the big O notation and not about the constant facts, but he optimizes them anyway because he's Knuth. and he starts using the sign bit to essentially encode a boolean flag because obviously these these numbers these values in here can also be pointers and it doesn't make sense to have a negative pointer so he just uses like the the decimal part as the pointer address and then you can also for free get this one bit flag and so some of his algorithms will like stuff things in that one extra bit so it's not wasted in those instance you know a null pointer with the bit clear is different from a null pointer with the bit set because it might mean null but red or null but black in a red black black tree things like that and just now you've, sorry, you've lit the litmus paper under me and I'm going now.
Starting point is 00:11:27 A good friend of mine has just put together a proposal for the C++ committee about canonifying, reserving certain bits in pointers. Many things, you know, you have a pointer, it points to an address in memory. The things you point to have to be aligned at certain um spaces so you know if you have a double precision number that's an eight byte quantity on almost any hardware you have to have it at an eight byte address what that means is every pointer has wasted bits at the bottom which always have to be zero because it has to be in a multiple of eight right there's some if you can just mask those two bits out you can access it as a pointer but if you mask them in
Starting point is 00:12:06 then you've got some bits at the bottom you've got two or three bits worth of like extra information and so so she's put together a proposal which says like can we canonify this because strictly by the book you're not allowed to do those kinds of things because once you start manipulating a pointer like it's an integer the compiler can lose track internally that it points to a valid particular object and whatever but she's made it so that's okay um so yeah sometimes if you do have redundant representation that's wasted bits you can find another use for them well someone will find a use for someone will find you whether that's good or bad i don't know but no hana uses it in a really smart way in fact we had her on the podcast ah we did yes so hana is behind that uh that uh proposal and very smart it is too and it's definitely something i'll be
Starting point is 00:12:54 looking to use myself you know sneaking bits in anyway that was not five minutes no it was not but we can talk about remote work now and then we can talk about remote work so uh new needle scratch yeah tell me about how remote works works for you i well okay uh the i think the main thing for me is um remote work is a trade-off between collaboration and productivity, essentially. I currently am working with people who are either in California or New York, despite the fact that we have a Chicago office. And that's where you are. Yes, I am a Chicago. You can't pick it up from the accent.
Starting point is 00:13:45 We are Chicago ands? Chicago, what's the multiple? Anyway. So I commute into our Chicago office a few days a week, mostly to see my friends. That's the main reason that I do it. Because, you know, the people that I work with are actually in California, New York, and I'm going to be talking to them over some sort of, you know, Slack or video call or something like that, no matter where I am. So, you know, regardless of where I am actually physically, It's the same medium. But there is a lot to be said. And I know
Starting point is 00:14:29 that people have made this complaint before, and this was obviously true for a lot of folks in COVID, but it's even still true for folks that sort of choose to have a fully remote, you know, they either work for companies that are fully remote or they have roles that are fully remote. Some amount of face-to-face interaction is, I think for most of the people that I've talked about this with, some amount of face-to-face interaction is really important. Because it's hard to develop those relationships when you are talking to everyone over a video chat. And you can do it, and lots of people do do it but it's harder um is is a refrain that i've heard a few times it was it was interesting i was discussing with a friend the other day about um how you can keep in touch with friends from like home you know we've moved i've moved away 4 000 miles away from most of
Starting point is 00:15:23 you know my my friends when I was growing up. And a way that you can keep in touch with friends is playing video games where you can actually now talk to people in real time. And I was regaling them in the pub the other day with the stories in the late 90s where, for whatever reason, I wasn't leaving the house very much. And there's all sorts of things going on in my life. But I was playing everquest and i have now made you know real life friends over what was purely a text-based thing and to this day you know i still talk to them and yes you can build a relationship using text medium using face-to-face medium like this but it's harder and it only really happens well under like uh i i think under either duress or a really concentrated on both sides thing where you both work at it to build that thing because
Starting point is 00:16:13 unfortunately evolution is kind of against us right you know we have picked up on so many subtle cues about how humans interact how you know and and for those folks obviously i'm talking about you know sort of very neurotypical things here but like you know everyone there's there are different degrees of this that you can pick up on but like for a first approximation just being in a room with someone tells you a lot about how they are and you can you can learn about them so much more naturally i don't i don't know what the right way i'm searching for the right words but yeah so it's just a higher bandwidth interaction i suppose that's it yeah um i think the other thing about it is is that when you're remote there are very few accidental interactions yeah right everything has to be really intentional
Starting point is 00:16:55 doesn't it you have to like schedule a coffee chat or whatever rather than like bump into someone as you're passing in the hallway to the bathroom even right you know even at that level yeah how many times have you had like an all company meeting and you get there a couple minutes early and you just sit down next to a random person and you start talking to them, right? And maybe you know them a little bit, maybe you know them well,
Starting point is 00:17:15 but like that kind of interaction doesn't happen when everyone joins the all company Google Meet. Like you're not chatting in the meet in front of everybody else, right? Like that's not going to work. So like of accidental things, I think, can play a big part. But the actual act of programming, like writing code, I am increasingly... And I think COVID was really the thing that tipped the scales for me here because I was forced to create such a productive home setup that is so well optimized that there's no question to me that I'm a more productive programmer when I'm staying at home. Even if you were to take out the commute time, which isn't really a fair thing anyway. But even if you were, I think
Starting point is 00:18:05 I'm more productive. I definitely agree with that. Although I don't agree with the having built myself a productive environment. Because if you could see the camera right now, or down from here, it is a catastrophe where I am. But I meant to do that, fix that today. I did not. Yeah, my the main person in my life who pointed out how important it is to go into an office is, in fact, my wife, who obviously during COVID was forced to suffer the full time with with the husband that she was, you know, very we have a great relationship. But I think all of us suffered from being in the pockets of each other for for a while. But she's like, you need you need it. You need to go and see other people. And she was right and i i'd like to pride myself on being you know rational logical not really
Starting point is 00:18:50 whims driven by the sort of more animalistic whims of our reptilian brain but it's but she's right i absolutely needed it and uh yeah it's yeah i agree but but in terms of focus time you know obviously we we kind of build our own focus time in the office with, you know, headphones, we, we, or, or by, you know, trying to find a sort of space away from, from the general thoroughfares to kind of get some stuff done. But yeah, you kind of, that's the default situation at home. Dog barking, notwithstanding kind of levels of things. And yeah, but, and the very lack of those
Starting point is 00:19:25 interactions at home the lack of the uh non-intentional interactions is actually the source of focus like i can get up and i can make a cup of tea and i'm still thinking about the problem that i'm working on while i'm waiting for the kettle to boil. Whereas probably more healthily in a, it opens in an office. I'm, I'm talking to somebody who's also waiting for whatever, for the coffee machine or whatever. Um, and maybe that break is actually what I do need, but focus wise, you know, it's, it's true. Yeah. You, you definitely don't have the rubber duck effect when you're at home where, you know, you, you're working on some hard problem and you're at home where you know you you're working on some hard problem and you stand up in you know a equal mix of frustration and need for coffee or or some
Starting point is 00:20:14 other thing it's like well i guess now's the time i need to go and get a snack or whatever yeah and then you run into somebody who you, will at least understand your problem. Right. And you wind up explaining it to them. Right. Yeah. And then you solve it because you're like, oh, wait. Or they just make some astute observation that's like to them, blindingly obvious, but to you has been stopping you from getting progress for like the last.
Starting point is 00:20:40 Oh, I don't know. You could do that. Oh, of course. That's the solution. Yeah. Yeah. Yeah. And that's hard to yeah yeah yeah yeah and that
Starting point is 00:20:45 that's hard to recapture as you say remotely i mean if you've got you know as as you well know i'm very well versed at just puking out my thought process into slack into a long thread of things and hope that that sometimes brings people along for the ride in terms of what i'm thinking or gives them people come in and say why are you doing doing that? That's stupid. But again, it requires intentionality. Yeah. And so the plot twist of this whole thing, I think, is that you can make the argument, and I enjoy remote work in it, and I do feel very productive when I do it, and I do it because I'm productive. But you can make the argument that productivity, in its very purest sense for programmers is bad.
Starting point is 00:21:28 Oh. And the reason I say that is because I have had many times in my life, and I think that this is more common when I'm remote, when I'm working by myself, when I'm, you know, I got my headphones on or whatever, and I'm just in the zone and I'm programming, where you are creating code. And as we've talked about before, code is a liability. Code is not good. We're trying to solve problems, not make a bunch of code that we need to maintain and test and deploy and debug and all the other things. And there are many times when the right thing to do is not just puke out a bunch of code as efficiently and productively as you can, but to take a step back and to maybe talk to a few coworkers and be like, do I even need to be solving this problem at all?
Starting point is 00:22:16 That, my friend, is absolutely spot on. I mean, yeah. in the in the throes of covid there is at least one reasonably large chunky piece of code that i'm very proud of and is used um but ultimately is now being phased out because really was over complicated could be replaced with something a bit more straightforward was part of a grander vision that didn't come to being and now ultimately i and i it ultimately yeah shouldn't should perhaps should not have ever been written. And it served a purpose. It kept me amused for a few months while I was sat rocking slowly backwards and forwards in this very chair.
Starting point is 00:22:57 But no, that's a really interesting observation. Unfortunately, though, as programmers, we love that state. We love doing that. And we love that thing. As we've discussed discussed before the whole flow and all that good stuff so it is hard to to um it's hard to give that up and say no i should go and talk to someone who will talk me out of writing this wonderful lock free doodad or this whatever you know thing because i say like well why don't we just write a file right the disc yes do you really need this fancy thing and i mean a lot of the time that is a very productive and good state to be in but it is not strictly true that it is always good
Starting point is 00:23:32 yeah at the exclusion of interacting with other people double checking your ideas making sure that you're doing things that actually need to be done and making sure that you're doing them in a reasonable way and not just like going all full mad scientist and being like right or your 10x developer and then you've got 10x as much code that no one else understands or has seen and doesn't even need and you're like as you say it's a liability now that's a really interesting observation yeah yeah well that seems like what a two-tone kind of uh podcast could split this in half and do it in two parts. I don't know. I'm not skilled enough an editor for that,
Starting point is 00:24:10 so I'm afraid everyone's just going to end up with it pretty much raw. This is going to be the peanut butter and pickle sandwich of Two's Compliment podcasts. That doesn't sound too bad. It's disgusting. I don't know why anyone would eat that, but we're just going to take two things. Actually, what this is like do you ever see the movie from dust till dawn oh my gosh i actually think i've seen that movie yeah it's the vampire one right well
Starting point is 00:24:33 the second half is vampires the first half is a bank heist movie oh yeah that's oh yeah i just remember it as vampires but yeah now you say that i'm like oh yeah it was like yeah it's like a cut and shut uh yeah i don't even know if that translates across the pond uh actually i'm not sure i do know what that means it's where you've two cars you've had two cars that have been involved in an accident and they're cut in half and the good halves are then welded together to make like a good one good car out of the two no no no yeah like you never heard that before two ford focuses have been once been smashed in the front once been smashed in the back so you just cut them in half and stick them together and you sell it as a as a as a good car now only the british could be so unscrupulous as to do
Starting point is 00:25:14 something like that surprises me but you know whatever uh no so it's like from dust dust your dawn yeah yeah two two-tone thing. Yeah, yeah, yeah. The first half of this podcast was a bank heist. In the second half, we talked about remote work. That's right. Yeah. Awesome. Well, to that effect, I think we're pretty much done for this episode. And so I will speak to you on the next one.
Starting point is 00:25:39 Yep, next time you've been listening to two's compliment a programming podcast by ben rady and matt godbobs find the show transcript and notes at www.twoscomplement.org contact us on mastodon we are at twos compliment at hackyderm.io Our theme music is by Inverse Phase.

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