0 00:00:00,000 --> 00:00:05,000 As the pioneers of computer science explored how to design a thinking machine, they realized 1 00:00:05,000 --> 00:00:09,000 that it had to perform four different tasks. 2 00:00:09,000 --> 00:00:18,000 It would need to take input, store information, process it, and then output the results. 3 00:00:18,000 --> 00:00:24,000 Now this might sound simple, but these four things are common to all computers. 4 00:00:24,000 --> 00:00:29,000 That's what makes a computer a computer. 5 00:00:29,000 --> 00:00:34,000 The earliest computers were made out of wood and metal, with mechanical levers and gears. 6 00:00:34,000 --> 00:00:39,000 By the 20th century, though, computers started using electrical components. 7 00:00:39,000 --> 00:00:42,000 These early computers were really large and really slow. 8 00:00:42,000 --> 00:00:49,000 A computer the size of a room might take hours just to do a basic math problem. 9 00:00:49,000 --> 00:00:55,000 These machines are things of gleaming, very colored metal, and numerous flashing lights. 10 00:00:55,000 --> 00:01:00,000 Computers started out as basic calculators, which was already really awesome at the time, 11 00:01:00,000 --> 00:01:02,000 and they were only manipulating numbers back then. 12 00:01:02,000 --> 00:01:08,000 But now we can use them to talk to each other, we can use them to play games, control robots, 13 00:01:08,000 --> 00:01:12,000 and do any crazy thing that you could probably imagine. 14 00:01:12,000 --> 00:01:16,000 Modern computers look nothing like those clunky old machines, but they still do these same 15 00:01:16,000 --> 00:01:24,000 four things. 16 00:01:24,000 --> 00:01:26,000 Next we're going to talk about input. 17 00:01:26,000 --> 00:01:30,000 This is my favorite, because what input is, is the stuff that the world does, or that 18 00:01:30,000 --> 00:01:33,000 you do, that makes the computer do stuff. 19 00:01:33,000 --> 00:01:36,000 You can tell a computer what to do with a keyboard, you can tell them what to do with 20 00:01:36,000 --> 00:01:42,000 a mouse, the microphone, the camera, and now if you're wearing a computer on your wrist, 21 00:01:42,000 --> 00:01:45,000 it might listen to your heartbeat, or in your car it might be listening to what the car 22 00:01:45,000 --> 00:01:51,000 is doing, and a touch screen can actually sense your finger and it takes that as input 23 00:01:51,000 --> 00:01:57,000 on what it's doing. 24 00:01:57,000 --> 00:02:03,000 All these different inputs give a computer information, which is then stored in memory. 25 00:02:03,000 --> 00:02:08,000 A computer's processor takes information from memory, it manipulates it, or changes it, 26 00:02:08,000 --> 00:02:12,000 using an algorithm, which is just a series of commands, and then it sends the processed 27 00:02:12,000 --> 00:02:16,000 information back to be stored in memory again. 28 00:02:16,000 --> 00:02:24,000 This continues until the processed information is ready to be output. 29 00:02:24,000 --> 00:02:28,000 How a computer outputs information depends on what the computer is designed to do. 30 00:02:28,000 --> 00:02:33,000 A computer display can show text, photos, videos, or interactive games, even virtual 31 00:02:33,000 --> 00:02:34,000 reality. 32 00:02:34,000 --> 00:02:38,000 The output of a computer may even include signals to control a robot. 33 00:02:38,000 --> 00:02:43,000 And when computers connect over the internet, the output from one computer becomes the input 34 00:02:43,000 --> 00:02:46,000 to another, and vice versa. 35 00:02:46,000 --> 00:02:52,000 You may have heard that computers work on ones and zeros, or you may have seen scary 36 00:02:52,000 --> 00:02:58,000 looking visuals like this, but almost nobody today actually deals directly with these ones 37 00:02:58,000 --> 00:02:59,000 and zeros. 38 00:02:59,000 --> 00:03:06,000 But ones and zeros do play a big role in how computers work on the inside. 39 00:03:06,000 --> 00:03:12,000 Inside a computer are electric wires and circuits that carry all the information in a computer. 40 00:03:12,000 --> 00:03:15,000 How do you store or represent information using electricity? 41 00:03:15,000 --> 00:03:20,000 Well, if you have a single wire with electricity flowing through it, the signal can either 42 00:03:20,000 --> 00:03:23,000 be on or off. 43 00:03:23,000 --> 00:03:26,000 That's not a lot of choices, but it's a really important start. 44 00:03:26,000 --> 00:03:35,000 With one wire, we can represent a yes or a no, true or false, a one or a zero, or anything 45 00:03:35,000 --> 00:03:37,000 else with only two options. 46 00:03:37,000 --> 00:03:42,000 This on-off state of a single wire is called a bit, and it's the smallest piece of information 47 00:03:42,000 --> 00:03:44,000 a computer can store. 48 00:03:44,000 --> 00:03:47,000 If you use more wires, you get more bits. 49 00:03:47,000 --> 00:03:53,000 More ones and zeros, with more bits, you can represent more complex information. 50 00:03:53,000 --> 00:04:01,000 But to understand that, we need to learn about something called the binary number system. 51 00:04:01,000 --> 00:04:07,000 In the decimal number system, we have 10 digits from 0 to 9, and that's how we've all learned 52 00:04:07,000 --> 00:04:08,000 to count. 53 00:04:08,000 --> 00:04:14,000 In the binary number system, we only have two digits, 0 and 1. 54 00:04:14,000 --> 00:04:17,000 With these two digits, we can count up to any number. 55 00:04:17,000 --> 00:04:19,000 Here's how this works. 56 00:04:19,000 --> 00:04:24,000 In the decimal number system we're all used to, each position in a number has a different 57 00:04:24,000 --> 00:04:25,000 value. 58 00:04:25,000 --> 00:04:31,000 There's the 1 position, the 10 position, the 100 position, and so on. 59 00:04:31,000 --> 00:04:36,000 For example, a 9 in the 100 position is a 900. 60 00:04:36,000 --> 00:04:42,000 In binary, each position also carries a value, but instead of multiplying by 10 each time, 61 00:04:42,000 --> 00:04:44,000 we multiply by 2. 62 00:04:44,000 --> 00:04:51,000 So there's the 1s position, the 2s position, the 4s position, the 8s position, and so on. 63 00:04:51,000 --> 00:04:57,000 For example, the number 9 in binary is 1001. 64 00:04:57,000 --> 00:05:07,000 To calculate the value, we add 1 times 8 plus 0 times 4 plus 0 times 2 plus 1 times 1. 65 00:05:07,000 --> 00:05:12,000 Almost nobody does this math because computers do it for us. 66 00:05:12,000 --> 00:05:17,000 What's important is that any number can be represented with only 1s and 0s, or by a bunch 67 00:05:17,000 --> 00:05:20,000 of wires that are on or off. 68 00:05:20,000 --> 00:05:24,000 The more wires you use, the larger the numbers you can store. 69 00:05:24,000 --> 00:05:32,000 With 8 wires, you can store numbers between 0 and 255, that's 8 1s. 70 00:05:32,000 --> 00:05:39,000 With just 32 wires, you can store all the way from 0 to over 4 billion. 71 00:05:39,000 --> 00:05:44,000 Using the binary number system, you can represent any number you like. 72 00:05:44,000 --> 00:05:50,000 But what about other types of information, like text, images, or sound? 73 00:05:50,000 --> 00:06:00,000 It turns out that all these things can also be represented with numbers. 74 00:06:00,000 --> 00:06:02,000 Think of all the letters in the alphabet. 75 00:06:02,000 --> 00:06:08,000 You could assign a number to each letter, A could be 1, B could be 2, and so on. 76 00:06:08,000 --> 00:06:12,000 You can then represent any word or paragraph as a sequence of numbers. 77 00:06:12,000 --> 00:06:19,000 And as we saw, these numbers can be stored as on or off electrical signals. 78 00:06:19,000 --> 00:06:30,000 Every word you see on every webpage or your phone is represented using a system like this. 79 00:06:30,000 --> 00:06:36,000 Now let's consider photos, videos, and all the graphics you see on a screen. 80 00:06:36,000 --> 00:06:43,000 All of these images are made out of teeny dots called pixels, and each pixel has a color. 81 00:06:43,000 --> 00:06:47,000 Each of the colors can be represented with numbers. 82 00:06:47,000 --> 00:06:52,000 When you consider that a typical image has millions of these pixels, and a typical video 83 00:06:52,000 --> 00:07:03,000 shows 30 images per second, now we're talking about a lot of data here. 84 00:07:03,000 --> 00:07:08,000 Every sound is basically a series of vibrations in the air. 85 00:07:08,000 --> 00:07:12,000 Vibrations can be represented graphically as a waveform. 86 00:07:12,000 --> 00:07:16,000 Any point on this waveform can be represented by a number. 87 00:07:16,000 --> 00:07:21,000 In this way, any sound can be broken down into a series of numbers. 88 00:07:21,000 --> 00:07:27,000 If you want higher quality sound, you would pick 32-bit audio over 8-bit audio. 89 00:07:27,000 --> 00:07:32,000 More bits means a higher range of numbers. 90 00:07:32,000 --> 00:07:37,000 When you use a computer to write code or make your own app, you're not dealing directly 91 00:07:37,000 --> 00:07:42,000 with these ones and zeros, but you will be dealing with images, or sound, or video. 92 00:07:42,000 --> 00:07:47,000 So if you want to understand how computers work on the inside, it all comes down to these 93 00:07:47,000 --> 00:07:52,000 simple ones and zeros, and the electrical signals in the circuits behind them. 94 00:07:52,000 --> 00:08:01,000 They are the backbone of how all computers input, store, process, and output information. 95 00:08:01,000 --> 00:08:05,000 Under the hood, all computers do the same four basic things. 96 00:08:05,000 --> 00:08:12,000 They input information, store and process the information, and then output information. 97 00:08:12,000 --> 00:08:16,000 Each of these things is done by a different part of the computer. 98 00:08:16,000 --> 00:08:22,000 There are input devices that take input from the outside world and convert it into binary 99 00:08:22,000 --> 00:08:24,000 information. 100 00:08:24,000 --> 00:08:27,000 There is memory to store this information. 101 00:08:27,000 --> 00:08:33,000 There is a central processing unit, or CPU, where all the calculations are done. 102 00:08:33,000 --> 00:08:39,000 And finally, there are output devices that take information and convert it into physical 103 00:08:39,000 --> 00:08:41,000 output. 104 00:08:41,000 --> 00:08:43,000 Let's talk about input first. 105 00:08:43,000 --> 00:08:47,000 Computers can take many different types of input, like the keyboard of a computer, the 106 00:08:47,000 --> 00:08:53,000 touchpad of a phone, a camera, a microphone, or a GPS. 107 00:08:53,000 --> 00:08:59,000 But even the sensors on a car, a thermostat, or a drone are also different input devices. 108 00:08:59,000 --> 00:09:03,000 Now let's look at a simple example of how input travels through a computer and becomes 109 00:09:03,000 --> 00:09:06,000 output. 110 00:09:06,000 --> 00:09:10,000 When you press a key on your keyboard, let's say the letter B, the keyboard converts the 111 00:09:10,000 --> 00:09:13,000 letter to a number. 112 00:09:13,000 --> 00:09:19,000 That number is sent as binary, ones and zeros, into the computer. 113 00:09:19,000 --> 00:09:25,000 Starting from this number, the CPU calculates how to display the letter B pixel by pixel. 114 00:09:25,000 --> 00:09:29,000 The CPU requests step-by-step instructions from memory, which tell it how to draw the 115 00:09:29,000 --> 00:09:36,000 letter B. The CPU runs these instructions and stores the results as pixels in memory. 116 00:09:37,000 --> 00:09:41,000 Finally, this pixel information is sent in binary to the screen. 117 00:09:41,000 --> 00:09:46,000 The screen is an output device, which converts the binary signals into the tiny lights and 118 00:09:46,000 --> 00:09:51,000 colors that make up what you see. 119 00:09:51,000 --> 00:09:55,000 This all happens so quickly it feels instantaneous. 120 00:09:55,000 --> 00:10:01,000 But to display each letter, a computer runs thousands of instructions, starting from the 121 00:10:01,000 --> 00:10:07,000 moment your finger presses the keyboard. 122 00:10:07,000 --> 00:10:10,000 In that example, the output device was the screen. 123 00:10:10,000 --> 00:10:14,000 But there are many different types of output which take a binary signal from the computer 124 00:10:14,000 --> 00:10:16,000 and do something in the physical world. 125 00:10:16,000 --> 00:10:22,000 For example, a speaker will play sound, and a 3D printer will print an object. 126 00:10:22,000 --> 00:10:28,000 Output devices can also control physical motion, like a robotic arm, the motor of a car, or 127 00:10:28,000 --> 00:10:33,000 the cutting tool of the milling machine that my company makes. 128 00:10:33,000 --> 00:10:38,000 New types of inputs and outputs let computers interact with the world in entirely new ways. 129 00:10:38,000 --> 00:10:44,000 This has been helped out by improvements to the speed and size of the memory and CPU. 130 00:10:44,000 --> 00:10:48,000 The more complicated a task is, and the more information that's input or output, the more 131 00:10:48,000 --> 00:10:53,000 processing power and memory a computer needs. 132 00:10:53,000 --> 00:10:58,000 Typing letters on a screen may be easy, but to do complicated 3D graphics or record a 133 00:10:58,000 --> 00:11:05,000 high-definition movie, modern computers often have multiple CPUs to process all that information 134 00:11:05,000 --> 00:11:10,000 and many gigabytes of memory to store it. 135 00:11:10,000 --> 00:11:16,000 No matter what it is you want to do with a computer, every single action is about inputting 136 00:11:16,000 --> 00:11:23,000 information from the physical world, storing and processing that information, and getting 137 00:11:23,000 --> 00:11:29,000 some output back into the physical world. 138 00:11:29,000 --> 00:11:35,000 When you look inside a computing device, you see a bunch of circuits, chips, wires, speakers, 139 00:11:35,000 --> 00:11:38,000 plugs, and all sorts of other stuff. 140 00:11:38,000 --> 00:11:40,000 This is the hardware. 141 00:11:40,000 --> 00:11:43,000 But what you don't see is the software. 142 00:11:43,000 --> 00:11:48,000 Software is all of the computer programs, or code, running on this machine. 143 00:11:48,000 --> 00:11:53,000 Software can be anything from apps and games to webpages and the data science software 144 00:11:53,000 --> 00:11:57,000 that me and my teams use at Amazon to understand how customers behave. 145 00:11:57,000 --> 00:12:02,000 But how do the hardware and the software interact with one another? 146 00:12:02,000 --> 00:12:07,000 Let's start at looking at a computer's central processing unit, or CPU. 147 00:12:07,000 --> 00:12:13,000 The CPU is the master chip that controls all the other parts of the computer. 148 00:12:13,000 --> 00:12:19,000 A CPU needs to do different things, so inside it has smaller, simpler parts that handle 149 00:12:19,000 --> 00:12:22,000 specific tasks. 150 00:12:22,000 --> 00:12:25,000 It has circuits to do simple math and logic. 151 00:12:25,000 --> 00:12:31,000 It has other circuits to send and receive information to and from different parts of 152 00:12:31,000 --> 00:12:33,000 the computer. 153 00:12:33,000 --> 00:12:41,000 The real magic of the CPU is how it knows which circuits to use and when to use them. 154 00:12:41,000 --> 00:12:47,000 The CPU receives simple commands that tell it which circuit to use to do a specific job. 155 00:12:47,000 --> 00:12:52,000 For example, an add command tells the CPU to use its adder circuit to calculate a new 156 00:12:52,000 --> 00:12:53,000 number. 157 00:12:53,000 --> 00:12:57,000 And then the store command tells the CPU to use a different circuit to save that result 158 00:12:57,000 --> 00:13:00,000 into memory. 159 00:13:00,000 --> 00:13:06,000 Just like numbers, all of these simple commands can be represented in binary 1s and 0s, or 160 00:13:06,000 --> 00:13:10,000 on and off electrical signals. 161 00:13:10,000 --> 00:13:16,000 The binary commands are stored in memory, and the CPU fetches and executes them in sequence, 162 00:13:16,000 --> 00:13:19,000 one after the other. 163 00:13:19,000 --> 00:13:24,000 This sequence of commands is in fact a very simple computer program. 164 00:13:24,000 --> 00:13:31,000 Binary code is the most basic form of software, and it controls all the hardware of a computer. 165 00:13:31,000 --> 00:13:34,000 These days, nobody writes software in binary. 166 00:13:34,000 --> 00:13:35,000 It would take forever! 167 00:13:36,000 --> 00:13:44,000 Today, the software we write looks more like this, or this, or even this. 168 00:13:44,000 --> 00:13:49,000 Programming languages like these let you type in commands in something that looks a lot 169 00:13:49,000 --> 00:13:51,000 like English. 170 00:13:51,000 --> 00:13:57,000 To draw a rectangle on the screen, you just need a single command. 171 00:13:57,000 --> 00:14:03,000 This high-level command is converted into hundreds or thousands of simpler binary commands 172 00:14:03,000 --> 00:14:09,000 that the CPU understands. 173 00:14:09,000 --> 00:14:12,000 Software tells the CPU what to do. 174 00:14:12,000 --> 00:14:17,000 But when you're listening to music and browsing the web and chatting with a friend, your computer 175 00:14:17,000 --> 00:14:20,000 is running multiple pieces of software all at once. 176 00:14:20,000 --> 00:14:24,000 So how do all of these programs get on the computer in the first place? 177 00:14:24,000 --> 00:14:27,000 And how can the CPU run them all at once? 178 00:14:27,000 --> 00:14:32,000 To find out, we'll have to take a look at the operating system. 179 00:14:32,000 --> 00:14:37,000 The operating system of the computer is the master program that manages how software gets 180 00:14:37,000 --> 00:14:39,000 to use the hardware of the computer. 181 00:14:39,000 --> 00:14:46,000 For example, I helped create the Windows operating system that runs on most personal computers. 182 00:14:46,000 --> 00:14:51,000 The operating system is a program with special abilities that let it control the other software 183 00:14:51,000 --> 00:14:53,000 on the computer. 184 00:14:53,000 --> 00:14:57,000 It lets you install new programs by loading them into your computer's memory. 185 00:14:57,000 --> 00:15:02,000 It decides when a program is run by the central processing unit, and whether that program 186 00:15:02,000 --> 00:15:06,000 can access the computer's input and output devices. 187 00:15:06,000 --> 00:15:11,000 And when you think your computer is running many programs at once, in reality, it's the 188 00:15:11,000 --> 00:15:17,000 operating system that's quickly switching between programs, sharing that CPU for fractions 189 00:15:17,000 --> 00:15:19,000 of a second. 190 00:15:19,000 --> 00:15:23,000 Inside every computer is an operating system managing software that controls the computer's 191 00:15:23,000 --> 00:15:24,000 hardware. 192 00:15:24,000 --> 00:15:28,000 The software is a series of commands made of simple binary code. 193 00:15:28,000 --> 00:15:32,000 And that binary code is just electrical signals flowing through billions of tiny circuits.