Switch Statement

041: Pray, Mr. Babbage

August 18, 2023 Jon Bedard
Switch Statement
041: Pray, Mr. Babbage
Transcript
Matt:

Hello everyone And welcome to the switch statement podcast It's a podcast for investigations into miscellaneous tech topics

This is an oldie but a goodie from the archives where we discuss Charles Babbage's Difference Engine.

audio:

All right. Welcome back, Matt. How are you? Again, I'm pretty good. Awesome. It's funny because, all right, no, go for it. Okay. Okay. Um, so I wanted to talk about something today that it's a completely random topic in computer science adjacent, I would say, and it's a historical topic, but I find this completely fascinating. Um, so I hope you do as well. Uh, I wanted to talk about the Difference Engine. Ooh, okay. So this was an invention slash mechanical device created by a dude by the name of Charles Babbage. Uh, in the 1820s, and I'm going to be referring to my notes a lot. Cause this, this is just a lot of information dense. Yeah. So there was a couple of things that I did not know about the difference engine. I think if you're in computer science, you've heard of the difference engine. It's, it's a very early precursor to like modern computers. Uh, but I didn't know, I didn't know what the difference engine was for. And if I'm being honest, I feel like I still don't even know. Was it programmable? So it was programmable in the, the inputs were, were programmable, which I guess is not exactly programmable. And I'm glad you asked that question. Cause there is another thing that will come up as part of this discussion, uh, which I don't want to spoil it yet. Yes. Um, but anyway, the difference engine, the reason it's called the difference engine is because it uses the method of finite differences, which I don't know. I don't know exactly what that means. I think what it means is like, if you have some. Okay. Continuous function, like an integral or something, or like a, like sign or something, you can often represent it as like a polynomial or like a system of equations. Like, you know, sign can be represented as like, uh, X minus X cubed over 3 factorial plus X to the 5th over 5 factorial minus X. So it's like this, it's a, it's a infinite sequence. But if, but if you calculate the first like nine terms of it, then you get like a very close approximation. Right. Um, and I think that this is an example, first of all, finite differences, that equation that I just gave for sine, that, um, you know, infinite sum is an example of using finite differences to calculate like a continuous function. Right. And this is what the difference engine was good at. Um, and I think that, you know, during the time that the difference engine was conceived and developed, uh, you know, there was some very important, uh, math for like calculating, uh, navigational, um, you know, like if you're out at sea, like being able to calculate where you are based on whatever variables you have, yeah, at your disposal and like, um, And so this, there would be some infinite series that they would be, they would have to describe the situation and then they could use the difference engine to like precisely calculate the, exactly, or an estimate for that. And it may not have been an infinite series. It might've just been like a complex polynomial that the difference engine could take polynomials of the form where. You know, you have a bunch of terms with coefficients and powers and you plug all that in and it will compute the result. Um, so I wanted to give some stats about the Difference Engine, the final Difference Engine 2, which there was also a Difference Engine 1, Difference Engine 2 is 8, 000 parts, it weighs 5 tons, and it's 11 feet long on the longest dimension. And I was trying to estimate how like tall it is. It looks like it's about six, maybe five or six feet tall. So it's huge. It's like an enormous thing. Um, and as you crank it, which by the way, cranking was extremely difficult because you're turning like hundreds of gears, maybe thousands. I don't know. I guess it's 8, 000 parts. So, uh, so in order to be a programmer, you need to be like a real beefy. Yeah, exactly. Uh, But, uh, basically in order to achieve one crank of the machine, you actually had to crank it four times because they had to add all these additional gears for like mechanical advantage and stuff, right? The machine produces printed output, which I did not realize. I thought that was cool. I watched a video. There's like a very cool printing mechanism that like it prints the output onto this. Uh, look, it basically look like plaster of Paris so that you could then like. You know, put ink in it and press it against paper and produce tons of copies or whatever. That's amazing. Yeah, it was crazy. It looked like this extremely complex mechanism just for printing. And then obviously, you know, the difference engine itself is this like amazingly complicated, like system of gears and stuff. Another thing that I thought was very interesting was jamming was actually a form of error detection. Like there was a couple of cases where it would not be able to find A value, like, I guess there would be a value in between two integers or something. Um, and what it would do is a gear would be, it would turn halfway and then it would jam. Like the machine was like designed to jam in order to tell you that you're, you know, you're, so there was something wrong with your like initial input values, which I found super interesting. It's like kind of early mechanical error detection. That's, that's kind of amazing. Like, I guess that makes sense. Like you got to tell, you communicate somehow and you know, they didn't have like error consoles, I guess. Yeah. Yeah. So I thought that was, I thought that was super interesting. Um, I also wrote down, this is like a total tangent, but I also wrote down the earliest, uh, mechanical calculator because the difference engine is considered to be a mechanical calculator, the earliest mechanical calculator. Is thought to be this thing called the Antikythera mechanism. Oh, yes, yes. Which is amazing. If you've never heard of the Antikythera mechanism, like Google it. It's, it's amazing. It was designed, they think it was created during, uh, the Hellenistic period, which is 323 to 31 BC. Yeah. Didn't they find it on the, like, the bottom of the ocean or something, like in the Mediterranean or something? Yeah, you're right. You're right. It was, it was for navigation. So they're, they're assuming, you know, it was on a ship because that's where it would be and the ship sunk. So they found it at the bottom of the ocean and it was a very incomplete thing. Okay, so apparently it didn't work very well. Well, who knows? Maybe it worked really well and then pirates wanted to take it or something. Right. All right. But anyway, back to the difference engine. So the project is actually considered this massive failure historically, because, you know, Babbage designed the thing and he was like, let me build this. The government gave him about 17, 000 pounds. This was England, uh, which is about 2 million today. And the machine was never actually finished. Uh, there was a lot of issues with like, you know, they couldn't just the technology to like create parts at the time. You know, this machine required all these very finely tuned parts. Now, this was Difference Engine 1 or Difference Engine 2? Like, that's unclear to me. Like, so Difference Engine 1, I think is the one that he spent the most time building and he had this contract with the government to like figure it out. This is another issue with the project is Babbage could not focus. It seems he was constantly thinking of new things. You know, he, he conceived of Difference Engine 2, like while he was working on Difference Engine 1. So I think a part of the reason the project sort of flopped is because Babbage himself was, uh, you know, it just seems like he was a little bit whimsical. Yeah, um, but yeah, he did finish a chunk of Difference Engine 1. It's a piece consisting of about 2, 000 parts and it was assembled in 1832. And apparently it still works to this day, and it's it works flawlessly. So, so it's not, it wasn't any shortage of, like, actually being able to do it. It was just, uh, you know, other focus and, you know, probably not enough. Capital or I don't know, but, but the fact of the matter is he, he was able to build a pretty sizable chunk of the thing that worked perfectly. What was this made out of? Did they have steel at the time? Uh, that I don't know. They built one in more modern times and that one is made out of like very nice materials, like steel and brass and stuff. I think that's the one I've seen, which is probably what I'm, it's probably like. Coloring my image of what this, the original one looks like. There was also one that was built where they intentionally used the technology and materials that would have been available in Babbage's time. And, and they were, they were able to do it. Um, so, so yeah, again, that's just more proof that like his designs were sound, you know, the designs that he came up with were sound, although. Just a, just a super interesting tidbit about his design. Apparently there was flaws in his design. Like they've, you know, they still have his designs to this day. So they've, they went over them to, in order to create these modern day difference engines, there were flaws. They think Babbage introduced those flaws in the designs in case they were stolen, which I just thought was really interesting. Really? Yeah. So he, he knew of a couple of like targeted flaws. And he would have to just unflaw that one little section when he was building it himself. Yes. So he kind of had his own, you know, little code in, in the designs themselves. Yeah. DRM for the difference. Exactly. Um, all right. So that actually transitions nicely into this other concept. I mentioned how Babbage was, you know, sort of famously whimsical. You know, he was, he was a. Serial inventor, just constantly coming up with amazing, amazing ideas. He came up with this thing called the analytic engine. Right, right, right. Which, yeah. Difference engine 3. 0. Exactly. So this goes, this goes a step. Actually, saying a step is kind of an understatement. This goes far beyond the difference engines. A quantum leap. Exactly, a quantum leap. This thing originated the concept of a digital programmable computer. Like it's, it's commonly credited, you know, his initial designs and his initial conception of it, it's commonly credited with kind of originating that notion. So, I mean, this is huge. Now, when you say digital, what do you mean by that? Like ones and zeros, uh, and being able to compute, you know, use math basically. Um, and also have like some discrete output or an output that's represented by like. A series of digits or something. Now, this is, this is still though made with the same thing where it's just a bunch of gears and stuff like that. Yes. So this was a physical device, but why doesn't that make it like, cause I feel like I think of two, there's the two things there's digital and there's analog, right? So it was like, can it be analog and digital simultaneously? I guess that's what it sounds like. You know, it's, that's an interesting point. I think it was digital because it dealt. Purely with finite, like, like digits, like integer values. I mean, it could represent decimals, but it would always be representing decimals with, with integers, basically. So I think that's where the digital term. That's its own massive topic in computer science. It's like crazy. He must've had a floating point representation of numbers. Yeah. He, he, I don't know if he pioneered a lot of this stuff, but this thing had a lot of like. Extremely interesting, you know, software engineering concepts built into it. So the analytic engine had flow control. It had this notion of storage where it can store values and then continue computing based on those values. Uh, it had a notion of procedures. If you look at the Wikipedia page, someone came up with like a language where you could actually write code that could be like directly translated to something the analytic engine could be, could use. And they like wrote the Fibonacci sequence in like. Analytic engine code. It's, it's, it's totally amazing. Um, and I thought this was an interesting quote. Babbage is also kind of a goldmine for quotes, um, in case people are interested in that sort of thing. But he has a quote, and this is referring to the machine being able to use its own output. He referred to that as the engine eating its own tail, which I thought was pretty cool. Oh, yeah. A robbers. Yeah, exactly. It kind of reminds me of like, I don't know. I feel like in computing, you see the word tail a lot, like the end of a list or tail recursion if you recurse at the end of a function. And I don't know. I just like I've always liked that sort of imagery. Right. Okay, so the actual difference engine was built based on the original model in 1985 to 1991. And this is where I wrote the note about there was several fixes to the designs, but people. Theorized that they weren't real fixes. They were, they were intentional mistakes that Babbage put in the designs. And this is mostly based on the fact that he was able to build a working, you know, device back when he was designing the thing. So it's pretty clear that he like knew what he was doing. Um, and, and yeah, that's about it. Like, I think this is something that we could discuss for a billion years. I'd love to learn more about how the thing like actually works. And what its actual like purpose is like during, I'd love to learn like during the time, what would someone actually use this thing for? What did they want to do with this? Yeah, yeah, yeah. Was he just building the analytical engine for shits and giggles? Like did he just think this was like an awesome idea? Yeah. I think he could just see that, that this would have so many practical uses, that it was just this utterly amazing thing that that needed to be built. This is, this is crazy to me because it, like, it just goes to show you that the world doesn't necessarily always like pick up on good ideas because like, like it's just this island, this like ingenious island that like no one really, it's not like everyone immediately realized that this was an amazing idea. And they like, cause he had the designs for the analytical engine. It never got built. Yeah. And then like, I feel like I, we haven't heard really anything about like physical computation in the interim. And then we just got to, you know, the digital revolution, you know, until like, you know, and punch cards and things like that, uh, which didn't really bear any like direct relation to the, you know, Babbage's work. Yeah. And if anything, the government was aware of it and kind of abandoned it. Yeah. Which, which is even, you know, furthering your point of like, they actively turned their back on the idea. So it's, it's pretty interesting. I guess they just couldn't see the, the extreme, like practical usages of such a machine. So, so this is interesting. So like you have something like a Bitcoin today and it's funny because I think there's a lot of people on both sides where like there's people who are in the new camp who are like really drinking the Kool Aid about. Bitcoin and, and cryptocurrencies in general. Yeah. But then you actually have this whole other class of, of the more kind of like established like the establishment who are like, there's nothing to Bitcoin. Like it's just a speculative asset and mm-hmm. I'm wondering,'cause you have people who are like, no, you should never invest in Bitcoin. Or like, and Bitcoin is interesting'cause like, as far as I know, You can't do anything with, uh, with a Bitcoin. Like it's very well defined, like it is just a store, like potential store of value, whereas like, you know, Ethereum is kind of a different thing and I don't, I don't want to get too deep into the weeds, but I would be curious to know, like, do you think that cryptocurrency is, is more of like just a, a technological flash in the pan or maybe something that people are not, you know, something that has. Long term ramifications that maybe the general populace haven't really realized the value of yet. Oh, I, I believe that the blockchain as a concept is an incredibly revolutionary idea. I don't know about, you know, Bitcoin itself, or I don't know about any particular cryptocurrency, but that, that idea of like a blockchain, this thing that can be, you know, can be verified, uh, cannot be faked. You know, is distributed, there's no single body that, that controls it like that. This concept I think is very valuable, um, at least to me. I mean, that's, that's just my opinion, I guess, but I would be, I would be totally in Babbage's corner if he, you know, throughout this notion of a blockchain, it's interesting you mentioned that too, because they, uh, I did read about a couple strong allies of Babbage. Um, I think one of them, I want to say it was Lord Byron's wife, Lady Byron. Was an ally. There's like a quote from her where she talks about, you know, they were, they were calculating these differential equations or something, and the machine was just spitting out the answers. And it was kind of a really cool comment. There's also some hilarious comments by detractors. This is like one of my favorite quotes about programming. There's, this is, this is Babbage speaking about the questions that he's been asked about the machine. Uh, obviously while he was developing this machine, people asked him all sorts of stupid questions. Right, right. So this is one of them. He says, On two occasions, I have been asked, Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answer come out? And Babbage says, I am not rightly, I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question. Which I think is just the most, I don't know, awesomely, like, Somewhat passive aggressive, but just amazing way to like put someone in their place. Right. But it also just does speak to this, you know, this common element in software engineering, which is there's a lot of people who don't understand, you know, the underlying mechanism, not necessarily because they're stupid, but just because it's, it's complex and it might not be what they devoted their life to, but, but they might, you know, they might be on one side or the other. Based purely out of like emotion rather than some underlying merit. Deeper understanding. Yeah. Yeah, exactly. So yeah. Okay. Very cool. I think we should go back. I think we should go back to the state of the world where we were building physical computers. Uh, it's so cool. If, yeah, if you get some time, check it out, check out the videos. Cause there is a differential engine too. It's working. It's in a museum somewhere and you can literally plug values into it. See it function. You can see it carrying ones when it does when addition goes past 10 or whatever, it's, it has these crazy elevators that like lift these physical things up and kind of carry ones. Um, so that's amazing. You should check it out. It's really cool. I will, I will do that. Um, all right, well, I guess that's all we got for today. So I think we'll call that another, another episode of switch statement, uh, in the, in the can. Heck yeah. All right. All right. Peace. See you later.