WEBVTT 00:00:04.284 --> 00:00:08.893 If a computer is like a piano, then the term software refers to the code - what runs on it, like the music. 00:00:08.893 --> 00:00:13.026 And the hardware is the physical parts of the thing. 00:00:13.026 --> 00:00:15.167 So in this section, I'm going to talk about hardware, physical parts of the computer. 00:00:15.167 --> 00:00:22.200 So probably one of the most important inventions of the twentieth century is the transistor. 00:00:22.200 --> 00:00:27.467 And this is a little electronic component that can be used to build all sorts of different things. 00:00:27.467 --> 00:00:32.367 The most common form of transistor today is built on what's called a chip. 00:00:32.367 --> 00:00:36.967 And here's a picture of a chip, that I'm linking to from Wikimedia. 00:00:40.147 --> 00:00:44.234 And so a chip is made of a little fingernail-sized piece of silicon. 00:00:44.234 --> 00:00:46.667 And then different electronic components can be etched onto the silicon 00:00:46.667 --> 00:00:50.267 and this allows you to essentially make the components very, very cheaply. 00:00:50.267 --> 00:00:58.816 So the most likely, the most common component put on here is transistors. And you can make all sorts of stuff out of transistors. 00:00:58.816 --> 00:01:04.100 So the things I'm gonna talk about later, CPUs and memory and whatnot, those all come down to chips that look like this. 00:01:04.100 --> 00:01:08.615 Now a chip like this is said to be solid state 00:01:08.615 --> 00:01:10.667 meaning there's no moving parts, there's no gears, there's no wheels. 00:01:10.667 --> 00:01:13.538 And in a way, that makes it very reliable. 00:01:13.538 --> 00:01:14.931 And as I said before, they can be made pretty cheaply. 00:01:14.931 --> 00:01:18.100 And so this is one of the driving forces in the, computer revolution. 00:01:18.100 --> 00:01:22.033 I should point out, this is the element silicon, which is like glass. 00:01:22.033 --> 00:01:28.300 Not to be confused with silicone, which is like that kinda soft, rubbery stuff. 00:01:28.300 --> 00:01:33.633 So, one of the most important forces driving silicon development is this thing called Moore's Law. 00:01:33.633 --> 00:01:37.600 And so this was formulated by Gordon Moore. And it's just an observation about 00:01:37.600 --> 00:01:43.120 how the manufacturing of chips with transistors on them tends to go. 00:01:43.120 --> 00:01:47.633 And what the law says is that every 18 to 24 months, approximately, 00:01:47.633 --> 00:01:52.867 the number of transistors which can be fit onto one of those chips doubles. 00:01:52.867 --> 00:02:00.906 So, you could sorta take that two ways. It might mean that for each year when I make a chip 00:02:00.906 --> 00:02:04.733 after it doubles, well, now I can make that same chip but I get twice as many transistors. 00:02:04.733 --> 00:02:06.167 So, in some sense it... it's more powerful. 00:02:06.167 --> 00:02:12.795 Or you can think of it as just that the transistors are just getting cheaper and cheaper. 00:02:12.795 --> 00:02:15.233 Now Moore's Law is not some law of nature, like the law of gravity. 00:02:15.233 --> 00:02:19.467 It's just an observation about how transistor manufacturing tends to go, 00:02:19.467 --> 00:02:24.776 but it's been true for over twenty years, and it seems to be continuing to be true. 00:02:24.776 --> 00:02:32.767 So. Moore's law is why you can have computers now that are getting cheaper and they're showing up in thermostats and microwaves. 00:02:32.767 --> 00:02:37.872 Essentially it's the doubling quality of Moore's law, 00:02:37.872 --> 00:02:46.742 making what used to be a computer that would fill a room and cost millions of dollars now fit in the size of a sugar cube and cost under a dollar. 00:02:46.742 --> 00:02:49.018 That is the effect of Moore's law when you think of doubling. 00:02:49.018 --> 00:02:50.500 Well, just one doubling it's not that big. 00:02:50.500 --> 00:02:55.334 If you have ten doublings that's a factor of a thousand. 00:02:55.334 --> 00:02:57.935 So that's how you get from the room down to the sugar cube. 00:02:57.935 --> 00:02:59.800 The other way you can think about this just in your own life, 00:02:59.800 --> 00:03:07.408 is imagine buying... maybe six years ago buying a 50 dollar mp3 player. 00:03:07.408 --> 00:03:14.096 had some amount of capacity. Maybe it had one gigabyte of capacity. 00:03:14.096 --> 00:03:17.967 And then a few years later, with the same $50, if you bought an mp3 player it might have two or maybe four gigabytes of capacity. 00:03:17.967 --> 00:03:22.367 And then a few years later, for the same $50, well now they all have eight gigabytes. 00:03:22.367 --> 00:03:26.267 And what's going on is, well, basically there's a chip in the mp3 player that does the storage. 00:03:26.267 --> 00:03:30.300 And by Moore's law, the manufacturing of that chip... 00:03:30.300 --> 00:03:33.415 because there's more transistors that fit in there, 00:03:33.415 --> 00:03:36.733 for pretty much the same price they can offer more and more capacity. 00:03:36.733 --> 00:03:40.167 So that is the exponential quality of Moore's law. 00:03:40.167 --> 00:03:44.100 So, to talk about computers, I'm gonna talk about the major parts that go into one. 00:03:44.100 --> 00:03:53.400 And largely - oh, and here's a little picture of a computer - I'm going to say that there's the CPU, which is sort of the brains of the thing; 00:03:53.400 --> 00:03:57.656 and then there's RAM, which is sort of the temporary scratch pad memory; 00:03:57.656 --> 00:04:01.046 and finally, disk or flash for persistent structure. 00:04:01.046 --> 00:04:02.333 So we'll talk about each one of those parts. 00:04:02.333 --> 00:04:09.127 So, probably the most important part of the computer is the CPU, which stands for Central Processing Unit, 00:04:09.127 --> 00:04:12.467 and it's inevitably described as kind of "the brains" of the computer. It actually does the computing. 00:04:12.467 --> 00:04:19.767 So... the CPU has certain fairly simple operations that it can perform, 00:04:19.767 --> 00:04:27.533 and so when you say that a computer runs at two billion operations per second, 00:04:27.533 --> 00:04:29.900 really that's talking about the CPU: that means the CPU can do two billion things per second. 00:04:29.900 --> 00:04:32.765 And that's a very typical number for 2012. 00:04:32.765 --> 00:04:38.767 To say that it's the brains, we have to think about, well, the 'run' button in the earlier coding exercises, 00:04:38.767 --> 00:04:42.610 where you had the code, and then something was executing the code. 00:04:42.610 --> 00:04:45.600 Really, that was the CPU that was taking in that code and doing it. 00:04:45.600 --> 00:04:51.833 So, before I talk about, RAM and disk and those things, I need to have a brief word about bytes. 00:04:51.833 --> 00:04:57.900 So a byte is the, sort of, most common measure of information storage. 00:04:57.900 --> 00:05:02.951 So one byte refers to approximately one letter that you might type, 00:05:02.951 --> 00:05:07.688 like a T or an X or something. That fits in one byte. 00:05:07.688 --> 00:05:14.700 Later on I'm gonna talk about RAM and disks and things like that. And those are all the sizes. How much information can they hold? 00:05:14.700 --> 00:05:20.333 Those are measured in bytes. And later on, I'll go into more detail about the different sizes that you might have. 00:05:20.333 --> 00:05:24.067 For now, I'll just say that one megabyte is a common size. That's about a million bytes. 00:05:24.067 --> 00:05:28.367 And one gigabyte is about a billion bytes. 00:05:28.367 --> 00:05:32.500 So,with that in mind, let's go to our second bit of technology here... 00:05:32.500 --> 00:05:38.167 So RAM stands for Random Access Memory - or we might just say 'memory'- 00:05:38.167 --> 00:05:44.654 and RAM is the temporary storage used by the CPU 00:05:44.654 --> 00:05:47.800 to hold data and code that it's using right then just in the course of doing computation. 00:05:47.800 --> 00:05:55.233 So in the code when we said something like 'new SimpleImage ("flowers.jpg")' 00:05:55.233 --> 00:06:02.333 and I would say, 'well, this kind of loads the data into the computer' - really what was happening is the bytes of that data were being loaded into RAM, 00:06:02.333 --> 00:06:06.016 and once they were in RAM then the CPU could do operations on them. 00:06:06.016 --> 00:06:09.833 could do operations on them. So when you wrote code like 'pixel.setRed(0)' - really that was 00:06:09.833 --> 00:06:14.767 going into RAM and manipulating of the data; actually making a change. 00:06:14.767 --> 00:06:18.300 So, that sort of active stuff happens in RAM. 00:06:18.300 --> 00:06:24.824 The main thing about RAM is that it is not persistent. 00:06:24.824 --> 00:06:27.000 What that means is - when the power is removed, it just goes blank. 00:06:27.000 --> 00:06:31.744 So it just works well as fast, temporary storage, but it's not long-term storage. 00:06:31.744 --> 00:06:36.067 And you can kind of, I think you can have some intuition about that if you think about when you're working on 00:06:36.067 --> 00:06:42.500 some, you know, paper, and you're typing in a word processor and then suddenly your computer shuts down... 00:06:42.500 --> 00:06:44.700 maybe it crashes or the power goes out or something. 00:06:44.700 --> 00:06:50.667 And so you have a sense that, well, whatever you were just... those last few bits you were typing. Those are gone. 00:06:50.667 --> 00:06:59.283 Those were just in RAM. And the version that you have is the version that you saved. 00:06:59.283 --> 00:07:00.233 So in a word processor when you hit the 'save' command, really what you are doing is 00:07:00.233 --> 00:07:05.506 you're taking the version that is in RAM - this kinda temporary version - and you're writing it to disk. 00:07:05.506 --> 00:07:09.667 (mumbled) I'm just getting something, and we'll talk about it in a second. 00:07:09.667 --> 00:07:14.300 So that kinda gives you the sense of what does it mean to be persistent - like disk, or volatile - like RAM. 00:07:14.300 --> 00:07:19.577 Alright, that leads us to our third hardware component: persistent storage. 00:07:19.577 --> 00:07:22.300 So, the main thing about persistent storage: 00:07:22.300 --> 00:07:27.843 It's a big area of bytes, but when you remove the power the data stays there. 00:07:27.843 --> 00:07:34.484 So for the longest time persistent storage in computers has been done with a hard drive. 00:07:34.484 --> 00:07:40.800 So a hard drive has a spinning disk in it. And there's a little head that writes magnetic patterns on the disk, 00:07:40.800 --> 00:07:44.467 and it does that to record 0's and 1's, and store data. 00:07:44.467 --> 00:07:48.767 And so when you... if you have a computer and you hear kind of a high-pitched 'whining' sound, 00:07:48.767 --> 00:07:54.800 what you're probably hearing is the hard drive disk spinning in its little enclosure. 00:07:54.800 --> 00:07:59.500 More recently there's been advances in what's called a flash drive. 00:07:59.500 --> 00:08:04.200 And so a flash drive also stores 0's and 1's persistently, but it's solid state. 00:08:04.200 --> 00:08:11.868 It just uses a chip - a so-called 'flash chip' - so there's no moving parts, it's very small, it's very reliable. 00:08:11.868 --> 00:08:14.667 So, flash chips are used to make those little USB thumb drives 00:08:14.667 --> 00:08:19.667 or SD cards, that you might put into a camera or something like that. 00:08:19.667 --> 00:08:26.636 It used to be that per byte, flash was much more expensive than hard drives, and so hard drives were used for everything. 00:08:26.636 --> 00:08:28.633 Sort of following the pattern of Moore's Law, 00:08:28.633 --> 00:08:30.491 flash chips have been getting cheaper and cheaper. 00:08:30.491 --> 00:08:34.531 And so it may be that the hard drive kinda dies out for day-to-day usage. 00:08:34.531 --> 00:08:38.600 Like, we don't need it: we can just use these chips. So that remains to be seen. 00:08:38.600 --> 00:08:41.833 So when you've got a hard drive or a flash chip 00:08:41.833 --> 00:08:49.500 that just has this big area of bytes to do persistent storage, um, just on its own it's not really ready for the user to use. 00:08:49.500 --> 00:08:54.825 Usually what happens is, the hard drive or flash drive is organised with what's called a file system. 00:08:54.825 --> 00:08:59.400 And so the file system is just a way of organising this big area of bytes 00:08:59.400 --> 00:09:04.700 and giving it that sort of familiar structure of files and folders. 00:09:04.700 --> 00:09:07.178 And they each have names, and you can move them around and stuff. 00:09:07.178 --> 00:09:16.791 And so a file is really just a way of taking some area of, you know, 100,000 bytes, and assigning a name to them. 00:09:16.791 --> 00:09:20.667 So saying, 'look, this is flowers.jpg'. And flowers.jpg, that name, refers to those 100,000 bytes. 00:09:20.667 --> 00:09:23.033 And then the user can copy it, or move it around, or whatever. 00:09:23.033 --> 00:09:28.900 So, the file system just facilitates for you, seeing what data you have on there 00:09:28.900 --> 00:09:31.800 and moving it around and organising it. 00:09:31.800 --> 00:09:34.810 So that's our quick introduction. 00:09:34.810 --> 00:09:36.900 So actually what I'd like to do is show you just pictures of actual hardware. 00:09:36.900 --> 00:09:37.400 So, this is a picture of a motherboard. 00:09:37.400 --> 00:09:41.100 This is a computer, a Shuttle computer, I bought in I think 2008, and then it broke. 00:09:41.100 --> 00:09:47.800 So it became my little demo computer. 00:09:47.800 --> 00:09:52.318 So this was a cheap computer, about $200 with all the parts. 00:09:52.318 --> 00:09:56.358 So this is the motherboard all the electronic components plug into. 00:09:56.358 --> 00:09:58.467 And right here in the middle is maybe the most important component. That's the CPU. 00:09:58.467 --> 00:10:04.996 So let's zoom in on that. 00:10:04.996 --> 00:10:10.733 So, if you kinda zoom in and look at the CPU, this metal package has the CPU chip in it. 00:10:10.733 --> 00:10:16.200 And I'm gonna flip it over. If you flip it over you see there's all these gold pads here. 00:10:16.200 --> 00:10:20.633 So the CPU is the most complicated chip on here and so it has a very large number of connections, 00:10:20.633 --> 00:10:22.933 electrical connections to the motherboard. 00:10:22.933 --> 00:10:28.727 And so then I can look again at my Wikimedia image, and now you can appreciate... 00:10:28.727 --> 00:10:34.000 ...well, so there's these little tiny wires around the outside. So these connect to pads on the package 00:10:34.000 --> 00:10:36.761 - the gold pads we were seeing - 00:10:36.761 --> 00:10:41.033 and so inside the package they connect to little tiny spots around the chip 00:10:41.033 --> 00:10:43.200 in order to get the electricity into the transistors on the side here. 00:10:43.200 --> 00:10:49.667 The other thing I'll point out here is this copper thing. There's a second chip underneath here. 00:10:49.667 --> 00:10:55.533 This is called a heatsink. So, the chip, because it has electricity running through it, it can heat up, 00:10:55.533 --> 00:10:59.470 so there needs to be a way of dissipating that heat. 00:10:59.470 --> 00:11:01.281 This is made of copper: copper's really good at conducting heat, 00:11:01.281 --> 00:11:06.715 and so just by bolting that on there, it keeps the chip cool enough to operate. 00:11:06.715 --> 00:11:12.167 There used to be another heatsink on top of the CPU here, but I removed it. Just so I could take it apart and show it to you. 00:11:12.167 --> 00:11:20.967 All righty. So that's the CPU in the, uh, in this computer. So now let's look at the RAM. 00:11:20.967 --> 00:11:24.700 So if you look at the side of the computer here, this is the RAM. 00:11:24.700 --> 00:11:31.100 It's on a little separate card. And in this picture I have removed the card. 00:11:31.100 --> 00:11:33.533 So the card fits into the slot here, so that's RAM. 00:11:33.533 --> 00:11:38.712 So that's about 512 megabytes of RAM. 00:11:38.712 --> 00:11:41.533 This is some years ago. You probably couldn't buy a RAM card that small nowadays. 00:11:41.533 --> 00:11:47.767 So, you can see there's two chips here and there's two more chips underneath the stickers. 00:11:47.767 --> 00:11:55.300 So this was made with four chips. Probably by Moore's Law, when this card was manufactured a few years before, 00:11:55.300 --> 00:11:56.967 it probably used to be eight chips. 00:11:56.967 --> 00:12:00.567 And then, by Moore's law, they can fit more under each chip and so they can just save money. 00:12:00.567 --> 00:12:05.693 So, for the same 512 megabytes they could use fewer chips, so it's cheaper. 00:12:05.693 --> 00:12:10.900 So that's...what do we have...CPU and RAM. So the last thing we need is persistent storage. 00:12:10.900 --> 00:12:14.833 So, for this computer, persistent storage was provided by this. This is a hard drive. 00:12:14.833 --> 00:12:19.000 So this is a three and a half inch hard drive - very typical size for a desktoop computer. 00:12:19.000 --> 00:12:23.619 So this is where there's the spinning magnetic disk in here. 00:12:23.619 --> 00:12:31.700 And this connects to the motherboard by this little SATA cable, which is a standard thing. 00:12:31.700 --> 00:12:35.508 So those are the three parts of a computer. 00:12:35.508 --> 00:12:36.767 That was a $200 computer, and it sorta did everything you'd want a computer to do. 00:12:36.767 --> 00:12:43.900 More recently now we've got this alternative to the hard drive. 00:12:43.900 --> 00:12:49.904 So this is a USB flash drive, or sometimes called a thumb drive. 00:12:49.904 --> 00:12:54.367 So it's, you know, it's tiny. And I took this one apart. 00:12:54.367 --> 00:12:59.471 And so if you look inside of it, this is a flash chip. 00:12:59.471 --> 00:13:04.600 So this is the chip that just stores persistent data, little 0's and 1's, as little groups of electrons. 00:13:04.600 --> 00:13:08.852 So this is the thing that's competing with the hard drive. 00:13:08.852 --> 00:13:15.800 So this is a one gigabit chip, so it stores one billion bits. 00:13:15.800 --> 00:13:22.644 And later on we'll look at how many bytes that might be. So that's a thumb drive. 00:13:22.644 --> 00:13:27.520 This is an SD card, which is just a similar, you know, just an alternative to the thumb drive. 00:13:27.520 --> 00:13:31.003 It's really just the same technology; it's just a different shape basically. 00:13:31.003 --> 00:13:33.300 So this is the sort of thing you would use inside of a camera. 00:13:33.300 --> 00:13:37.830 So as a last example, looking at that big computer... 00:13:37.830 --> 00:13:43.133 So, one of the effects of Moore's Law is that you get these cheap little computers that can sort of fit into different places. 00:13:43.133 --> 00:13:48.465 So a little computer on a chip is known as a microcontroller. 00:13:48.465 --> 00:13:49.933 So the idea is, that instead of having all these separate chips 00:13:49.933 --> 00:13:56.963 you can fit the CPU, the RAM, and the persistent storage all onto one chip. 00:13:56.963 --> 00:14:03.883 And it's not gonna have a lot of power, but it's gonna be cheap. And Moore's Law has made that possible. 00:14:03.883 --> 00:14:07.970 So microcontrollers, now, you can buy essentially the whole computer for under a dollar, 00:14:07.970 --> 00:14:12.033 and it's just on the one chip. So these are the kinda computers - or I should say microcontrollers - 00:14:12.033 --> 00:14:13.821 that you would find in a thermostat, 00:14:13.821 --> 00:14:18.133 or they're probably scattered around your car doing little computer functions. 00:14:18.133 --> 00:14:27.167 So, a neat example of a micro-controller is this guy. This is an Arduino board. 00:14:27.167 --> 00:14:33.167 And this is a free and open source board, just offered by artists or hobbyists, or just for kinda playing around. 00:14:33.167 --> 00:14:37.267 So this here. This is the chip; this is the micro controller. 00:14:37.267 --> 00:14:40.867 So, it has a little bit of RAM, a little bit of CPU, and a little bit of persistent storage 00:14:40.867 --> 00:14:45.300 just all on there. And then it's put on this board with some other support chips: 00:14:45.300 --> 00:14:50.000 so, this is a USB chip, and it's got some power chips here to just make the whole thing work. 00:14:50.000 --> 00:14:54.167 So, you can buy a version of this I think for about $20. 00:14:54.167 --> 00:14:56.333 And the idea is, it's just a little computer, 00:14:56.333 --> 00:14:59.633 so it can read sensors or switches, or control little lights or whatever. 00:14:59.633 --> 00:15:05.323 So it's just a fun way to play around and make, like, an art project, or something like that. 00:15:05.323 --> 00:15:06.000 So if you like working with your hands and you like wires, 00:15:06.000 --> 99:59:59.999 then this is another form of computer that might be good to play with.