1 00:00:00,520 --> 00:00:06,570 So, we always start all programming classes with hardware architecture. 2 00:00:06,570 --> 00:00:10,120 I, I don't think it's essential, so don't get too excited about it. 3 00:00:10,120 --> 00:00:11,440 It's a good 4 00:00:11,440 --> 00:00:13,310 use of terminology so we can have some words 5 00:00:13,310 --> 00:00:15,810 like, say, like CPU and you don't freak out. 6 00:00:15,810 --> 00:00:19,980 Or memory, or RAM, or disk drive and you don't freak out. 7 00:00:19,980 --> 00:00:21,910 I don't want to turn you into a hardware nut. I just want you 8 00:00:21,910 --> 00:00:25,260 to kind of have a few words so we can talk about what's going on inside. 9 00:00:25,260 --> 00:00:27,640 Because, in a sense, we're going to be writing 10 00:00:27,640 --> 00:00:31,150 programs to do stuff, both data, instructions, et cetera. 11 00:00:32,480 --> 00:00:36,120 So, here's some hardware that I just bought 12 00:00:36,120 --> 00:00:38,420 a couple weeks ago and I'm really in love with, 13 00:00:38,420 --> 00:00:40,400 and that is the Raspberry Pi. 14 00:00:40,400 --> 00:00:44,130 This is a single-board computer. 15 00:00:44,130 --> 00:00:48,530 It's got storage on an SD card right there. 16 00:00:48,530 --> 00:00:50,680 That's the operating system and the data. 17 00:00:50,680 --> 00:00:55,120 And it's got the both a microprocessor and the memory is in 18 00:00:55,120 --> 00:00:58,200 here, as well, and it hooks up with USB and HDMI and 19 00:00:58,200 --> 00:01:01,220 various things, and if you want, in this course, you probably can 20 00:01:01,220 --> 00:01:06,460 do all of the homework using a Raspberry Pi if you so desire. 21 00:01:06,460 --> 00:01:08,490 So, this is what hardware really looks like. 22 00:01:08,490 --> 00:01:10,100 It's kind of the inside of something. 23 00:01:10,100 --> 00:01:12,980 Normally, it's in some kind of case and you don't get to see it. 24 00:01:12,980 --> 00:01:13,900 And that's what it looks like. 25 00:01:13,900 --> 00:01:18,340 It's kind of got this green and little silver and gold. 26 00:01:18,340 --> 00:01:19,600 I think they're very beautiful. 27 00:01:21,460 --> 00:01:22,970 They're very pretty. 28 00:01:22,970 --> 00:01:24,670 A lot of engineering goes into making these things. 29 00:01:26,950 --> 00:01:29,980 And and so we kind of have a block diagram of 30 00:01:29,980 --> 00:01:34,520 what's going on in here, and there's some, just some terminology. 31 00:01:34,520 --> 00:01:38,370 The, the brains of it all, well. 32 00:01:38,370 --> 00:01:40,820 We draw this black diagram partly because, and this is 33 00:01:40,820 --> 00:01:43,990 a, from a, oh, parts are coming off of this. 34 00:01:45,700 --> 00:01:45,750 Eh. 35 00:01:45,750 --> 00:01:47,830 I don't know what that was. 36 00:01:47,830 --> 00:01:50,100 It's okay, it's broken anyways. 37 00:01:50,100 --> 00:01:53,280 And if you have a desktop computer, this is more like what it looks like inside. 38 00:01:53,280 --> 00:01:55,850 This part is called a motherboard, and it's kind 39 00:01:55,850 --> 00:01:58,620 of like the thing that connects and brings everything together. 40 00:01:58,620 --> 00:02:00,150 It's got a bunch of wires. 41 00:02:00,150 --> 00:02:02,600 Each one of those little lines here is a wire. 42 00:02:02,600 --> 00:02:04,930 It's covered with sort of a lacquer. 43 00:02:04,930 --> 00:02:06,560 And then there are things that penetrate 44 00:02:06,560 --> 00:02:09,830 the board, and then connect to various chips. 45 00:02:09,830 --> 00:02:13,490 And this whole thing is what this picture is. 46 00:02:13,490 --> 00:02:15,700 But it really is connecting a number of different components. 47 00:02:17,260 --> 00:02:20,510 The central processing unit that I've spoken of before. 48 00:02:20,510 --> 00:02:21,370 Put that back down. 49 00:02:21,370 --> 00:02:24,054 [SOUND] Central processing unit is the closest thing a 50 00:02:24,054 --> 00:02:26,750 computer has to a brain, but it's barely a brain. 51 00:02:26,750 --> 00:02:30,380 It's really just a super fast programmable calculator. 52 00:02:30,380 --> 00:02:33,670 It, we make it flexible by our creativity when we write programs. 53 00:02:33,670 --> 00:02:35,320 We make it seem intelligent. 54 00:02:35,320 --> 00:02:38,770 It's people that make it intelligent by taking our own knowledge 55 00:02:38,770 --> 00:02:40,000 and putting it in. 56 00:02:40,000 --> 00:02:43,600 This is not itself intelligent, there's nothing to fear from this. 57 00:02:43,600 --> 00:02:44,630 It's just not that smart. 58 00:02:46,040 --> 00:02:50,400 So, this is the thing that's programmed to ask the question "what's next?" 59 00:02:50,400 --> 00:02:52,680 And then we have to have a set of instructions 60 00:02:52,680 --> 00:02:56,370 that feed this thing really fast, billions of times a second. 61 00:02:56,370 --> 00:02:59,500 And that's what this is, this is the random access memory. 62 00:02:59,500 --> 00:03:01,290 And we have memory chips and 63 00:03:01,290 --> 00:03:03,790 they're connected together through the motherboard. 64 00:03:03,790 --> 00:03:08,990 So, we have the main memory and we have the central processing unit. 65 00:03:08,990 --> 00:03:11,870 And this is where our high-speed instructions come 66 00:03:11,870 --> 00:03:14,470 from, this is where our high-speed data is stored. 67 00:03:14,470 --> 00:03:18,110 And this is the thing that asks "what next?" and it reads its instructions from here. 68 00:03:18,110 --> 00:03:19,640 And you'll see that kind of like, oop, they're not 69 00:03:19,640 --> 00:03:22,790 quite connected together but eventually they're kind of connecting together. 70 00:03:22,790 --> 00:03:24,560 Don't feel too bad about this hardware it's all 71 00:03:24,560 --> 00:03:27,840 old and it's all broken and it can't be hurt. 72 00:03:27,840 --> 00:03:31,610 So, the next thing we got is input/output device. 73 00:03:31,610 --> 00:03:33,160 So I'll go back to my Raspberry Pi. 74 00:03:33,160 --> 00:03:35,980 So the Raspberry Pi has a USB 75 00:03:35,980 --> 00:03:39,190 that you can connect a mouse or a keyboard. 76 00:03:39,190 --> 00:03:43,150 It has a HDMI that you can connect a monitor to. 77 00:03:43,150 --> 00:03:44,490 I has an Ethernet connector. 78 00:03:44,490 --> 00:03:47,770 So these are all examples of 79 00:03:47,770 --> 00:03:49,100 input/output devices. 80 00:03:50,890 --> 00:03:55,870 And then the last thing on the screen is the secondary memory. 81 00:03:55,870 --> 00:04:00,380 So, this RAM [SOUND] on the Raspberry Pi, the CPU, the central processing 82 00:04:00,380 --> 00:04:03,495 unit and the RAM are all on this one chip in the middle. 83 00:04:03,495 --> 00:04:07,780 It's called SOC or system on a chip where they put more parts there. 84 00:04:07,780 --> 00:04:11,280 So in a sense it collapsed 85 00:04:13,300 --> 00:04:18,590 this, and this, and a lot of this all down in the Raspberry Pi 86 00:04:19,840 --> 00:04:21,140 to one little guy. 87 00:04:21,140 --> 00:04:23,320 But it's still architecturally the same thing. 88 00:04:23,320 --> 00:04:24,900 There's a central processing unit. 89 00:04:24,900 --> 00:04:25,690 There's main memory. 90 00:04:25,690 --> 00:04:27,376 There's graphics cards, etc. 91 00:04:27,376 --> 00:04:31,030 [SOUND] So, input/output devices. 92 00:04:31,030 --> 00:04:31,940 Oh, this big 93 00:04:31,940 --> 00:04:37,020 this guy has input/output devices too, like USB and keyboard, monitor, etc. 94 00:04:37,020 --> 00:04:38,230 So they're, they're very similar. 95 00:04:38,230 --> 00:04:40,770 It's just, this is new, and this is old. 96 00:04:40,770 --> 00:04:43,370 Everything gets smaller when it gets newer. 97 00:04:44,560 --> 00:04:45,607 Okay. 98 00:04:45,607 --> 00:04:48,640 [SOUND] Okay. 99 00:04:48,640 --> 00:04:51,990 So the last thing we gotta talk about is the secondary memory. 100 00:04:51,990 --> 00:04:52,490 Well, 101 00:04:54,310 --> 00:04:57,720 when the power goes off, these things sort of go away. 102 00:04:57,720 --> 00:04:59,830 The data in this RAM goes away. 103 00:04:59,830 --> 00:05:02,210 It's just designed to be really fast. 104 00:05:02,210 --> 00:05:03,450 But not permanent. 105 00:05:03,450 --> 00:05:06,600 So we need a place that's permanent, that's what secondary storage is. 106 00:05:06,600 --> 00:05:10,260 That's what, that's what this secondary storage is for, this is permanent. 107 00:05:11,520 --> 00:05:16,820 This is fast, and it cha cha cha cha cha really fast. 108 00:05:16,820 --> 00:05:20,290 And but this is permanent, and this is slower. 109 00:05:20,290 --> 00:05:20,900 Okay? 110 00:05:20,900 --> 00:05:22,110 So the secondary memory. 111 00:05:22,110 --> 00:05:24,480 [SOUND] I've got two kind of secondary memory. 112 00:05:24,480 --> 00:05:26,105 Oh, dropped it on the floor. 113 00:05:26,105 --> 00:05:28,740 [SOUND] Two kinds of secondary memory. 114 00:05:28,740 --> 00:05:30,480 I'll start with the Raspberry Pi. 115 00:05:30,480 --> 00:05:34,940 The secondary memory of the Raspberry Pi is this SD card. 116 00:05:34,940 --> 00:05:36,380 It's like a disk drive. 117 00:05:36,380 --> 00:05:38,210 It still is permanent. 118 00:05:38,210 --> 00:05:40,540 Does not require power to maintain its data. 119 00:05:40,540 --> 00:05:42,110 The data stays permanent. 120 00:05:42,110 --> 00:05:44,220 So, in the future we will see more 121 00:05:44,220 --> 00:05:48,220 of these flash-style drives and SD-style drives. 122 00:05:48,220 --> 00:05:51,040 So the Raspberry Pi is kind of alluding to the future. 123 00:05:51,040 --> 00:05:52,540 [SOUND] There's a disk drive in here. 124 00:05:52,540 --> 00:05:53,410 It's not really a disk. 125 00:05:53,410 --> 00:05:55,190 It's also flash memory. 126 00:05:55,190 --> 00:06:00,970 But in the old days, in the good old days, back when I was a kid, 127 00:06:00,970 --> 00:06:06,150 we, our secondary memory was [SOUND] a disk drive, 128 00:06:06,150 --> 00:06:11,760 and it had [SOUND] platters, and it spun, and it made a satisfying noise. 129 00:06:11,760 --> 00:06:13,640 And it would move in and out to read data, and 130 00:06:13,640 --> 00:06:15,495 I'll show you a video of this just in a bit. 131 00:06:15,495 --> 00:06:19,420 [SOUND] And so these would record the data on the magnetic platters 132 00:06:19,420 --> 00:06:21,450 and then when the power's taken off, the data would still be magnetized. 133 00:06:21,450 --> 00:06:23,480 And then it would go and move to the 134 00:06:23,480 --> 00:06:26,260 right spot, [SOUND] spin it around, and read the data. 135 00:06:26,260 --> 00:06:30,740 And again, this is kind of messed up in a pretty bad way. 136 00:06:30,740 --> 00:06:32,290 So, there we go. 137 00:06:33,310 --> 00:06:39,570 Central processing unit, brains of the operation, main memory, fast, 138 00:06:39,570 --> 00:06:44,060 but goes away when we power on, input output devices, keyboards, et cetera. 139 00:06:44,060 --> 00:06:49,740 And then storage, that has, maintains its data across power cycles. 140 00:06:49,740 --> 00:06:53,480 Okay, and I just said all that. 141 00:06:53,480 --> 00:06:53,980 Okay? 142 00:06:55,220 --> 00:06:59,340 So then the question is, where do you belong in this? 143 00:06:59,340 --> 00:07:00,570 Where do programs live? 144 00:07:00,570 --> 00:07:01,980 Where do we write? 145 00:07:01,980 --> 00:07:06,180 And the answer is, we kind of live in the memory, right. 146 00:07:06,180 --> 00:07:09,320 What we do is we put our programs into the 147 00:07:09,320 --> 00:07:14,250 memory and then the CPU pulls the programs out of the memory. 148 00:07:14,250 --> 00:07:17,530 So we have to write our programs and put them into the memory. 149 00:07:17,530 --> 00:07:19,990 When we start them and run them we're really loading them 150 00:07:19,990 --> 00:07:23,590 into the memory so they can be fed rapidly to the CPU. 151 00:07:23,590 --> 00:07:27,400 Now the computers don't really execute Python, like "if x less 152 00:07:27,400 --> 00:07:30,420 than three print", but that's what we tend to want to write. 153 00:07:30,420 --> 00:07:33,290 Because what the computers really execute is a thing called 154 00:07:33,290 --> 00:07:36,490 machine language, which is a series of zeroes and ones 155 00:07:36,490 --> 00:07:39,880 that pretty much translate directly to what's on these pins. 156 00:07:39,880 --> 00:07:42,900 There's voltages that go up and down. 157 00:07:42,900 --> 00:07:44,830 That's called machine language. 158 00:07:44,830 --> 00:07:48,900 Source code, like Python, is written in a 159 00:07:48,900 --> 00:07:52,260 way that's most convenient, well, at least more convenient. 160 00:07:52,260 --> 00:07:54,510 Machine language is what's most convenient 161 00:07:54,510 --> 00:07:55,700 for the hardware. 162 00:07:55,700 --> 00:07:58,320 So we either, we have to translate from source code to 163 00:07:58,320 --> 00:08:01,720 machine language, and that's what the Python program does for us. 164 00:08:01,720 --> 00:08:06,030 We write in Python, and Python translates to machine language for us. 165 00:08:06,030 --> 00:08:11,570 So, I got a couple of videos that give you a sense of how this all works. 166 00:08:11,570 --> 00:08:14,500 We'll start with CPU. 167 00:08:14,500 --> 00:08:18,270 And what this is going to do is, this is going to show you the intensity of 168 00:08:18,270 --> 00:08:21,380 how much electricity, the thing that gets hot 169 00:08:21,380 --> 00:08:23,530 inside your computer is this little guy right here. 170 00:08:23,530 --> 00:08:26,625 And we're going to see in this video just how hot it can get. 171 00:08:26,625 --> 00:08:34,050 [SOUND]. 172 00:08:34,050 --> 00:08:36,290 Okay, so welcome back. 173 00:08:36,290 --> 00:08:37,860 So the next thing I'm going to show you 174 00:08:37,860 --> 00:08:40,660 I showed you a hard disk that sort of didn't work. 175 00:08:40,660 --> 00:08:43,920 But we're actually going to show you a real short video on how a hard 176 00:08:43,920 --> 00:08:45,990 disk works [SOUND] that someone took the 177 00:08:45,990 --> 00:08:48,220 cover off and actually applied power to it. 178 00:08:48,220 --> 00:08:49,730 You don't want to do this yourself if you have a 179 00:08:49,730 --> 00:08:53,770 hard drive, I've read, and some people say that you can do 180 00:08:53,770 --> 00:08:56,910 it for a, for a few minutes and then the drive 181 00:08:56,910 --> 00:09:00,590 kind of destroys itself if you run it with the cover off.