1 00:00:00,540 --> 00:00:02,460 So I was actually just back in Connecticut 2 00:00:02,460 --> 00:00:05,190 at my high school for the first time in years recently, 3 00:00:05,190 --> 00:00:09,480 and chatting with some of my successors about where I made my way in life, 4 00:00:09,480 --> 00:00:12,030 and what I really didn't do, actually, in high school. 5 00:00:12,030 --> 00:00:14,310 In fact, I gave a talk about all of the studies 6 00:00:14,310 --> 00:00:17,190 that I didn't discover when I was back in high school. 7 00:00:17,190 --> 00:00:19,980 Because I still remember wandering around the hallways 8 00:00:19,980 --> 00:00:22,300 when I was last there, looking in on various classrooms 9 00:00:22,300 --> 00:00:24,930 where I'd spent a lot of time, that there was one in particular 10 00:00:24,930 --> 00:00:26,370 that I spent no time in. 11 00:00:26,370 --> 00:00:28,470 And that was the computer science lab. 12 00:00:28,470 --> 00:00:31,590 I still vaguely remember peeking through the glass of the window 13 00:00:31,590 --> 00:00:35,100 when some of my friends were taking their introductory computer science 14 00:00:35,100 --> 00:00:38,220 classes, but I had no interest in it, honestly. 15 00:00:38,220 --> 00:00:41,670 I just assumed it was all about programming, and like C++ or Java, 16 00:00:41,670 --> 00:00:43,060 whatever those were. 17 00:00:43,060 --> 00:00:45,240 But it just didn't seem all that interesting to me. 18 00:00:45,240 --> 00:00:48,120 And any time I did look in, all my friends had their heads down, 19 00:00:48,120 --> 00:00:50,470 typing away, doing whatever it was they were doing. 20 00:00:50,470 --> 00:00:53,490 And so I focused on history, and English, 21 00:00:53,490 --> 00:00:56,070 and constitutional law was my favorite class in high school. 22 00:00:56,070 --> 00:00:59,640 And so when I got to Harvard some years later, I kind of just 23 00:00:59,640 --> 00:01:01,950 stuck with where I was comfortable. 24 00:01:01,950 --> 00:01:04,510 I felt like, well, I hadn't studied CS in high school, 25 00:01:04,510 --> 00:01:08,460 so all the other students who are taking CS here surely have a leg up 26 00:01:08,460 --> 00:01:09,600 and know way more than me. 27 00:01:09,600 --> 00:01:12,930 So I figured, ah, I thought of it too late. 28 00:01:12,930 --> 00:01:15,690 And there was this core CS50 my first year here. 29 00:01:15,690 --> 00:01:17,680 And it had this alluring reputation. 30 00:01:17,680 --> 00:01:19,140 There were a lot of students in it. 31 00:01:19,140 --> 00:01:21,750 But it really didn't seem like it was for me. 32 00:01:21,750 --> 00:01:23,740 I wasn't really a computer person in that way. 33 00:01:23,740 --> 00:01:24,950 And I felt like I was behind. 34 00:01:24,950 --> 00:01:28,470 I didn't want to hurt my GPA by taking something so unfamiliar to me. 35 00:01:28,470 --> 00:01:32,010 And so I stayed within my comfort zone, and I took more history, and government 36 00:01:32,010 --> 00:01:36,240 classes, and I declared my major to be-- or concentration to be government. 37 00:01:36,240 --> 00:01:40,340 And it wasn't until sophomore year when I finally got up the nerve to shop, 38 00:01:40,340 --> 00:01:40,890 so to speak-- 39 00:01:40,890 --> 00:01:45,000 Sit in on a class before you officially register-- this class called CS50. 40 00:01:45,000 --> 00:01:47,490 And I only got up the nerve to register for it 41 00:01:47,490 --> 00:01:51,150 officially because the professor at the time let me sign up for pass-fail. 42 00:01:51,150 --> 00:01:52,680 So no harm to the GPA. 43 00:01:52,680 --> 00:01:56,820 I was really able to explore really well beyond my comfort zone. 44 00:01:56,820 --> 00:02:01,110 And honestly, within weeks, I realized for the first time in like 18 years 45 00:02:01,110 --> 00:02:03,040 that homework can actually be fun. 46 00:02:03,040 --> 00:02:05,750 And if you find the field that's of interest to you, whether it's 47 00:02:05,750 --> 00:02:09,390 CS or anything else, by exploring things that you're not familiar with right 48 00:02:09,390 --> 00:02:13,520 now, you might have the same experience I did of going home on a Friday night. 49 00:02:13,520 --> 00:02:15,740 The problem set or homework assignment had just 50 00:02:15,740 --> 00:02:17,790 been released at like 7:00 PM every Friday night. 51 00:02:17,790 --> 00:02:23,060 And I would spend the entire evening on my laptop working on CS50's programming 52 00:02:23,060 --> 00:02:23,640 assignments. 53 00:02:23,640 --> 00:02:25,470 Because I finally realized what it was. 54 00:02:25,470 --> 00:02:29,010 And programming itself is not the ends of a course like this. 55 00:02:29,010 --> 00:02:31,220 It really is just about problem-solving. 56 00:02:31,220 --> 00:02:34,640 And so quickly did I realize, wow, I can use these kinds of ideas 57 00:02:34,640 --> 00:02:37,840 to go solve problems in other courses, to be more efficient, 58 00:02:37,840 --> 00:02:39,980 to be more creative in my extracurriculars. 59 00:02:39,980 --> 00:02:42,020 I realized, wow, I can now build some application 60 00:02:42,020 --> 00:02:45,170 to now make processes more easily accessible 61 00:02:45,170 --> 00:02:47,090 on campus, like the intramural sports program. 62 00:02:47,090 --> 00:02:49,920 I was able to overhaul just with a little bit of computer science. 63 00:02:49,920 --> 00:02:54,560 And if we distill today what took me all too long to discover, 64 00:02:54,560 --> 00:02:57,090 problem-solving really is kind of a picture 65 00:02:57,090 --> 00:02:59,630 like this, where you have some inputs, and the goal 66 00:02:59,630 --> 00:03:01,100 is to achieve some outputs. 67 00:03:01,100 --> 00:03:03,930 And that, in some sense, really is computer science. 68 00:03:03,930 --> 00:03:05,910 And programming, and a lot of the particulars 69 00:03:05,910 --> 00:03:09,140 that you learn in the classroom, are really just deeper 70 00:03:09,140 --> 00:03:11,580 dives into this very simple idea. 71 00:03:11,580 --> 00:03:14,410 But how do you get to that point of actually solving problems? 72 00:03:14,410 --> 00:03:17,200 Well, I eventually realized that you needed to do two things. 73 00:03:17,200 --> 00:03:20,550 One, you needed to represent these inputs and these outputs. 74 00:03:20,550 --> 00:03:22,740 That is, we just all have to agree how to do it. 75 00:03:22,740 --> 00:03:25,240 And then you actually have to do something with those inputs 76 00:03:25,240 --> 00:03:26,220 to get those outputs. 77 00:03:26,220 --> 00:03:28,560 And therein lies the problem-solving. 78 00:03:28,560 --> 00:03:31,680 And so how do you go about representing information? 79 00:03:31,680 --> 00:03:34,600 Well, I could represent information-- 80 00:03:34,600 --> 00:03:36,540 all I need is some kind of input. 81 00:03:36,540 --> 00:03:38,900 And here's the power cord to my laptop. 82 00:03:38,900 --> 00:03:41,520 And honestly, even if you have no idea how your computer works, 83 00:03:41,520 --> 00:03:44,040 odds are, you appreciate that this is pretty integral, 84 00:03:44,040 --> 00:03:47,850 having somehow electricity, some physical input come into the computer. 85 00:03:47,850 --> 00:03:49,920 And if you unplug it, it's off. 86 00:03:49,920 --> 00:03:51,150 If you plug it in, it's on. 87 00:03:51,150 --> 00:03:53,730 And batteries, of course, can persist this here too. 88 00:03:53,730 --> 00:03:58,290 But off and on maps really cleanly to what you all probably generally know 89 00:03:58,290 --> 00:04:01,130 to be true of computers, in that they only speak what language? 90 00:04:01,130 --> 00:04:01,840 AUDIENCE: Binary. 91 00:04:01,840 --> 00:04:02,920 DAVID MALAN: Yeah, binary. 92 00:04:02,920 --> 00:04:06,900 "Bi" meaning two, mapping to this concept of off and on, 93 00:04:06,900 --> 00:04:09,870 or as a computer scientist would say, 0 or 1. 94 00:04:09,870 --> 00:04:12,180 That's why we have 0s and 1s at the end of the day, 95 00:04:12,180 --> 00:04:14,460 because the simplest thing to do electrically 96 00:04:14,460 --> 00:04:17,460 is to either turn the power on or turn the power off. 97 00:04:17,460 --> 00:04:18,720 1 or 0. 98 00:04:18,720 --> 00:04:21,900 We could have called it A and B, but we call it 1 and 0. 99 00:04:21,900 --> 00:04:26,400 But if all you have in a computer is the ability to turn it on or turn it off, 100 00:04:26,400 --> 00:04:30,150 or to store some value-- kind of like a light switch goes on or off-- 101 00:04:30,150 --> 00:04:33,310 how can you possibly do anything interesting or solve problems? 102 00:04:33,310 --> 00:04:36,120 Well, let's just consider like a simple light bulb here. 103 00:04:36,120 --> 00:04:36,960 This has some power. 104 00:04:36,960 --> 00:04:38,280 It happens to have a battery. 105 00:04:38,280 --> 00:04:40,560 And if this thing is off, we'll just call it a 0. 106 00:04:40,560 --> 00:04:42,960 And if this thing is on, we'll call it a 1. 107 00:04:42,960 --> 00:04:45,000 So now we have a single switch, or what's 108 00:04:45,000 --> 00:04:46,890 known in computing as a transistor. 109 00:04:46,890 --> 00:04:50,790 In fact, inside of your computer are lots and lots-- millions of transistors 110 00:04:50,790 --> 00:04:52,800 that just turn things on and off. 111 00:04:52,800 --> 00:04:55,800 Well, if I have just one of these, I can only do 0 or 1. 112 00:04:55,800 --> 00:04:57,130 That's not all that interesting. 113 00:04:57,130 --> 00:05:00,000 That would seem to give us two problems total to solve. 114 00:05:00,000 --> 00:05:02,640 So how can we count higher than just 0 or 1? 115 00:05:02,640 --> 00:05:05,760 Well, I might take two of these, or three of these, 116 00:05:05,760 --> 00:05:08,580 and maybe start doing things a little more methodically. 117 00:05:08,580 --> 00:05:10,770 So I could do 1, 2, 3. 118 00:05:10,770 --> 00:05:13,080 So now I can clearly count as high as three. 119 00:05:13,080 --> 00:05:14,670 But that would seem to be it as well. 120 00:05:14,670 --> 00:05:15,060 But no. 121 00:05:15,060 --> 00:05:16,800 Computers are a little smarter than that, 122 00:05:16,800 --> 00:05:20,550 and we can actually adopt patterns of on and off. 123 00:05:20,550 --> 00:05:22,460 So this now, I'll claim is 0. 124 00:05:22,460 --> 00:05:24,090 All three of these light bulbs are off. 125 00:05:24,090 --> 00:05:27,000 Let me turn on this one on, thereby representing 126 00:05:27,000 --> 00:05:28,320 what I'm going to call a 1. 127 00:05:28,320 --> 00:05:29,070 But you know what? 128 00:05:29,070 --> 00:05:32,620 Now I'm going to go ahead and claim that that's how a computer would store a 2. 129 00:05:32,620 --> 00:05:35,040 It would turn a different light switch on, the second one. 130 00:05:35,040 --> 00:05:35,790 And you know what? 131 00:05:35,790 --> 00:05:39,690 If it turns the first one back on, this is how a computer stores a 3. 132 00:05:39,690 --> 00:05:42,990 And now just take a guess, if I do this-- 133 00:05:42,990 --> 00:05:45,750 uncomfortably-- what is the computer perhaps now storing? 134 00:05:45,750 --> 00:05:46,530 AUDIENCE: 4. 135 00:05:46,530 --> 00:05:47,190 DAVID MALAN: 4. 136 00:05:47,190 --> 00:05:48,270 This happens to be 6. 137 00:05:48,270 --> 00:05:49,920 This is now 7. 138 00:05:49,920 --> 00:05:50,880 Why? 139 00:05:50,880 --> 00:05:52,770 How did I choose those particular patterns? 140 00:05:52,770 --> 00:05:54,900 Well, it turns out this is something that all of us 141 00:05:54,900 --> 00:05:56,970 are probably really familiar with. 142 00:05:56,970 --> 00:06:00,870 If you think about our grade school understanding of numbers, if I draw 143 00:06:00,870 --> 00:06:03,570 something on the screen quite simply-- 144 00:06:03,570 --> 00:06:04,950 like this pattern of symbols. 145 00:06:04,950 --> 00:06:06,480 1, 2, 3. 146 00:06:06,480 --> 00:06:08,460 This is, of course, 123. 147 00:06:08,460 --> 00:06:09,240 But why? 148 00:06:09,240 --> 00:06:11,460 Because all of us just pretty instantaneously did 149 00:06:11,460 --> 00:06:15,690 the mental arithmetic of this being the ones place, this is the tens place, 150 00:06:15,690 --> 00:06:17,250 this is the hundreds place. 151 00:06:17,250 --> 00:06:19,620 And then what did you probably do in that split second? 152 00:06:19,620 --> 00:06:25,530 Well, you did 100 times 1 plus 10 times 2 plus 1 times 3, which of course gives 153 00:06:25,530 --> 00:06:29,690 you 100 plus 20 plus 3, or 123. 154 00:06:29,690 --> 00:06:33,030 Now, that's a bit of a circular argument because that's kind of where I started, 155 00:06:33,030 --> 00:06:34,350 but now these symbols-- 156 00:06:34,350 --> 00:06:37,950 these curves on the screen, 1, 2, 3-- 157 00:06:37,950 --> 00:06:44,670 actually have now meaning that we've all agreed represents the human number 123. 158 00:06:44,670 --> 00:06:47,320 So computers are actually fundamentally the same thing. 159 00:06:47,320 --> 00:06:52,510 And in some sense, they're even simpler than us humans in the following way. 160 00:06:52,510 --> 00:06:57,570 If you have the same number of placeholders, and we write down-- 161 00:06:57,570 --> 00:07:01,410 with great difficulty-- if we write down, say, 162 00:07:01,410 --> 00:07:06,290 three places, or three light bulbs, if you will, but doing it now textually, 163 00:07:06,290 --> 00:07:09,900 and I write down, for instance, 0, 0, 0, you 164 00:07:09,900 --> 00:07:12,120 can probably guess that in the world of computers, 165 00:07:12,120 --> 00:07:16,590 if you've got three switches that are all off, this represents the number 0. 166 00:07:16,590 --> 00:07:20,850 And if I turn one of these light bulbs on, so to speak, this of course-- 167 00:07:20,850 --> 00:07:23,940 as before-- is going to be the number that I called 1. 168 00:07:23,940 --> 00:07:28,380 Well, if I now do not just change this one, but change this to a 0-- 169 00:07:28,380 --> 00:07:31,530 and this is where maybe my light bulb patterns got a little non-obvious-- 170 00:07:31,530 --> 00:07:32,850 why is this 2? 171 00:07:32,850 --> 00:07:36,240 Well, it's the same mental arithmetic but just with different places. 172 00:07:36,240 --> 00:07:38,850 A computer doesn't use powers of 10, so to speak-- 173 00:07:38,850 --> 00:07:41,340 10 to the 0, 10 to the 1, 10 to the 2-- 174 00:07:41,340 --> 00:07:42,690 but powers of 2. 175 00:07:42,690 --> 00:07:45,150 So this is 2 to the 0, or the ones place. 176 00:07:45,150 --> 00:07:47,130 This is 2 to the 1, or the twos place. 177 00:07:47,130 --> 00:07:49,830 This is 2 to the 2, or the fours place. 178 00:07:49,830 --> 00:07:52,720 And so you just need to turn these light bulbs on and off 179 00:07:52,720 --> 00:07:55,020 based on this kind of pattern to get whatever number it 180 00:07:55,020 --> 00:07:56,020 is you're interested in. 181 00:07:56,020 --> 00:08:00,960 So this is 2 because it's 4 times 0 plus 2 times 1 plus 1 times 0. 182 00:08:00,960 --> 00:08:04,300 Why is this three when I turned two light bulbs on earlier? 183 00:08:04,300 --> 00:08:05,190 The same reasoning. 184 00:08:05,190 --> 00:08:10,110 And what's the highest I can count with just three light bulbs, or three 185 00:08:10,110 --> 00:08:11,860 0s and 1s? 186 00:08:11,860 --> 00:08:16,180 7, just because you got a 4 plus a 2 plus a 1, and so forth. 187 00:08:16,180 --> 00:08:19,640 And what would happen, then, if I wanted to count as high as 8, would you think? 188 00:08:19,640 --> 00:08:20,520 AUDIENCE: [INAUDIBLE] 189 00:08:20,520 --> 00:08:22,080 DAVID MALAN: Yeah, you need to add another place. 190 00:08:22,080 --> 00:08:24,250 Or really, you need more physical hardware. 191 00:08:24,250 --> 00:08:26,580 And this is why your computer can only count so high 192 00:08:26,580 --> 00:08:28,320 or store so much information. 193 00:08:28,320 --> 00:08:31,890 You need an additional light switch-- or another transistor, if you will-- 194 00:08:31,890 --> 00:08:34,590 to actually store additional information. 195 00:08:34,590 --> 00:08:35,720 So that, then, is binary. 196 00:08:35,720 --> 00:08:39,960 If you've just known intuitively computers only speak 0s and 1s, why? 197 00:08:39,960 --> 00:08:43,200 Well, that's because they start with electricity as their physical input. 198 00:08:43,200 --> 00:08:46,710 We humans have just all agreed to represent values 199 00:08:46,710 --> 00:08:51,060 in this way using binary by just having these patterns of 0s and 1s. 200 00:08:51,060 --> 00:08:53,850 But that pretty much makes for a very expensive calculator, 201 00:08:53,850 --> 00:08:55,350 if all you have are numbers. 202 00:08:55,350 --> 00:09:00,930 So how do you get from numbers and from electricity to now, 203 00:09:00,930 --> 00:09:02,410 letters, say of the alphabet? 204 00:09:02,410 --> 00:09:03,810 What could we do? 205 00:09:03,810 --> 00:09:07,080 How do we now enable spreadsheet programs, and word processors, 206 00:09:07,080 --> 00:09:09,760 and text messaging, and email clients, and the like? 207 00:09:09,760 --> 00:09:15,220 What can we all do if our only input is electricity, or in turn, 0s and 1s? 208 00:09:15,220 --> 00:09:16,100 AUDIENCE: [INAUDIBLE] 209 00:09:16,100 --> 00:09:16,690 DAVID MALAN: Say again? 210 00:09:16,690 --> 00:09:18,450 AUDIENCE: Assign number values to letters? 211 00:09:18,450 --> 00:09:21,080 DAVID MALAN: Yeah, we can just assign number values to letters. 212 00:09:21,080 --> 00:09:22,960 So you know what we could go ahead and do, 213 00:09:22,960 --> 00:09:25,720 and if we want to represent letters of the alphabet, 214 00:09:25,720 --> 00:09:28,300 as before, the only goal at hand is to just agree 215 00:09:28,300 --> 00:09:29,940 on how to represent that information. 216 00:09:29,940 --> 00:09:31,780 So let's pick a few letters of the alphabet. 217 00:09:31,780 --> 00:09:38,650 A, B, C, D, E, F, G, H, I. We could just say, you know what? 218 00:09:38,650 --> 00:09:42,710 Let's just agree to represent A as 1, and B as 2, and C as 3. 219 00:09:42,710 --> 00:09:45,130 Doesn't really matter, so long as we all agree to do that. 220 00:09:45,130 --> 00:09:47,740 But it turns out, some years ago, humans decided 221 00:09:47,740 --> 00:09:51,160 that A is actually going to be 65, and B is 66, 222 00:09:51,160 --> 00:09:58,690 and C is 67, 68, 69, 70, 71, 72, 73, and so forth. 223 00:09:58,690 --> 00:10:00,460 This is known as ASCII or Unicode. 224 00:10:00,460 --> 00:10:03,570 It's just a system that humans agreed decades ago 225 00:10:03,570 --> 00:10:07,120 shall be used by computers to represent letters of the alphabet 226 00:10:07,120 --> 00:10:09,880 just by storing numbers, and those numbers in turn 227 00:10:09,880 --> 00:10:11,980 are just the result of the computer turning 228 00:10:11,980 --> 00:10:15,470 little switches known as transistors on and off in these certain patterns. 229 00:10:15,470 --> 00:10:17,470 And let me, with the wave of a hand, assure sure 230 00:10:17,470 --> 00:10:19,420 that we can represent colors, and sounds, 231 00:10:19,420 --> 00:10:22,010 and videos in very similar ways. 232 00:10:22,010 --> 00:10:25,780 But we need to actually just agree on how to do this. 233 00:10:25,780 --> 00:10:27,820 So in fact, there's an opportunity here perhaps 234 00:10:27,820 --> 00:10:32,020 to write a message in exactly the same way that a computer could. 235 00:10:32,020 --> 00:10:34,990 If you could humor me, maybe, with eight volunteers? 236 00:10:34,990 --> 00:10:36,950 Could we get some eight volunteers up on stage? 237 00:10:36,950 --> 00:10:38,140 OK, 1, 2. 238 00:10:38,140 --> 00:10:39,310 Let me look a little harder. 239 00:10:39,310 --> 00:10:41,110 3, 4. 240 00:10:41,110 --> 00:10:43,060 Can I go a little farther? 241 00:10:43,060 --> 00:10:44,380 I see no hands in the back. 242 00:10:44,380 --> 00:10:45,440 OK. 243 00:10:45,440 --> 00:10:45,940 There we go. 244 00:10:45,940 --> 00:10:47,200 5. 245 00:10:47,200 --> 00:10:48,030 6 over there. 246 00:10:48,030 --> 00:10:49,660 I see someone pointing at someone else. 247 00:10:49,660 --> 00:10:50,680 Come on, 7. 248 00:10:50,680 --> 00:10:52,180 And let's go 8, over here. 249 00:10:52,180 --> 00:10:53,360 Come on down. 250 00:10:53,360 --> 00:10:55,390 And I just need you to go ahead, if you could, 251 00:10:55,390 --> 00:10:59,300 and stand beneath these placeholders here on the slide, which 252 00:10:59,300 --> 00:11:01,930 I've gone ahead and rotated just so that they fit a little more 253 00:11:01,930 --> 00:11:03,600 visibly on the screen. 254 00:11:03,600 --> 00:11:04,150 Come on over. 255 00:11:04,150 --> 00:11:04,510 What's your name? 256 00:11:04,510 --> 00:11:04,790 AUDIENCE: Matt. 257 00:11:04,790 --> 00:11:05,540 DAVID MALAN: Matt. 258 00:11:05,540 --> 00:11:07,770 Come on over and stand under the 128. 259 00:11:07,770 --> 00:11:08,480 What's your name? 260 00:11:08,480 --> 00:11:08,860 AUDIENCE: Mira. 261 00:11:08,860 --> 00:11:09,190 DAVID MALAN: Mira. 262 00:11:09,190 --> 00:11:09,710 David. 263 00:11:09,710 --> 00:11:10,300 AUDIENCE: Hey. 264 00:11:10,300 --> 00:11:10,730 DAVID MALAN: David. 265 00:11:10,730 --> 00:11:11,430 Nice to meet you. 266 00:11:11,430 --> 00:11:12,340 Hello. 267 00:11:12,340 --> 00:11:12,920 David. 268 00:11:12,920 --> 00:11:14,620 Nice to meet you. 269 00:11:14,620 --> 00:11:15,330 AUDIENCE: Anesha. 270 00:11:15,330 --> 00:11:16,450 DAVID MALAN: Anesha, David. 271 00:11:16,450 --> 00:11:17,360 And Monica. 272 00:11:17,360 --> 00:11:18,070 Nice to meet you. 273 00:11:18,070 --> 00:11:18,760 And what was your name? 274 00:11:18,760 --> 00:11:19,300 AUDIENCE: Chris. 275 00:11:19,300 --> 00:11:19,720 DAVID MALAN: Chris. 276 00:11:19,720 --> 00:11:20,600 Nice to meet you as well. 277 00:11:20,600 --> 00:11:22,660 So each of these guys is going to have to scooch a little closer 278 00:11:22,660 --> 00:11:23,380 to each other. 279 00:11:23,380 --> 00:11:24,400 And you know what? 280 00:11:24,400 --> 00:11:27,930 If this isn't too much effort, could we actually get eight more volunteers now 281 00:11:27,930 --> 00:11:29,230 that you know what you're vol-- 282 00:11:29,230 --> 00:11:30,770 OK, now everyone's hand goes up. 283 00:11:30,770 --> 00:11:31,270 OK. 284 00:11:31,270 --> 00:11:34,600 1, 2, 3, 4, 5, 6, 7, 8, if you could. 285 00:11:34,600 --> 00:11:36,460 Come on down. 286 00:11:36,460 --> 00:11:38,020 We'll do this round more quickly. 287 00:11:38,020 --> 00:11:42,970 And what you'll notice now that we have a bytes' worth of volunteers here. 288 00:11:42,970 --> 00:11:44,120 What is a byte? 289 00:11:44,120 --> 00:11:45,730 A byte is just 8 bits. 290 00:11:45,730 --> 00:11:49,030 It's a more useful unit of measure than just a 0 or 1. 291 00:11:49,030 --> 00:11:51,040 And notice the terminology here too. 292 00:11:51,040 --> 00:11:54,630 A bit-- a 0 or 1-- is a binary digit. 293 00:11:54,630 --> 00:11:56,770 There's the etymology of just that simple phrase. 294 00:11:56,770 --> 00:11:58,070 And a quick hello to AJ. 295 00:11:58,070 --> 00:11:58,610 AUDIENCE: AJ. 296 00:11:58,610 --> 00:11:59,320 DAVID MALAN: David. 297 00:11:59,320 --> 00:11:59,590 Jay. 298 00:11:59,590 --> 00:11:59,930 AUDIENCE: Hi. 299 00:11:59,930 --> 00:12:00,800 DAVID MALAN: David. 300 00:12:00,800 --> 00:12:05,380 Nice to meet you. 301 00:12:05,380 --> 00:12:05,730 AUDIENCE: Bianca. 302 00:12:05,730 --> 00:12:07,770 DAVID MALAN: David, and nice to meet you as well. 303 00:12:07,770 --> 00:12:09,500 Here we have our second byte of humans. 304 00:12:09,500 --> 00:12:10,000 And-- 305 00:12:10,000 --> 00:12:10,940 AUDIENCE: [INAUDIBLE] 306 00:12:10,940 --> 00:12:11,890 DAVID MALAN: What's that? 307 00:12:11,890 --> 00:12:13,340 AUDIENCE: We have seven right here. 308 00:12:13,340 --> 00:12:15,040 DAVID MALAN: We have a seven right here? 309 00:12:15,040 --> 00:12:16,820 1, 2, 3, 4, 5, 6, 7. 310 00:12:16,820 --> 00:12:19,420 1, 2, 3, 4, 5, 6, 7, 8. 311 00:12:19,420 --> 00:12:20,180 We have a bug. 312 00:12:20,180 --> 00:12:20,680 Here we go. 313 00:12:20,680 --> 00:12:21,880 Come on up. 314 00:12:21,880 --> 00:12:23,110 Thank you. 315 00:12:23,110 --> 00:12:25,690 Thank you very much. 316 00:12:25,690 --> 00:12:28,430 In computer science, that's an off-by-one error. 317 00:12:28,430 --> 00:12:29,140 What's your name? 318 00:12:29,140 --> 00:12:29,500 AUDIENCE: Helen. 319 00:12:29,500 --> 00:12:30,170 DAVID MALAN: Helen. 320 00:12:30,170 --> 00:12:30,540 David. 321 00:12:30,540 --> 00:12:30,900 Nice to meet you. 322 00:12:30,900 --> 00:12:34,150 Go ahead and join, I guess, this group right here in the middle, if you could. 323 00:12:34,150 --> 00:12:37,480 So these folks here hopefully do have cell phones on you. 324 00:12:37,480 --> 00:12:40,420 Key detail I probably should have mentioned earlier. 325 00:12:40,420 --> 00:12:42,280 That's OK if you don't. 326 00:12:42,280 --> 00:12:43,000 That's OK. 327 00:12:43,000 --> 00:12:43,960 We're going to recover. 328 00:12:43,960 --> 00:12:47,470 Whoever doesn't have a cell phone is now going to get a flashlight. 329 00:12:47,470 --> 00:12:48,730 OK. 330 00:12:48,730 --> 00:12:49,630 Let's do this. 331 00:12:49,630 --> 00:12:50,530 OK. 332 00:12:50,530 --> 00:12:51,250 Key detail. 333 00:12:51,250 --> 00:12:52,570 Sorry, you can go ahead and turn that off. 334 00:12:52,570 --> 00:12:54,660 Going to cross my fingers here that we have enough light bulbs. 335 00:12:54,660 --> 00:12:55,660 Hang on. 336 00:12:55,660 --> 00:12:59,950 Let's go ahead now and turn on, if you could, three light bulbs here. 337 00:12:59,950 --> 00:13:01,990 So you don't have your phone? 338 00:13:01,990 --> 00:13:04,800 Here is a nice iPhone XS. 339 00:13:04,800 --> 00:13:05,300 OK. 340 00:13:05,300 --> 00:13:07,570 [LAUGHTER] 341 00:13:07,570 --> 00:13:09,370 1, 2, 3, 4. 342 00:13:09,370 --> 00:13:10,750 Let's go ahead and turn yours on. 343 00:13:10,750 --> 00:13:12,530 Can you swap phones for a moment? 344 00:13:12,530 --> 00:13:15,490 So we have two light bulbs there, and we don't need anyone else's phone 345 00:13:15,490 --> 00:13:16,040 on just yet. 346 00:13:16,040 --> 00:13:17,800 Could you turn your light bulb on? 347 00:13:17,800 --> 00:13:20,170 And could you turn your light bulb on? 348 00:13:20,170 --> 00:13:22,840 And we need just one light bulb here, if you could turn that on. 349 00:13:22,840 --> 00:13:24,790 So let me step out of the way. 350 00:13:24,790 --> 00:13:29,110 And you'll see that we have someone in the 64s place whose light is 351 00:13:29,110 --> 00:13:33,760 on, in the 8s place, then again in the 64s place and the 8s place, 352 00:13:33,760 --> 00:13:35,240 and lastly, the 1. 353 00:13:35,240 --> 00:13:40,120 So if a computer indeed had some 16 switches or transistors inside of it 354 00:13:40,120 --> 00:13:44,140 and turned on those switches in this particular order, 355 00:13:44,140 --> 00:13:46,910 what message are these humans here representing at the moment? 356 00:13:46,910 --> 00:13:47,450 AUDIENCE: Hi. 357 00:13:47,450 --> 00:13:48,850 DAVID MALAN: So it's indeed hi. 358 00:13:48,850 --> 00:13:49,350 Why? 359 00:13:49,350 --> 00:13:54,120 Because the mapping we arbitrarily chose but globally decided on is that 72 is H 360 00:13:54,120 --> 00:13:55,840 and 73 is I. 361 00:13:55,840 --> 00:13:57,520 Well, let's try one more further. 362 00:13:57,520 --> 00:14:00,380 At the moment, we're just using two bytes of humans, if you will. 363 00:14:00,380 --> 00:14:01,840 Two units of eight. 364 00:14:01,840 --> 00:14:05,200 But suppose that we didn't just draw an imaginary line in between them 365 00:14:05,200 --> 00:14:08,710 and count only up to the ones place through that 128s place. 366 00:14:08,710 --> 00:14:11,050 But suppose that we treated everyone as one 367 00:14:11,050 --> 00:14:14,510 much bigger value so that we could count much higher. 368 00:14:14,510 --> 00:14:18,330 So now, these humans are taking on the value of a 128s place, 369 00:14:18,330 --> 00:14:21,570 but then the 256, 512, 1024. 370 00:14:21,570 --> 00:14:23,520 All I'm doing is multiplying by 2. 371 00:14:23,520 --> 00:14:26,910 I'm going to need one more volunteer, and I'll take on this role over here. 372 00:14:26,910 --> 00:14:31,530 If I were to be at the very end here, I'd now have 17 bits on stage. 373 00:14:31,530 --> 00:14:33,660 17 switches or transistors. 374 00:14:33,660 --> 00:14:36,330 Let me go ahead and turn on just some of these, if we could. 375 00:14:36,330 --> 00:14:38,730 Most of them, we might have to borrow a couple of phones. 376 00:14:38,730 --> 00:14:41,560 Let's go ahead and give-- if you could turn your phone on. 377 00:14:41,560 --> 00:14:42,060 Here. 378 00:14:42,060 --> 00:14:42,730 Your flashlight. 379 00:14:42,730 --> 00:14:44,700 Let me-- that's technically yours. 380 00:14:44,700 --> 00:14:46,450 Can we borrow your phone for a moment? 381 00:14:46,450 --> 00:14:46,950 OK. 382 00:14:46,950 --> 00:14:52,140 Your phone is going over here to the 32,000s place. 383 00:14:52,140 --> 00:14:53,640 We need to turn yours on. 384 00:14:53,640 --> 00:14:55,620 OK, I'll turn mine on over there. 385 00:14:55,620 --> 00:14:57,480 So we need 1, 2. 386 00:14:57,480 --> 00:14:59,550 Can we give you 3, 4 on? 387 00:14:59,550 --> 00:15:00,980 Can we borrow that? 388 00:15:00,980 --> 00:15:01,650 3, 4. 389 00:15:01,650 --> 00:15:03,170 Can we-- keep the phones coming. 390 00:15:03,170 --> 00:15:05,190 [CHUCKLING] 391 00:15:05,190 --> 00:15:05,940 3, 4. 392 00:15:05,940 --> 00:15:06,990 So 1, 2, 3, 4. 393 00:15:06,990 --> 00:15:08,220 And then we skip 1. 394 00:15:08,220 --> 00:15:10,950 And then we need you two to be on, if that's OK. 395 00:15:10,950 --> 00:15:14,310 And then over here, thankfully, we need just one light bulb on. 396 00:15:14,310 --> 00:15:16,230 So now it's your chance. 397 00:15:16,230 --> 00:15:18,520 If a computer were using this many bits-- 398 00:15:18,520 --> 00:15:19,320 16 bits. 399 00:15:19,320 --> 00:15:25,030 And if I stand in place now, 17 bits, where I represent 65,536, 400 00:15:25,030 --> 00:15:27,780 and our volunteers all the way on the end represents the number 1, 401 00:15:27,780 --> 00:15:31,910 and you do this math, what number are we all representing? 402 00:15:35,010 --> 00:15:36,560 OK, no one's going to get this right. 403 00:15:36,560 --> 00:15:40,460 It's 128,514. 404 00:15:40,460 --> 00:15:42,170 What might that message say? 405 00:15:45,080 --> 00:15:49,340 Well, there's not nearly enough clues in mine, but it's actually this. 406 00:15:49,340 --> 00:15:53,610 So if you've sent today or recently an email or a text message with an emoji, 407 00:15:53,610 --> 00:15:54,860 you might have sent this one-- 408 00:15:54,860 --> 00:15:56,610 Face with Tears of Joy. 409 00:15:56,610 --> 00:15:58,200 So that's its official name. 410 00:15:58,200 --> 00:15:59,930 But it's not an image per se. 411 00:15:59,930 --> 00:16:02,480 It's actually a character. 412 00:16:02,480 --> 00:16:05,370 And in fact, you might know that you have so many emojis these days, 413 00:16:05,370 --> 00:16:07,400 and that's because computers and humans who 414 00:16:07,400 --> 00:16:10,580 use them have started using way more than 8 bits. 415 00:16:10,580 --> 00:16:12,540 Way more than 16 or 17 bits. 416 00:16:12,540 --> 00:16:17,660 Sometimes 24 or 32 bits, which gives us so many darn possible permutations 417 00:16:17,660 --> 00:16:21,170 of 0s and 1s, or switches being turned on or off, that frankly, it's 418 00:16:21,170 --> 00:16:23,270 just become kind of a cultural thing that we 419 00:16:23,270 --> 00:16:26,330 have so many darn possibilities, let's start using some of them 420 00:16:26,330 --> 00:16:30,500 for more silly reasons, if you will, like emojis. 421 00:16:30,500 --> 00:16:35,090 So if you ever receive today or hereafter a face with tears of joy, 422 00:16:35,090 --> 00:16:38,060 what your friends have really sent to you is a pattern of 0s 423 00:16:38,060 --> 00:16:41,060 and 1s somehow implemented with electricity or wavelengths of light 424 00:16:41,060 --> 00:16:46,640 that represents, rather mundanely, 128,514. 425 00:16:46,640 --> 00:16:49,670 So if we could, a round of applause for our human volunteers here. 426 00:16:49,670 --> 00:16:50,400 [APPLAUSE] 427 00:16:50,400 --> 00:16:51,530 Let me borrow this. 428 00:16:51,530 --> 00:16:54,230 Thank you. 429 00:16:54,230 --> 00:16:57,400 If you'd like to step off stage, we have a little something for each of you. 430 00:16:57,400 --> 00:17:00,180 So we have just one last question to answer. 431 00:17:00,180 --> 00:17:02,100 Thank you all so much. 432 00:17:02,100 --> 00:17:04,080 We have just one other question to answer, 433 00:17:04,080 --> 00:17:07,410 which is, if problem-solving ultimately boils down 434 00:17:07,410 --> 00:17:10,440 to representing inputs and outputs, what is 435 00:17:10,440 --> 00:17:14,460 the process that we pass those inputs through in order to get those outputs? 436 00:17:14,460 --> 00:17:17,760 What is it you learn, ultimately, in a course on computer science? 437 00:17:17,760 --> 00:17:21,240 Well, it's perhaps best explained by way of a problem. 438 00:17:21,240 --> 00:17:23,400 So here is an old-school problem where you 439 00:17:23,400 --> 00:17:27,110 have a whole bunch of names and numbers alphabetically sorted from A through Z, 440 00:17:27,110 --> 00:17:28,320 and you want to find someone. 441 00:17:28,320 --> 00:17:30,300 And even though this is pretty old-school, 442 00:17:30,300 --> 00:17:33,870 it's honestly the same thing as the address book or the contacts app 443 00:17:33,870 --> 00:17:35,790 that you have in your own iPhone or Android 444 00:17:35,790 --> 00:17:37,950 phone, or any particular device. 445 00:17:37,950 --> 00:17:39,660 If you scroll through your contacts, odds 446 00:17:39,660 --> 00:17:42,840 are they're A through Z, alphabetized by first name or last name. 447 00:17:42,840 --> 00:17:45,600 So this is just representative of the same problem 448 00:17:45,600 --> 00:17:48,900 that you and I solve any time we look someone up in our phone. 449 00:17:48,900 --> 00:17:52,080 Well, if I want to look up an old friend-- someone like Mike Smith, 450 00:17:52,080 --> 00:17:53,400 last name starting with S-- 451 00:17:53,400 --> 00:17:56,130 I could certainly just start at the beginning of this book 452 00:17:56,130 --> 00:17:59,520 and do 1, 2, 3, 4. 453 00:17:59,520 --> 00:18:02,520 And that's a step-by-step process, otherwise known as an algorithm. 454 00:18:02,520 --> 00:18:03,810 And is that algorithm correct? 455 00:18:03,810 --> 00:18:04,990 Will I find Mike Smith? 456 00:18:04,990 --> 00:18:05,580 AUDIENCE: Yes. 457 00:18:05,580 --> 00:18:06,330 DAVID MALAN: Yeah. 458 00:18:06,330 --> 00:18:08,940 I mean, it's a little tedious, and it's a little slow, but if Mike is in here, 459 00:18:08,940 --> 00:18:10,020 I'll eventually find him. 460 00:18:10,020 --> 00:18:11,430 But I'm not going to do that. 461 00:18:11,430 --> 00:18:13,270 I know he's going to be roughly at the end. 462 00:18:13,270 --> 00:18:15,630 So maybe a little more intelligently or efficiently, 463 00:18:15,630 --> 00:18:19,720 I could do 2, 4, 6, 8, 10, 12, and so forth. 464 00:18:19,720 --> 00:18:22,140 It's going to fly me through the phone book twice as fast. 465 00:18:22,140 --> 00:18:25,320 And is that algorithm or step-by-step process correct? 466 00:18:25,320 --> 00:18:26,930 AUDIENCE: [INAUDIBLE] 467 00:18:26,930 --> 00:18:28,350 DAVID MALAN: A literal contention. 468 00:18:28,350 --> 00:18:31,090 It's almost correct, except if I get unlucky and might 469 00:18:31,090 --> 00:18:34,230 get sandwiched between two pages because I'm a little aggressively flying 470 00:18:34,230 --> 00:18:35,190 through the phone book. 471 00:18:35,190 --> 00:18:36,180 But no big deal. 472 00:18:36,180 --> 00:18:40,980 If I maybe hit the T section, I could maybe double back one or few pages 473 00:18:40,980 --> 00:18:41,520 and fix that. 474 00:18:41,520 --> 00:18:43,020 But none of us are going to do that. 475 00:18:43,020 --> 00:18:44,580 What's a typical person going to do? 476 00:18:44,580 --> 00:18:48,120 And really, what's a computer going to do, be it in your phone or a laptop 477 00:18:48,120 --> 00:18:49,070 these days? 478 00:18:49,070 --> 00:18:49,430 AUDIENCE: [INAUDIBLE] 479 00:18:49,430 --> 00:18:50,070 DAVID MALAN: Yeah. 480 00:18:50,070 --> 00:18:52,650 It's going to go roughly maybe to the middle, or a little biased 481 00:18:52,650 --> 00:18:55,350 toward the right, because you know S is a little alphabetically later 482 00:18:55,350 --> 00:18:56,220 than most letters. 483 00:18:56,220 --> 00:18:59,940 And I look down, for instance, here, and I see, oh, I'm in the M section. 484 00:18:59,940 --> 00:19:02,490 And so I know that Mike is not this way. 485 00:19:02,490 --> 00:19:03,720 He's definitely this way. 486 00:19:03,720 --> 00:19:08,980 So both metaphorically and literally, can I tear a problem like this in half? 487 00:19:08,980 --> 00:19:11,190 This is actually not that hard vertically. 488 00:19:11,190 --> 00:19:13,530 I can tear the problem in half, and now I'm 489 00:19:13,530 --> 00:19:16,980 left not with 1,000 pages with which I began, but maybe 500. 490 00:19:16,980 --> 00:19:20,940 And I can do it again, and whittle myself down to like 250 pages. 491 00:19:20,940 --> 00:19:23,010 And again, down to 125. 492 00:19:23,010 --> 00:19:25,560 And again and again and again until I'm left with, hopefully, 493 00:19:25,560 --> 00:19:27,510 just one or so page. 494 00:19:27,510 --> 00:19:30,720 But what's powerful about, honestly, that intuition that odds are you 495 00:19:30,720 --> 00:19:35,820 had when you walked in this door is that, in just 10 or so steps, 496 00:19:35,820 --> 00:19:37,560 can you find Mike Smith in a phone book? 497 00:19:37,560 --> 00:19:41,910 In just 10 or so steps, can iOS or Android find someone in your contacts 498 00:19:41,910 --> 00:19:44,550 by dividing and conquering, dividing and conquering? 499 00:19:44,550 --> 00:19:46,470 Whereas the other algorithms might have taken, 500 00:19:46,470 --> 00:19:50,290 gosh, like 1,000 steps, 500 steps, almost as many pages as there are. 501 00:19:50,290 --> 00:19:52,170 And so that's an algorithm, and that's what's 502 00:19:52,170 --> 00:19:54,960 inside this proverbial black box. 503 00:19:54,960 --> 00:19:56,250 It's the sort of secret sauce. 504 00:19:56,250 --> 00:20:00,150 And the idea is that you learn not just to learn along the way, 505 00:20:00,150 --> 00:20:03,480 but learn to harness in your own human intuition. 506 00:20:03,480 --> 00:20:06,480 And so I wish I had discovered that far earlier for myself, 507 00:20:06,480 --> 00:20:10,080 knowing that computer science is not about programming per se. 508 00:20:10,080 --> 00:20:14,100 It really is about problem-solving, and just formalizing, and cleaning up 509 00:20:14,100 --> 00:20:16,860 your thought process, and introducing you to ideas like this 510 00:20:16,860 --> 00:20:20,190 that you can then apply in so many different ways. 511 00:20:20,190 --> 00:20:22,950 So that there, say, is just a taste of computer science. 512 00:20:22,950 --> 00:20:26,790 Allow me to conclude with a taste of this one course, CS50, 513 00:20:26,790 --> 00:20:30,370 by way of the point of view of one of our very own students. 514 00:20:33,190 --> 00:20:33,860 [VIDEO PLAYBACK] 515 00:20:33,860 --> 00:20:34,900 [MUSIC - PORTUGAL. 516 00:20:34,900 --> 00:20:41,330 THE MAN - "LIVE IN THE MOMENT"] 517 00:20:41,330 --> 00:20:49,300 - (SINGING) My home is a girl with eyes like wishing wells. 518 00:20:49,300 --> 00:20:56,270 I'm not alone, but I'm still lone-- lonely. 519 00:20:56,270 --> 00:21:03,240 Those days are done, but I'm still glowing. 520 00:21:03,240 --> 00:21:09,220 Ooh, la, la, la, la, la, let's live in the moment. 521 00:21:09,220 --> 00:21:12,210 Come back Sunday morning. 522 00:21:12,210 --> 00:21:14,200 Oh my, oh well. 523 00:21:14,200 --> 00:21:18,680 When you're gone, goodbye, so long, farewell. 524 00:21:18,680 --> 00:21:24,660 Ooh, la, la, la, la, la, let's live in the moment. 525 00:21:24,660 --> 00:21:27,150 Come back Sunday morning. 526 00:21:27,150 --> 00:21:29,140 Got soul to sell. 527 00:21:29,140 --> 00:21:33,120 When you're gone, goodbye, so long, farewell. 528 00:21:37,600 --> 00:21:45,070 My home is a girl who can't wait for time to tell. 529 00:21:45,070 --> 00:21:52,540 God only knows we don't need history. 530 00:21:52,540 --> 00:22:00,010 Your family swinging from the branches of a tree. 531 00:22:00,010 --> 00:22:07,270 God only knows we don't need ghost stories. 532 00:22:07,270 --> 00:22:13,190 Ooh, la, la, la, la, la, let's live in the moment.