1 00:00:00,000 --> 00:00:00,230 2 00:00:00,230 --> 00:00:00,860 DAVID MALAN: Good morning. 3 00:00:00,860 --> 00:00:01,800 My name is David Malan. 4 00:00:01,800 --> 00:00:03,380 This is Computer Science for Business Leaders. 5 00:00:03,380 --> 00:00:05,300 And we'll do some group introductions before long. 6 00:00:05,300 --> 00:00:08,440 But why don't we dive right in this morning to one of our first lessons, 7 00:00:08,440 --> 00:00:10,700 which is going to be on computational thinking. 8 00:00:10,700 --> 00:00:12,750 Indeed, today and tomorrow, among the goals 9 00:00:12,750 --> 00:00:15,170 are to give you really kind of a top-down sense of what 10 00:00:15,170 --> 00:00:18,441 computer science itself is all about, and computer engineering, 11 00:00:18,441 --> 00:00:20,190 particularly so that everyone in the room, 12 00:00:20,190 --> 00:00:23,490 even just after a couple of days' time, can hold their own all the more, so 13 00:00:23,490 --> 00:00:27,640 to speak, with engineers, can try to estimate, perhaps, 14 00:00:27,640 --> 00:00:30,240 a little more effectively how long projects might take 15 00:00:30,240 --> 00:00:32,780 or what might be involved or, at the end of the day, just 16 00:00:32,780 --> 00:00:35,010 what kinds of questions to actually ask so as to wrap 17 00:00:35,010 --> 00:00:36,896 your minds around technical projects. 18 00:00:36,896 --> 00:00:38,770 It looks like we have a mix of folks, though, 19 00:00:38,770 --> 00:00:42,530 and to give you a sense of who else is in the classroom on an aggregate scale, 20 00:00:42,530 --> 00:00:44,420 we'll give you a sense of some of the answers 21 00:00:44,420 --> 00:00:47,420 that you gave us to the Google form that we circulated in advance. 22 00:00:47,420 --> 00:00:48,670 But here's where we are today. 23 00:00:48,670 --> 00:00:50,740 So we're going to start off with computational thinking 24 00:00:50,740 --> 00:00:53,680 and talking about some fairly high level concepts like abstraction 25 00:00:53,680 --> 00:00:55,510 and algorithms and representation. 26 00:00:55,510 --> 00:00:58,420 But we'll distill those into things much more concrete before long. 27 00:00:58,420 --> 00:01:01,060 After a short break, we'll then dive into internet technology. 28 00:01:01,060 --> 00:01:02,480 So how does the internet work? 29 00:01:02,480 --> 00:01:04,800 Most everyone here uses it every day. 30 00:01:04,800 --> 00:01:06,510 Most everyone here is on it right now. 31 00:01:06,510 --> 00:01:08,427 But what, actually, is underneath the hood? 32 00:01:08,427 --> 00:01:10,510 And what are some of the things that can go wrong? 33 00:01:10,510 --> 00:01:12,480 And why was it designed the way it was designed? 34 00:01:12,480 --> 00:01:14,160 And what are the kinds of questions to ask, then, 35 00:01:14,160 --> 00:01:15,850 when building a business on top of it? 36 00:01:15,850 --> 00:01:18,170 Indeed, after lunch, we'll focus specifically 37 00:01:18,170 --> 00:01:21,700 on a more modern incarnation of these technologies known as cloud computing. 38 00:01:21,700 --> 00:01:24,770 This in and of itself is mostly just a buzzword, frankly. 39 00:01:24,770 --> 00:01:26,660 But we'll distill exactly what that means 40 00:01:26,660 --> 00:01:28,826 and what some of the ingredients and building blocks 41 00:01:28,826 --> 00:01:29,840 are for using the cloud. 42 00:01:29,840 --> 00:01:31,756 And then, this afternoon, after another break, 43 00:01:31,756 --> 00:01:33,842 we'll take a look at web development. 44 00:01:33,842 --> 00:01:36,800 We'll just scratch the surface, but it will be an opportunity hands-on, 45 00:01:36,800 --> 00:01:38,966 with laptops to get your hands dirty if you've never 46 00:01:38,966 --> 00:01:40,860 done it before with a little bit of languages 47 00:01:40,860 --> 00:01:44,840 like HTML and CSS and the general Linux architecture so 48 00:01:44,840 --> 00:01:46,640 that, when you walk out today, we've tried 49 00:01:46,640 --> 00:01:48,600 to make things a little more concrete, still, 50 00:01:48,600 --> 00:01:50,340 based on the higher-level discussions. 51 00:01:50,340 --> 00:01:53,300 Tomorrow, meanwhile, we'll start with a high-level discussion 52 00:01:53,300 --> 00:01:57,000 of issues of security and privacy in society, more generally-- things 53 00:01:57,000 --> 00:02:02,440 like, a few months back, Apple created a bit of a stir with its butting heads 54 00:02:02,440 --> 00:02:06,310 with the FBI, as you may recall, as they tried to get into someone's iPhone. 55 00:02:06,310 --> 00:02:08,699 We'll talk about that, what it means for encryption, 56 00:02:08,699 --> 00:02:10,419 and what that technology actually is. 57 00:02:10,419 --> 00:02:13,980 Looking again at it another industry topic like Dropbox, 58 00:02:13,980 --> 00:02:16,240 or sharing of files, which, at first glance, 59 00:02:16,240 --> 00:02:19,750 might seem like a wonderful service and exists for Microsoft and Google 60 00:02:19,750 --> 00:02:21,077 and any number of other forms. 61 00:02:21,077 --> 00:02:22,910 But what does it actually mean to be storing 62 00:02:22,910 --> 00:02:26,530 your files on services like Dropbox for your own privacy and security? 63 00:02:26,530 --> 00:02:28,780 Then we'll talk about programming, so what it actually 64 00:02:28,780 --> 00:02:31,430 means to write software, what some of the basic building blocks 65 00:02:31,430 --> 00:02:35,364 are, followed by technology stacks, so a general way of describing what 66 00:02:35,364 --> 00:02:37,280 are the sort of ingredients that you can bring 67 00:02:37,280 --> 00:02:42,250 to bear when trying to build a business or a website or a mobile application. 68 00:02:42,250 --> 00:02:44,370 What's the sort of alphabet soup these days? 69 00:02:44,370 --> 00:02:46,720 And then, lastly, web programming-- looking not just 70 00:02:46,720 --> 00:02:50,850 on the aesthetics of web pages using languages like HTML and CSS, 71 00:02:50,850 --> 00:02:55,550 but actual web programming using languages like JavaScript or others. 72 00:02:55,550 --> 00:02:58,050 And we'll talk about some of the related technologies there. 73 00:02:58,050 --> 00:02:59,650 So here's who's in the room. 74 00:02:59,650 --> 00:03:02,150 When asked via that Google form, how would you 75 00:03:02,150 --> 00:03:04,280 describe your comfort with technology? 76 00:03:04,280 --> 00:03:06,570 It's split between "very" and "somewhat," 77 00:03:06,570 --> 00:03:08,560 with a few of you saying "not very." 78 00:03:08,560 --> 00:03:09,790 So this is a nice mix. 79 00:03:09,790 --> 00:03:12,320 And certainly feel free to ask any and all questions 80 00:03:12,320 --> 00:03:14,410 as we proceed today and tomorrow. 81 00:03:14,410 --> 00:03:16,540 And we'll see, perhaps based on questions from me 82 00:03:16,540 --> 00:03:19,430 to you, just how very "very" is, perhaps. 83 00:03:19,430 --> 00:03:20,560 But we'll get there. 84 00:03:20,560 --> 00:03:24,960 And then, when asked, as well, "Do you have any programming experience 85 00:03:24,960 --> 00:03:27,440 in any language," this was a bit more of a mix, 86 00:03:27,440 --> 00:03:30,240 with 35% of folks saying "no prior programming experience," some 87 00:03:30,240 --> 00:03:31,990 of you saying "some," and then, just a few 88 00:03:31,990 --> 00:03:34,160 of you saying "a lot," which is a good mix, too, because, hopefully, 89 00:03:34,160 --> 00:03:36,470 then when we do the hands-on portion, they'll 90 00:03:36,470 --> 00:03:39,231 be a little something new for everyone. 91 00:03:39,231 --> 00:03:42,230 So if you'd like to follow along today or tomorrow, all of these slides, 92 00:03:42,230 --> 00:03:45,590 including any edits we might make in real time, is at this URL here. 93 00:03:45,590 --> 00:03:48,370 So if there's one URL you want to keep open today, 94 00:03:48,370 --> 00:03:52,340 let me pause for just a moment and suggest you go to this bitly URL, 95 00:03:52,340 --> 00:03:58,325 cs-for-business-leaders-201607. 96 00:03:58,325 --> 00:04:03,100 I'll linger for just a moment on that. 97 00:04:03,100 --> 00:04:05,267 In the meantime, we can get these out of the way. 98 00:04:05,267 --> 00:04:10,249 99 00:04:10,249 --> 00:04:12,540 Just let me know if you have any trouble viewing those. 100 00:04:12,540 --> 00:04:18,510 101 00:04:18,510 --> 00:04:19,470 All right. 102 00:04:19,470 --> 00:04:30,387 And typing seems to be slowing, so if you don't have it yet, 103 00:04:30,387 --> 00:04:32,470 just look at the person next to you, if you could. 104 00:04:32,470 --> 00:04:34,749 So we are now at computational thinking. 105 00:04:34,749 --> 00:04:36,540 All right, so what does this actually mean? 106 00:04:36,540 --> 00:04:38,748 This is kind of one of the buzz words within academia 107 00:04:38,748 --> 00:04:41,280 for describing one of the returns that you 108 00:04:41,280 --> 00:04:44,000 get from studies in computer science, what you get out 109 00:04:44,000 --> 00:04:45,590 of it, what you learn how to do. 110 00:04:45,590 --> 00:04:47,830 And indeed, many fields teach you how to think, 111 00:04:47,830 --> 00:04:50,710 or so they claim in course catalogs, descriptions, and so forth. 112 00:04:50,710 --> 00:04:53,930 But computational thinking is actually a sort of ingredient 113 00:04:53,930 --> 00:04:55,230 that we can leverage. 114 00:04:55,230 --> 00:04:58,260 It's a way of thinking more algorithmically, so to speak, more 115 00:04:58,260 --> 00:05:02,140 methodically, and bringing to bear, to problem, sort of a more organized way 116 00:05:02,140 --> 00:05:02,780 of thought. 117 00:05:02,780 --> 00:05:05,460 But to get there, let me propose that there's 118 00:05:05,460 --> 00:05:09,800 three ingredients to this notion of computational thinking. 119 00:05:09,800 --> 00:05:13,620 Specifically, let me propose that computational thinking can 120 00:05:13,620 --> 00:05:16,640 be distilled as input, going into something 121 00:05:16,640 --> 00:05:23,460 called an algorithm, producing outputs. 122 00:05:23,460 --> 00:05:25,300 So in other words, computational thinking 123 00:05:25,300 --> 00:05:28,695 is all about building this process, this pipeline. 124 00:05:28,695 --> 00:05:31,320 But this invites the question, well, what do we mean by inputs, 125 00:05:31,320 --> 00:05:32,611 and what do we mean by outputs? 126 00:05:32,611 --> 00:05:35,510 Well, inputs are just whatever the problem is that we have to solve. 127 00:05:35,510 --> 00:05:38,200 In a little bit, we'll play around with an old school technology, this phone 128 00:05:38,200 --> 00:05:38,630 book. 129 00:05:38,630 --> 00:05:41,200 This might be the input to a problem-- look someone up in this phone book. 130 00:05:41,200 --> 00:05:42,451 So here is the physical input. 131 00:05:42,451 --> 00:05:44,616 And the additional ingredient, the additional input, 132 00:05:44,616 --> 00:05:46,730 is someone's name, whom we might want to look up. 133 00:05:46,730 --> 00:05:50,770 And the output, hopefully, is going to be, from that problem-- what? 134 00:05:50,770 --> 00:05:52,560 Intuitively? 135 00:05:52,560 --> 00:05:53,967 If the input-- is a phone number. 136 00:05:53,967 --> 00:05:55,800 So hopefully, that's going to be the output. 137 00:05:55,800 --> 00:05:59,560 Meanwhile, the algorithm is the process that my hands engage in, 138 00:05:59,560 --> 00:06:03,810 in order to find someone's name in this phone book and, in turn, their number. 139 00:06:03,810 --> 00:06:06,950 So that would be the algorithm or the problem solving steps 140 00:06:06,950 --> 00:06:08,540 in between the inputs and the outputs. 141 00:06:08,540 --> 00:06:14,285 But how does a computer, and how do we humans, represent inputs and outputs? 142 00:06:14,285 --> 00:06:16,060 Well, at the end of the day, most everyone 143 00:06:16,060 --> 00:06:22,679 here probably knows that computers only understand what alphabets, so to speak? 144 00:06:22,679 --> 00:06:23,470 AUDIENCE: Binaries. 145 00:06:23,470 --> 00:06:24,190 DAVID MALAN: Binaries. 146 00:06:24,190 --> 00:06:25,040 So, 0's and 1's. 147 00:06:25,040 --> 00:06:28,248 And even those of you who said you were only somewhat or not very comfortable 148 00:06:28,248 --> 00:06:31,830 probably at least know or have heard that computers, indeed, only understand 149 00:06:31,830 --> 00:06:35,070 0's and 1's, the so-called binary systems-- "bi," meaning two, 150 00:06:35,070 --> 00:06:38,230 and that's two because you only have 0 and 1 in your vocabulary. 151 00:06:38,230 --> 00:06:41,690 We humans, by contrast have used the decimal system, "dec," meaning 10, 152 00:06:41,690 --> 00:06:44,630 so we get to speak in terms of 0 through 9, not to mention 153 00:06:44,630 --> 00:06:46,370 alphabetical letters and more. 154 00:06:46,370 --> 00:06:48,860 So if computers only have 0's and 1's, though, 155 00:06:48,860 --> 00:06:52,460 how could we possibly go about representing 156 00:06:52,460 --> 00:06:56,650 the number 2 and the number 3 and the number 4, let alone a, b, and c, 157 00:06:56,650 --> 00:07:01,450 let alone images and movies and audio files and any number of other formats 158 00:07:01,450 --> 00:07:03,310 that we just take for granted these days? 159 00:07:03,310 --> 00:07:05,520 Well, think back to grade school, perhaps, 160 00:07:05,520 --> 00:07:11,930 when you first learned that this pattern of symbols-- 1,2,3-- 161 00:07:11,930 --> 00:07:15,160 represents what number in decimal? 162 00:07:15,160 --> 00:07:16,110 123. 163 00:07:16,110 --> 00:07:16,650 Excellent. 164 00:07:16,650 --> 00:07:19,560 So that all comes to us very intuitively, certainly, these days. 165 00:07:19,560 --> 00:07:20,249 But why is that? 166 00:07:20,249 --> 00:07:23,290 You might not have thought about it for some time, but if you're like me, 167 00:07:23,290 --> 00:07:25,630 you probably learned back in the day that this 3 is 168 00:07:25,630 --> 00:07:31,570 in the ones place, or the ones column, and the 2 is in the tens place, 169 00:07:31,570 --> 00:07:32,535 so the tens place. 170 00:07:32,535 --> 00:07:34,410 And then the hundreds place, thousands place, 171 00:07:34,410 --> 00:07:35,660 ten thousands place, and so forth. 172 00:07:35,660 --> 00:07:36,980 But why is that significant? 173 00:07:36,980 --> 00:07:38,780 Well 1, 2, 3 is just a pattern of symbols. 174 00:07:38,780 --> 00:07:41,550 That's our vocabulary, 0 through 9, so the fact 175 00:07:41,550 --> 00:07:46,040 that we've ascribed meaning to the places in which these digits are, means 176 00:07:46,040 --> 00:07:50,010 that we can do 100 times 1-- is meant to be the arithmetic-- 177 00:07:50,010 --> 00:07:54,960 and then, that's plus 10 times 2, and that's plus 1 times 3. 178 00:07:54,960 --> 00:08:00,169 So this, of course, is 100 plus 20 plus 3, which gives us 123. 179 00:08:00,169 --> 00:08:03,210 Now at the end of the day, we've still written down the exact same thing, 180 00:08:03,210 --> 00:08:06,769 but we've gone from just a pattern of symbols-- 1, 2, 3-- 181 00:08:06,769 --> 00:08:09,060 to a higher-level notion of a number, a decimal number, 182 00:08:09,060 --> 00:08:11,810 that we know now, intuitively, is 123. 183 00:08:11,810 --> 00:08:15,020 Well, how many of you-- just to get a litmus 184 00:08:15,020 --> 00:08:21,070 test of before and after-- how many of you know binary, 185 00:08:21,070 --> 00:08:24,010 could recite numbers in binary? 186 00:08:24,010 --> 00:08:24,700 OK, good. 187 00:08:24,700 --> 00:08:26,850 Otherwise, this is going to be very underwhelming. 188 00:08:26,850 --> 00:08:33,020 So it turns out all of you, I claim, a bit boldly, already know binary 189 00:08:33,020 --> 00:08:35,380 or certainly could make this leap within seconds. 190 00:08:35,380 --> 00:08:40,309 So instead of having 1's, 2's, 3's, and 0's and 4's and 5's and 6's, 7's, 8's, 191 00:08:40,309 --> 00:08:44,870 9's in our vocabulary, now we're limiting ourselves to just 0's and 1's. 192 00:08:44,870 --> 00:08:49,332 And so if we have, say, three digits, just for the sake of discussion, 193 00:08:49,332 --> 00:08:52,540 we also now-- if we only have 0's and 1's-- are going to want to change these 194 00:08:52,540 --> 00:08:58,197 placeholders because before, 1, 10, 100, 1,000-- those were powers of 10. 195 00:08:58,197 --> 00:09:00,280 And that was significant because we had 10 digits. 196 00:09:00,280 --> 00:09:02,074 So just intuitively, or take a guess, what 197 00:09:02,074 --> 00:09:03,990 are the powers going to need to be if you only 198 00:09:03,990 --> 00:09:06,640 have two digits at your disposal? 199 00:09:06,640 --> 00:09:07,460 Powers of 2. 200 00:09:07,460 --> 00:09:10,650 So we still start with a ones column, which is 2 to the 0, 201 00:09:10,650 --> 00:09:14,760 but then we have 2 to the 1, which is the twos column, 2 the 2, 202 00:09:14,760 --> 00:09:20,010 which is the fours column, 2 the 3, which is going to be 8, 16, 32, 64. 203 00:09:20,010 --> 00:09:23,760 And so the columns are still powers of some value. 204 00:09:23,760 --> 00:09:26,130 But in this case, it's powers of 2 instead of 10. 205 00:09:26,130 --> 00:09:29,370 So based on that logic, if I told you a computer was storing 206 00:09:29,370 --> 00:09:33,170 this pattern of bits, or binary digits, what number 207 00:09:33,170 --> 00:09:36,150 is the computer thinking of in decimal? 208 00:09:36,150 --> 00:09:39,130 209 00:09:39,130 --> 00:09:40,030 Just 0, right? 210 00:09:40,030 --> 00:09:43,550 If the logic is the same-- 4 times 0, plus 2 times 0, 211 00:09:43,550 --> 00:09:46,510 plus 1 times 0 gives us the higher-level notion of 0. 212 00:09:46,510 --> 00:09:49,860 So this is how a computer would store the number 0. 213 00:09:49,860 --> 00:09:52,960 So even if you've never spoken or thought about binary before, 214 00:09:52,960 --> 00:09:58,050 how do we represent, say, the number 1 in binary? 215 00:09:58,050 --> 00:09:58,550 Yeah. 216 00:09:58,550 --> 00:10:00,430 0, 0, 1. 217 00:10:00,430 --> 00:10:03,428 And of course, to represent the number 2, we're going to do what? 218 00:10:03,428 --> 00:10:03,928 This. 219 00:10:03,928 --> 00:10:07,720 220 00:10:07,720 --> 00:10:08,410 Yeah. 221 00:10:08,410 --> 00:10:09,090 Trick question. 222 00:10:09,090 --> 00:10:13,220 So this would be 3, just based on the process we've been using before. 223 00:10:13,220 --> 00:10:14,450 So that's not correct. 224 00:10:14,450 --> 00:10:16,910 This would be the number 2. 225 00:10:16,910 --> 00:10:19,750 This now would intentionally be the number 3. 226 00:10:19,750 --> 00:10:25,460 The number 4, of course, would be 1, 0, 0. 227 00:10:25,460 --> 00:10:26,840 And then we can count up further. 228 00:10:26,840 --> 00:10:32,030 But actually, let's count up as high as we can with three binary digits, a.k.a. 229 00:10:32,030 --> 00:10:35,230 bits, what's the largest number we can count to? 230 00:10:35,230 --> 00:10:39,410 231 00:10:39,410 --> 00:10:40,052 Yeah, 7. 232 00:10:40,052 --> 00:10:43,260 And you know this because, if you only have 0's and 1's-- and we already know 233 00:10:43,260 --> 00:10:45,780 that putting 0's everywhere gives us 0-- clearly, 234 00:10:45,780 --> 00:10:48,020 the largest number has got to be 1, 1, 1. 235 00:10:48,020 --> 00:10:51,030 So that's 4 plus 2 plus 1 is 7. 236 00:10:51,030 --> 00:10:53,331 But how, then, does a computer count as high as 8? 237 00:10:53,331 --> 00:10:56,740 238 00:10:56,740 --> 00:10:57,240 Yeah. 239 00:10:57,240 --> 00:10:58,198 So we need more powers. 240 00:10:58,198 --> 00:10:59,030 We need more bits. 241 00:10:59,030 --> 00:11:01,570 So just like you might carry into the next place 242 00:11:01,570 --> 00:11:04,940 using the decimal system or grade school arithmetic, same idea here. 243 00:11:04,940 --> 00:11:07,790 If we want to now count as high as 8, that's fine. 244 00:11:07,790 --> 00:11:10,640 But we're going to need another bit in the so-called eights place 245 00:11:10,640 --> 00:11:13,340 so that we can represent this. 246 00:11:13,340 --> 00:11:20,290 Now as an aside, how many bits does a computer typically 247 00:11:20,290 --> 00:11:21,960 use to store numbers? 248 00:11:21,960 --> 00:11:22,810 Does anyone know? 249 00:11:22,810 --> 00:11:25,840 250 00:11:25,840 --> 00:11:31,104 It's bigger than 4, otherwise we wouldn't have much to do in a computer. 251 00:11:31,104 --> 00:11:31,970 AUDIENCE: 16. 252 00:11:31,970 --> 00:11:33,560 DAVID MALAN: 16, used to be 16. 253 00:11:33,560 --> 00:11:35,430 Nowadays, it's a little bigger. 254 00:11:35,430 --> 00:11:38,832 32 is very common, and very much in vogue these days is 64. 255 00:11:38,832 --> 00:11:41,290 So even if you've never really thought about what it means, 256 00:11:41,290 --> 00:11:45,560 if you've heard the expression 32-bit or 64-bit-- it's usually 257 00:11:45,560 --> 00:11:49,020 in the context of CPUs or computers or operating systems-- well, 258 00:11:49,020 --> 00:11:52,330 that signifies, essentially, how many bits does 259 00:11:52,330 --> 00:11:53,950 that computer use to store numbers. 260 00:11:53,950 --> 00:11:55,880 Specifically, it means how many bits does 261 00:11:55,880 --> 00:11:57,650 it use to store addresses of memory. 262 00:11:57,650 --> 00:11:59,330 But more on memory in just a little bit. 263 00:11:59,330 --> 00:12:03,080 But that's to say, if a computer has a ones place, a twos place, 264 00:12:03,080 --> 00:12:08,090 a fours place, eights, 16, 32 total such bits, 265 00:12:08,090 --> 00:12:13,150 the largest value a computer can represent is 2 to the 32. 266 00:12:13,150 --> 00:12:17,150 And so, if there's one number, roughly, you take away from today, 267 00:12:17,150 --> 00:12:18,560 let's consider this one. 268 00:12:18,560 --> 00:12:22,515 How high can a computer count if a computer can count as high as 2 the 32? 269 00:12:22,515 --> 00:12:28,526 270 00:12:28,526 --> 00:12:30,070 2 to 32-- we could do this. 271 00:12:30,070 --> 00:12:37,600 So 2 times 2 is 4, times 2 is 8, times 2 is 16, 32, 64, 128, 256, 512, 1024, 272 00:12:37,600 --> 00:12:38,360 2048. 273 00:12:38,360 --> 00:12:41,334 It's going to get hard soon, so save me. 274 00:12:41,334 --> 00:12:43,000 So it's going to be a pretty big number. 275 00:12:43,000 --> 00:12:47,480 Turns out, this is roughly 4 billion-- roughly 4 billion. 276 00:12:47,480 --> 00:12:51,110 Now, for those of you who might have grown up with PCs 277 00:12:51,110 --> 00:12:53,920 and might have built them or bought them, certainly, yourself, 278 00:12:53,920 --> 00:13:00,350 you might have at some point realized or been told that your computer can only 279 00:13:00,350 --> 00:13:02,810 support up to 2 gigabytes of RAM. 280 00:13:02,810 --> 00:13:05,146 Did anyone ever run into this limitation? 281 00:13:05,146 --> 00:13:07,520 So if you ever ran into an upper bound on how much memory 282 00:13:07,520 --> 00:13:09,339 your computer could support, sometimes it's 283 00:13:09,339 --> 00:13:11,880 just because the manufacturer had some hard-coded limitation. 284 00:13:11,880 --> 00:13:15,150 Apple does this just for money and financial reasons or engineering 285 00:13:15,150 --> 00:13:15,670 reasons. 286 00:13:15,670 --> 00:13:18,716 But back in the day, especially with PCs that you could upgrade, 287 00:13:18,716 --> 00:13:21,840 there was still an upper bound on how much RAM you could put in a computer. 288 00:13:21,840 --> 00:13:26,760 You could only, in many machines, put in 2 gigabytes because, at the time, 289 00:13:26,760 --> 00:13:29,270 they were using 32-bit values-- and actually 290 00:13:29,270 --> 00:13:33,180 31-bits because they were stealing one of them to represent negative signs. 291 00:13:33,180 --> 00:13:35,520 But more on that, perhaps, another time. 292 00:13:35,520 --> 00:13:38,227 So that meant not 4 billion, but 2 billion. 293 00:13:38,227 --> 00:13:41,060 And if you've got memory in your computer--and we'll talk more about 294 00:13:41,060 --> 00:13:43,393 memory in a bit-- if you've got memory in your computer, 295 00:13:43,393 --> 00:13:46,230 but you can physically only count as high as 2 billion, 296 00:13:46,230 --> 00:13:51,370 you better have no more than 2 billion bytes of memory because everything at 2 297 00:13:51,370 --> 00:13:54,850 billion and 1 or beyond, essentially, would just be inaccessible. 298 00:13:54,850 --> 00:13:57,750 You wouldn't have the vocabulary with which to express it. 299 00:13:57,750 --> 00:13:59,290 Nowadays, this is less of an issue. 300 00:13:59,290 --> 00:14:04,790 And computers these days are doing 64-bit values, 2 to the 64. 301 00:14:04,790 --> 00:14:06,520 And this is not a number I can pronounce, 302 00:14:06,520 --> 00:14:08,970 but I can bring up a calculator. 303 00:14:08,970 --> 00:14:11,880 If you've ever wondered what 2 to the 32 is. 304 00:14:11,880 --> 00:14:14,730 That, of course, is 4 billion, which looks like that. 305 00:14:14,730 --> 00:14:17,450 And just to give you a sense of the size of 2 to the 64, 306 00:14:17,450 --> 00:14:18,740 that's a lot more bytes. 307 00:14:18,740 --> 00:14:23,080 That's way more RAM than we would ever be able to afford or fit, physically, 308 00:14:23,080 --> 00:14:24,170 probably, in a computer. 309 00:14:24,170 --> 00:14:25,450 At least right now. 310 00:14:25,450 --> 00:14:27,030 So why is all of this important? 311 00:14:27,030 --> 00:14:28,970 Well, we only seem to have, at the moment, 312 00:14:28,970 --> 00:14:34,800 a conceptual way of thinking about what goes on inside of a computer. 313 00:14:34,800 --> 00:14:38,230 We're just doing things with markers and with numbers on the screen. 314 00:14:38,230 --> 00:14:41,019 But at the end of the day, the computer is a physical device, 315 00:14:41,019 --> 00:14:43,810 and a phone, which is essentially a computer, is a physical device. 316 00:14:43,810 --> 00:14:45,434 So what's going on underneath the hood? 317 00:14:45,434 --> 00:14:51,320 How do we get from these abstract ideas of counting to 7 or 4 billion 318 00:14:51,320 --> 00:14:53,640 to actually doing that, physically, in a computer. 319 00:14:53,640 --> 00:14:56,390 Well, what's one of the only inputs into my computer? 320 00:14:56,390 --> 00:14:59,310 At the end of the day, it's this thing here, the power cord. 321 00:14:59,310 --> 00:15:01,310 And even if you're not an electrical engineer, 322 00:15:01,310 --> 00:15:03,910 what comes out of the power cord? 323 00:15:03,910 --> 00:15:06,610 Electricity comes out of the holes in the wall. 324 00:15:06,610 --> 00:15:08,450 We can keep things very real today. 325 00:15:08,450 --> 00:15:11,590 And you probably remember, generally, that there's electrons involved. 326 00:15:11,590 --> 00:15:14,700 Little-- Electricity is flowing in one direction or another. 327 00:15:14,700 --> 00:15:16,850 And that suffices for today's purposes, certainly, 328 00:15:16,850 --> 00:15:19,040 to know that electricity is an input. 329 00:15:19,040 --> 00:15:21,580 And you note, certainly, that when you have electricity, 330 00:15:21,580 --> 00:15:22,730 you can turn things on. 331 00:15:22,730 --> 00:15:25,730 So if I want to turn on this light on my phone, 332 00:15:25,730 --> 00:15:28,566 you can think of that as consuming some electricity. 333 00:15:28,566 --> 00:15:30,440 Electricity is now flowing through the device 334 00:15:30,440 --> 00:15:31,856 because I've turned the switch on. 335 00:15:31,856 --> 00:15:34,380 And now, when I hit it again, it's off. 336 00:15:34,380 --> 00:15:36,316 So it turns out computers do fundamentally 337 00:15:36,316 --> 00:15:37,440 work in quite the same way. 338 00:15:37,440 --> 00:15:40,510 If you think of your computer as having a whole bunch of little switches 339 00:15:40,510 --> 00:15:44,007 or light bulbs, if you will, inside, if those are on, 340 00:15:44,007 --> 00:15:46,090 you can think of the computer as representing a 1. 341 00:15:46,090 --> 00:15:49,090 And if they're off, you can think of the computer as representing a 0. 342 00:15:49,090 --> 00:15:52,040 So my phone right now is in the off state, so to speak. 343 00:15:52,040 --> 00:15:55,260 And now, once I turn the switch on, it's in the on state. 344 00:15:55,260 --> 00:15:58,840 So I might say that my phone is currently representing a 0. 345 00:15:58,840 --> 00:16:03,800 And now it's representing a 1, 0, 1, and so on. 346 00:16:03,800 --> 00:16:06,470 But unfortunately, with just one switch, one light bulb, 347 00:16:06,470 --> 00:16:08,142 I can only count so high. 348 00:16:08,142 --> 00:16:10,350 And it's around this time I like to borrow one phone. 349 00:16:10,350 --> 00:16:11,990 Can I-- a phone? 350 00:16:11,990 --> 00:16:13,130 That one, I can turn on. 351 00:16:13,130 --> 00:16:13,630 May I? 352 00:16:13,630 --> 00:16:14,713 I don't need to unlock it. 353 00:16:14,713 --> 00:16:16,480 I just need to turn the flashlight on. 354 00:16:16,480 --> 00:16:18,930 So everything is safe, still. 355 00:16:18,930 --> 00:16:23,380 So if now I have two phones at my disposal, you can think of this one 356 00:16:23,380 --> 00:16:26,440 as being in the ones place, this one as being in twos place. 357 00:16:26,440 --> 00:16:29,442 So quite trivially, what number am I representing right now? 358 00:16:29,442 --> 00:16:30,250 AUDIENCE: 0. 359 00:16:30,250 --> 00:16:30,690 DAVID MALAN: Both are off. 360 00:16:30,690 --> 00:16:30,930 Right. 361 00:16:30,930 --> 00:16:31,763 So they're both off. 362 00:16:31,763 --> 00:16:36,040 And if I go ahead and turn on this one, I'm now 363 00:16:36,040 --> 00:16:39,796 representing 1 because this is the ones place, this is the twos place. 364 00:16:39,796 --> 00:16:41,670 Now if I turn this one on, I'm representing-- 365 00:16:41,670 --> 00:16:42,370 AUDIENCE: 3. 366 00:16:42,370 --> 00:16:43,810 DAVID MALAN: --3 because 1 and 1. 367 00:16:43,810 --> 00:16:47,880 And if I turn off this one, I'm representing, of course, 2. 368 00:16:47,880 --> 00:16:52,450 Now with two phones, I can only count as high as 3-- 0, 1, 2, 3-- 369 00:16:52,450 --> 00:16:55,660 because that's how many ways I can permute the on, off switches. 370 00:16:55,660 --> 00:16:58,580 Now certainly-- thank you-- a typical laptop 371 00:16:58,580 --> 00:17:00,790 has many more than just two switches. 372 00:17:00,790 --> 00:17:06,950 It might have-- turn this off-- it might have 373 00:17:06,950 --> 00:17:11,550 thousands of switches or millions of switches or tens of millions 374 00:17:11,550 --> 00:17:12,800 of switches these days. 375 00:17:12,800 --> 00:17:15,699 And indeed, if you've ever heard the expression "transistor," back 376 00:17:15,699 --> 00:17:17,865 in the day a transistor radio, inside of a computer, 377 00:17:17,865 --> 00:17:20,979 a transistor is really just a tiny, little switch that if it's on, 378 00:17:20,979 --> 00:17:23,770 allows a little bit of electricity to flow and get stored, perhaps, 379 00:17:23,770 --> 00:17:25,089 and so that gives us a 1. 380 00:17:25,089 --> 00:17:27,109 And if the switch is off, that gives us a 0. 381 00:17:27,109 --> 00:17:30,301 So inside, physically, a computer, there might be millions or tens 382 00:17:30,301 --> 00:17:31,550 of millions of these switches. 383 00:17:31,550 --> 00:17:34,740 And that's how we can store so much darn information 384 00:17:34,740 --> 00:17:38,460 or compute so much information all at once. 385 00:17:38,460 --> 00:17:41,990 Unfortunately, there is a downside of using electricity and switches 386 00:17:41,990 --> 00:17:42,970 in this way. 387 00:17:42,970 --> 00:17:46,190 And I deliberately turned my flashlight off a moment ago 388 00:17:46,190 --> 00:17:49,620 because I was probably worried that what might happen? 389 00:17:49,620 --> 00:17:50,610 The battery might die. 390 00:17:50,610 --> 00:17:53,450 So if the battery dies, or if, in the case of my laptop, 391 00:17:53,450 --> 00:17:56,310 my battery dies and this power cord comes off, 392 00:17:56,310 --> 00:17:59,300 presumably all those little light bulbs, all those little transistors, 393 00:17:59,300 --> 00:18:02,760 naturally switch off, which is not good for your Excel files 394 00:18:02,760 --> 00:18:04,700 and your Word documents and anything else 395 00:18:04,700 --> 00:18:07,270 that you might be storing locally on your computer. 396 00:18:07,270 --> 00:18:11,690 So what do computers instead use to store data persistently or long term? 397 00:18:11,690 --> 00:18:14,270 398 00:18:14,270 --> 00:18:14,794 Yes, memory. 399 00:18:14,794 --> 00:18:16,960 And it turns out, there's different types of memory. 400 00:18:16,960 --> 00:18:18,650 Let's distill this for just a moment. 401 00:18:18,650 --> 00:18:20,410 So there's different types of memory. 402 00:18:20,410 --> 00:18:23,240 We've been talking about bits, of course, 403 00:18:23,240 --> 00:18:28,880 which might be turned to 0's, which might be represented, physically, 404 00:18:28,880 --> 00:18:31,400 with little transistors turning on and off. 405 00:18:31,400 --> 00:18:34,460 And so this takes different forms, but let's 406 00:18:34,460 --> 00:18:37,770 go ahead and describe a few types of memory. 407 00:18:37,770 --> 00:18:40,930 One, there's little things called registers. 408 00:18:40,930 --> 00:18:47,770 These are typically 32 or 64 bits of memory inside of a computer's CPU. 409 00:18:47,770 --> 00:18:50,890 And we humans really never should care about how many registers 410 00:18:50,890 --> 00:18:51,620 a computer has. 411 00:18:51,620 --> 00:18:53,250 It's not a selling point of a computer, per se. 412 00:18:53,250 --> 00:18:55,290 It's a very low-level implementation detail. 413 00:18:55,290 --> 00:18:57,200 But it's about the smallest unit of measure 414 00:18:57,200 --> 00:18:59,980 that a computer or its CPU, central processing unit, 415 00:18:59,980 --> 00:19:01,440 might actually care about. 416 00:19:01,440 --> 00:19:04,460 There's then stuff called RAM, which is what all of us 417 00:19:04,460 --> 00:19:08,950 are intuitively describing, most likely, as memory, random access memory. 418 00:19:08,950 --> 00:19:12,210 This is the stuff that does get lost when you lose power, 419 00:19:12,210 --> 00:19:13,480 or when your battery dies. 420 00:19:13,480 --> 00:19:15,740 It's for non-persistent data. 421 00:19:15,740 --> 00:19:19,020 And RAM is where programs live when you're using them 422 00:19:19,020 --> 00:19:20,200 or when files are open. 423 00:19:20,200 --> 00:19:23,325 So if you double click Microsoft Word or some such program on your desktop, 424 00:19:23,325 --> 00:19:25,952 and a window opens up, essentially what's happened 425 00:19:25,952 --> 00:19:27,660 is that program, Microsoft Word, has been 426 00:19:27,660 --> 00:19:31,180 copied from somewhere permanently on your computer into somewhere 427 00:19:31,180 --> 00:19:33,480 temporary on your computer called RAM. 428 00:19:33,480 --> 00:19:35,390 Why that is, we'll see in just a moment. 429 00:19:35,390 --> 00:19:40,450 And where it came from was probably something called a hard drive. 430 00:19:40,450 --> 00:19:44,920 Now back in the day, these might be called HDDs, hard disk drive. 431 00:19:44,920 --> 00:19:47,940 The catch is, they're not really hard disks anymore. 432 00:19:47,940 --> 00:19:51,050 They're not spinning platters, as we'll soon see. 433 00:19:51,050 --> 00:19:54,417 They're also called SSDs now for solid state drives, 434 00:19:54,417 --> 00:19:56,000 which means they're purely electronic. 435 00:19:56,000 --> 00:20:00,020 But they store their charges even after you lose power. 436 00:20:00,020 --> 00:20:02,770 But this is kind of the pipeline from one to the other. 437 00:20:02,770 --> 00:20:04,520 And it turns out we could do this all day. 438 00:20:04,520 --> 00:20:08,280 There's something called a L1 cache in here, level 1. 439 00:20:08,280 --> 00:20:09,901 There's L2 cache in here. 440 00:20:09,901 --> 00:20:12,150 Those two are very low-level details, but this is just 441 00:20:12,150 --> 00:20:14,630 to say when we humans say memory, frankly, 442 00:20:14,630 --> 00:20:17,130 we could technically mean a whole bunch of different things. 443 00:20:17,130 --> 00:20:19,949 But odds are humans mean this one here. 444 00:20:19,949 --> 00:20:22,490 But it's different from this kind of memory, your hard drive, 445 00:20:22,490 --> 00:20:24,770 because this is where your data is stored permanently. 446 00:20:24,770 --> 00:20:27,830 So when you install Microsoft Word or Excel or create a file 447 00:20:27,830 --> 00:20:32,590 and go to File, Save, all of those 0's and 1's are somehow stored here. 448 00:20:32,590 --> 00:20:35,220 But when you double click on the program or open the file, 449 00:20:35,220 --> 00:20:38,000 they're temporarily copied in duplicate, essentially, 450 00:20:38,000 --> 00:20:41,100 here while you're using them. 451 00:20:41,100 --> 00:20:44,220 Now, why might there be this duality? 452 00:20:44,220 --> 00:20:48,260 If you put on your so-called engineering hat, 453 00:20:48,260 --> 00:20:50,440 why would we have so many different types of memory? 454 00:20:50,440 --> 00:20:54,370 Because, as an aside, the stuff that's in here, eventually ends up in here, 455 00:20:54,370 --> 00:20:58,670 and a little bit in here, and even less of it, but some of it, in here. 456 00:20:58,670 --> 00:21:02,710 So like all of these steps, moving things around, 457 00:21:02,710 --> 00:21:07,010 why would we have this pipeline from long term to super short term, 458 00:21:07,010 --> 00:21:08,490 would you think, intuitively? 459 00:21:08,490 --> 00:21:09,559 AUDIENCE: Speed. 460 00:21:09,559 --> 00:21:10,350 DAVID MALAN: Speed. 461 00:21:10,350 --> 00:21:11,216 What do you mean? 462 00:21:11,216 --> 00:21:14,710 AUDIENCE: When you're dealing with less material. 463 00:21:14,710 --> 00:21:19,830 DAVID MALAN: Yeah, so less material-- so speed, though, in what sense? 464 00:21:19,830 --> 00:21:22,986 Is one of these slower or faster, would you conjecture? 465 00:21:22,986 --> 00:21:25,826 AUDIENCE: [INAUDIBLE] the RAM is smaller. 466 00:21:25,826 --> 00:21:27,450 DAVID MALAN: Oh, so the RAM is smaller. 467 00:21:27,450 --> 00:21:28,616 So that's, indeed, the case. 468 00:21:28,616 --> 00:21:32,620 A computer might have 2 gigabytes of RAM these days, 8 gigabytes of RAM, 469 00:21:32,620 --> 00:21:34,090 but low numbers of gigabytes. 470 00:21:34,090 --> 00:21:38,910 Whereas a hard disk might have 512 gigabytes or 1,024 471 00:21:38,910 --> 00:21:42,360 gigabytes, a.k.a. a terabyte, or even more than that. 472 00:21:42,360 --> 00:21:44,820 But this seems silly. 473 00:21:44,820 --> 00:21:47,730 Why have less of this, if this is the good stuff, 474 00:21:47,730 --> 00:21:49,730 this is where your programs and files are living 475 00:21:49,730 --> 00:21:53,595 when you actually care to use them? 476 00:21:53,595 --> 00:21:57,210 AUDIENCE: One has the working memory, and the other's the stored memory. 477 00:21:57,210 --> 00:21:57,960 DAVID MALAN: True. 478 00:21:57,960 --> 00:21:58,980 One is working memory. 479 00:21:58,980 --> 00:22:00,030 One is stored memory. 480 00:22:00,030 --> 00:22:04,730 But why not just use your hard drive for working memory? 481 00:22:04,730 --> 00:22:06,456 Why complicate things? 482 00:22:06,456 --> 00:22:09,277 AUDIENCE: You don't want to lose the old stuff. 483 00:22:09,277 --> 00:22:12,360 DAVID MALAN: You don't want to lose-- but if I'm storing everything always 484 00:22:12,360 --> 00:22:15,650 on my hard drive, it would stand to reason that I'll never lose it. 485 00:22:15,650 --> 00:22:19,240 Whereas if I load something into RAM while temporarily working on it, 486 00:22:19,240 --> 00:22:21,800 power goes out, that's when all of us start 487 00:22:21,800 --> 00:22:24,930 to swear because that's when you've lost data, potentially. 488 00:22:24,930 --> 00:22:28,300 AUDIENCE: I guess he was saying like speed and the amount of space you put 489 00:22:28,300 --> 00:22:29,209 [INAUDIBLE]. 490 00:22:29,209 --> 00:22:30,250 DAVID MALAN: Speed, yeah. 491 00:22:30,250 --> 00:22:32,110 And let me fill in a blank here. 492 00:22:32,110 --> 00:22:35,280 It's indeed the case that this is bigger, this is smaller. 493 00:22:35,280 --> 00:22:37,890 This is bits, this is, maybe, terabytes. 494 00:22:37,890 --> 00:22:42,360 But this is also super fast, and this is, relatively speaking, super slow. 495 00:22:42,360 --> 00:22:44,890 So there is this trade off between size and space. 496 00:22:44,890 --> 00:22:46,620 You want a huge amount of space, ideally, 497 00:22:46,620 --> 00:22:49,129 for all of your personal files and work files and so forth, 498 00:22:49,129 --> 00:22:51,420 so you don't have to run out of space and delete things 499 00:22:51,420 --> 00:22:53,350 and just generally do that kind of dance. 500 00:22:53,350 --> 00:22:57,840 But this space, as a result of being cheap, tends to be pretty slow. 501 00:22:57,840 --> 00:23:00,490 And as a result of being mechanical, as we'll see in a moment, 502 00:23:00,490 --> 00:23:01,490 also tends to be slow. 503 00:23:01,490 --> 00:23:04,660 Back in the day, this was a physical device with a moving platter, 504 00:23:04,660 --> 00:23:07,250 not unlike record players of yesteryear, that 505 00:23:07,250 --> 00:23:11,490 is just subject to laws of motion and physical speed limitations, 506 00:23:11,490 --> 00:23:13,160 whereas this is purely electronic. 507 00:23:13,160 --> 00:23:17,060 And even RAM is purely electronic and therefore much faster. 508 00:23:17,060 --> 00:23:22,030 So if you have more of this and less of this, but this is slower, 509 00:23:22,030 --> 00:23:26,455 and this is faster, why not just have more of the fast stuff? 510 00:23:26,455 --> 00:23:30,310 511 00:23:30,310 --> 00:23:39,050 Just to be clear, this is more, less, fast, slow. 512 00:23:39,050 --> 00:23:42,770 So why not just have more fast somewhere in the middle? 513 00:23:42,770 --> 00:23:44,930 Like more RAM? 514 00:23:44,930 --> 00:23:46,600 AUDIENCE: Does it take more electricity? 515 00:23:46,600 --> 00:23:49,080 DAVID MALAN: It doesn't necessarily take more electricity, but good thought. 516 00:23:49,080 --> 00:23:49,940 AUDIENCE: Expensive. 517 00:23:49,940 --> 00:23:50,690 DAVID MALAN: Yeah. 518 00:23:50,690 --> 00:23:52,460 It's really this issue right here. 519 00:23:52,460 --> 00:23:55,680 It just happens to be the case, still, that the higher you go up 520 00:23:55,680 --> 00:23:59,220 on your RAM vs hard disk space, this is just a lot more 521 00:23:59,220 --> 00:24:01,540 expensive than hard disk space. 522 00:24:01,540 --> 00:24:03,770 So yeah, you could have a terabyte of RAM, 523 00:24:03,770 --> 00:24:05,410 but you're really going to pay for it. 524 00:24:05,410 --> 00:24:07,340 And no one really supports systems that use 525 00:24:07,340 --> 00:24:09,673 that because, for some of the intuition that some of you 526 00:24:09,673 --> 00:24:11,780 had where this is really just working memory, 527 00:24:11,780 --> 00:24:14,390 I don't need to run all of my programs at once. 528 00:24:14,390 --> 00:24:17,870 I might run one, maybe half a dozen if I have multiple windows going. 529 00:24:17,870 --> 00:24:21,344 But it's a subset, most likely, of all of the stuff I've installed over time. 530 00:24:21,344 --> 00:24:24,260 I'm not going to have every Word document open that I've ever created. 531 00:24:24,260 --> 00:24:26,100 I'm probably going to have one or a few. 532 00:24:26,100 --> 00:24:29,070 So working memory can be, logistically, just smaller. 533 00:24:29,070 --> 00:24:30,820 And so even though it's more expensive, we 534 00:24:30,820 --> 00:24:33,124 can tolerate that because we don't need as much. 535 00:24:33,124 --> 00:24:34,790 And so these are some of the trade offs. 536 00:24:34,790 --> 00:24:36,860 And when you're buying a consumer PC or Mac, 537 00:24:36,860 --> 00:24:39,290 frankly, the only ones you really have choice over, 538 00:24:39,290 --> 00:24:42,170 discretion over, perhaps, are those two. 539 00:24:42,170 --> 00:24:45,900 And more RAM tends to mean more expensive. 540 00:24:45,900 --> 00:24:50,600 But why might you want to have more RAM, according to this logic here? 541 00:24:50,600 --> 00:24:52,850 Why might you want to spend a few hundred dollars more 542 00:24:52,850 --> 00:24:56,060 to get the nicer Mac or the nicer PC with more RAM 543 00:24:56,060 --> 00:24:59,230 if everything else is constant? 544 00:24:59,230 --> 00:25:00,334 Faster why? 545 00:25:00,334 --> 00:25:04,780 546 00:25:04,780 --> 00:25:11,540 That's correct, but why does more RAM make your computer faster? 547 00:25:11,540 --> 00:25:13,050 AUDIENCE: Bigger working memory? 548 00:25:13,050 --> 00:25:14,878 DAVID MALAN: Bigger working memory. 549 00:25:14,878 --> 00:25:17,200 AUDIENCE: [INAUDIBLE] pull more things from your hard drive [INAUDIBLE] 550 00:25:17,200 --> 00:25:18,280 using them all at the same time? 551 00:25:18,280 --> 00:25:19,930 DAVID MALAN: Yeah, that's what it boils down to. 552 00:25:19,930 --> 00:25:22,930 But there's a reason that it actually feels, to the human, faster. 553 00:25:22,930 --> 00:25:26,260 It turns out that, even if you only have a gigabyte of RAM, 554 00:25:26,260 --> 00:25:30,600 you can actually cram more than a gigabyte of files and programs 555 00:25:30,600 --> 00:25:34,420 into RAM, which seems a little counter intuitive. 556 00:25:34,420 --> 00:25:36,800 But that's because of a technology called virtual memory. 557 00:25:36,800 --> 00:25:39,880 And computers have had this for 20, 30 years now, in some form. 558 00:25:39,880 --> 00:25:43,070 Back in the day, you used to have to pay for and install special software 559 00:25:43,070 --> 00:25:45,432 to add virtual memory to your computer. 560 00:25:45,432 --> 00:25:46,140 It was a feature. 561 00:25:46,140 --> 00:25:48,900 Nowadays, it just comes with Windows and Mac OS and Linux and Unix 562 00:25:48,900 --> 00:25:50,220 and other operating systems. 563 00:25:50,220 --> 00:25:53,380 But virtual memory is a feature of modern operating systems 564 00:25:53,380 --> 00:25:56,270 that creates the illusion that, even if you might have, physically, 565 00:25:56,270 --> 00:26:00,840 1 gig of RAM, the computer will let you think you have 2 gigabytes of RAM. 566 00:26:00,840 --> 00:26:05,300 But the moment you try to add the billionth plus 1 byte 567 00:26:05,300 --> 00:26:09,670 to your RAM, what the computer does is it does a little switcheroo. 568 00:26:09,670 --> 00:26:13,750 It looks at your RAM, realizes yes, Excel is running, 569 00:26:13,750 --> 00:26:16,650 but you haven't touched that spreadsheet for a minute or for an hour 570 00:26:16,650 --> 00:26:17,790 or for a week. 571 00:26:17,790 --> 00:26:22,470 I'm going to secretly move Excel from RAM back to your hard drive 572 00:26:22,470 --> 00:26:25,122 in some temporary scratch locations, or some temporary space 573 00:26:25,122 --> 00:26:27,080 that you don't even have to know or care about, 574 00:26:27,080 --> 00:26:31,620 so that you can load that additional file that you just double clicked on 575 00:26:31,620 --> 00:26:34,110 and go about your business. 576 00:26:34,110 --> 00:26:36,580 So what happens, though, if I just said, oh, wait a minute. 577 00:26:36,580 --> 00:26:38,500 Now I do want to play with that Excel file. 578 00:26:38,500 --> 00:26:43,360 So I click the little icon in my toolbar or whatnot for the Excel program. 579 00:26:43,360 --> 00:26:44,970 That then gets foregrounded. 580 00:26:44,970 --> 00:26:48,190 And if you've ever seen this happen, visually, sometimes computers 581 00:26:48,190 --> 00:26:52,110 have this like-- it kind of feels painfully slow 582 00:26:52,110 --> 00:26:55,390 as the window is going from the background, or minimized state, 583 00:26:55,390 --> 00:26:56,530 to foreground. 584 00:26:56,530 --> 00:26:58,210 Why is that so slow? 585 00:26:58,210 --> 00:27:01,144 What might be happening? 586 00:27:01,144 --> 00:27:02,280 AUDIENCE: [INAUDIBLE]. 587 00:27:02,280 --> 00:27:03,030 DAVID MALAN: Yeah. 588 00:27:03,030 --> 00:27:04,570 Go ahead. 589 00:27:04,570 --> 00:27:05,703 Oh, from-- 590 00:27:05,703 --> 00:27:08,494 AUDIENCE: I was just saying, it's retrieving it from the hard drive 591 00:27:08,494 --> 00:27:10,070 so it's taking [INAUDIBLE] memory. 592 00:27:10,070 --> 00:27:10,650 DAVID MALAN: Exactly. 593 00:27:10,650 --> 00:27:11,858 Remember that this is slower. 594 00:27:11,858 --> 00:27:13,050 This is faster. 595 00:27:13,050 --> 00:27:16,319 And so if Excel was secretly swapped out by your operating system 596 00:27:16,319 --> 00:27:19,360 so that you could use that memory for something else, the moment you want 597 00:27:19,360 --> 00:27:22,220 Excel back, your computer has to secretly move it back 598 00:27:22,220 --> 00:27:25,340 from the hard drive to RAM. 599 00:27:25,340 --> 00:27:27,600 And that's what creates that feeling of slowness. 600 00:27:27,600 --> 00:27:30,410 So it's not so much that just adding RAM to a computer 601 00:27:30,410 --> 00:27:33,944 makes your computer faster because if you're only using a few programs 602 00:27:33,944 --> 00:27:36,860 or files at any one time, you could have an infinite amount of memory. 603 00:27:36,860 --> 00:27:37,950 If you're not going to use it, it's not going 604 00:27:37,950 --> 00:27:39,680 to have any impact on your computer. 605 00:27:39,680 --> 00:27:43,010 But if you have relatively little RAM, but you've 606 00:27:43,010 --> 00:27:45,000 been using your computer and programs and files 607 00:27:45,000 --> 00:27:49,200 so much that you're constantly swapping, so to speak, unbeknownst to you, 608 00:27:49,200 --> 00:27:52,540 but underneath the hood, between RAM and hard disk RAM and hard disk again 609 00:27:52,540 --> 00:27:55,840 and again because of virtual memory, then yes, more RAM will help. 610 00:27:55,840 --> 00:27:59,209 So in a consumer perspective, frankly, just spending on RAM 611 00:27:59,209 --> 00:28:00,250 tends to be a good thing. 612 00:28:00,250 --> 00:28:01,870 There tends to be an upper bound, realistically, 613 00:28:01,870 --> 00:28:05,120 anyway because this way you don't have to think about these kinds of things, 614 00:28:05,120 --> 00:28:05,620 as well. 615 00:28:05,620 --> 00:28:06,921 But that's a slippery slope. 616 00:28:06,921 --> 00:28:08,670 Of course, paying for more hard disk space 617 00:28:08,670 --> 00:28:11,544 is great, too, because you never have to worry about deleting things. 618 00:28:11,544 --> 00:28:14,622 Paying for a faster CPU, central processing unit, 619 00:28:14,622 --> 00:28:17,580 will just make everything faster because the computer can think faster. 620 00:28:17,580 --> 00:28:21,610 So even though I say more is better, it all, of course, has this impact. 621 00:28:21,610 --> 00:28:25,630 But this is the first such example of a trend we'll see today and tomorrow, 622 00:28:25,630 --> 00:28:26,670 of these trade offs. 623 00:28:26,670 --> 00:28:28,670 And in retrospect, it might seem pretty obvious. 624 00:28:28,670 --> 00:28:31,840 So better is more expensive, faster is probably more expensive, 625 00:28:31,840 --> 00:28:35,750 but I can get less of it to sort of balance my budget. 626 00:28:35,750 --> 00:28:39,520 This notion of trade offs is going to be constant throughout computer science. 627 00:28:39,520 --> 00:28:43,790 In this case, it might be something like speed and cost or speed and quantity. 628 00:28:43,790 --> 00:28:46,040 But we're going to see other such trade offs, as well. 629 00:28:46,040 --> 00:28:47,789 And that really, at the end of the day, is 630 00:28:47,789 --> 00:28:50,390 what's interesting about or hard about engineering-- is 631 00:28:50,390 --> 00:28:54,270 having to make those educated decisions as to which one is more important 632 00:28:54,270 --> 00:28:55,420 and when. 633 00:28:55,420 --> 00:28:58,920 So let's now scale up from something conceptual to something 634 00:28:58,920 --> 00:29:03,586 physical, but small, like a phone and a flashlight, to actual hardware, 635 00:29:03,586 --> 00:29:05,710 something like a hard drive, with which some of you 636 00:29:05,710 --> 00:29:07,126 might be familiar from yesteryear. 637 00:29:07,126 --> 00:29:10,390 Most of your laptops today probably have what are called SSDs, 638 00:29:10,390 --> 00:29:11,409 solid state drives. 639 00:29:11,409 --> 00:29:13,450 But if your computer has a fan, or if you've ever 640 00:29:13,450 --> 00:29:15,660 heard clicking, which is generally not good, 641 00:29:15,660 --> 00:29:19,390 that's because you have a hard disk that works a little something like this. 642 00:29:19,390 --> 00:29:20,598 Let me go ahead and hit play. 643 00:29:20,598 --> 00:29:23,089 644 00:29:23,089 --> 00:29:25,630 SPEAKER 12 (ON VIDEO): The hard drive is where your PC stores 645 00:29:25,630 --> 00:29:27,630 most of its permanent data. 646 00:29:27,630 --> 00:29:30,610 To do that, the data travels from RAM along 647 00:29:30,610 --> 00:29:35,170 with software signals that tell the hard drive how to store that data. 648 00:29:35,170 --> 00:29:40,010 The hard drive circuits translate those signals into voltage fluctuations. 649 00:29:40,010 --> 00:29:44,320 These, in turn, control the hard drive's moving parts, some of the few moving 650 00:29:44,320 --> 00:29:46,880 parts left in the modern computer. 651 00:29:46,880 --> 00:29:51,100 Some of the signals control a motor, which spins metal-coated platters. 652 00:29:51,100 --> 00:29:54,430 Your data is actually stored on these platters. 653 00:29:54,430 --> 00:29:59,690 Other signals move the read/write heads to read or write data on the platters. 654 00:29:59,690 --> 00:30:03,540 This machinery is so precise that a human hair couldn't even 655 00:30:03,540 --> 00:30:06,200 pass between the heads and spinning platters, 656 00:30:06,200 --> 00:30:09,630 yet it all works at terrific speeds. 657 00:30:09,630 --> 00:30:13,150 DAVID MALAN: So now let's zoom in a little lower-level on where 658 00:30:13,150 --> 00:30:19,920 the bits actually are on a physical device like that, and it's version 2. 659 00:30:19,920 --> 00:30:23,000 SPEAKER 13 (ON VIDEO): Let's look at what we just saw in slow motion. 660 00:30:23,000 --> 00:30:26,400 When a brief pulse of electricity is sent to the read/write head, 661 00:30:26,400 --> 00:30:30,170 it flips on a tiny electromagnet for a fraction of a second. 662 00:30:30,170 --> 00:30:32,560 The magnet creates a field, which changes 663 00:30:32,560 --> 00:30:35,770 the polarity of a tiny, tiny portion of the metal particles 664 00:30:35,770 --> 00:30:38,130 which coat each platter surface. 665 00:30:38,130 --> 00:30:41,190 A patterned series of these tiny, charged up areas on the disk 666 00:30:41,190 --> 00:30:45,750 represents a single bit of data in the binary number system used by computers. 667 00:30:45,750 --> 00:30:48,680 Now, if the current is sent one way through the read/write head, 668 00:30:48,680 --> 00:30:51,069 the area is polarized in one direction. 669 00:30:51,069 --> 00:30:53,110 If the current is sent in the opposite direction, 670 00:30:53,110 --> 00:30:55,200 the polarization is reversed. 671 00:30:55,200 --> 00:30:57,620 How do you get data off the hard disk? 672 00:30:57,620 --> 00:30:59,360 Just reverse the process. 673 00:30:59,360 --> 00:31:01,610 So it's the particles on the disk that get the current 674 00:31:01,610 --> 00:31:03,430 in the read/write head moving. 675 00:31:03,430 --> 00:31:05,750 Put together millions of these magnetized segments, 676 00:31:05,750 --> 00:31:07,400 and you've got a file. 677 00:31:07,400 --> 00:31:12,200 Now, the pieces of a single file maybe scattered all over a drive's platters, 678 00:31:12,200 --> 00:31:15,230 kind of like the mess of papers on your desk. 679 00:31:15,230 --> 00:31:18,760 So a special, extra file keeps track of where everything is. 680 00:31:18,760 --> 00:31:21,710 Don't you wish you had something like that? 681 00:31:21,710 --> 00:31:22,500 DAVID MALAN: OK. 682 00:31:22,500 --> 00:31:25,090 So this is all to say that, not only do we 683 00:31:25,090 --> 00:31:29,100 have a conceptual mental model for how to count higher than 0 and 1, 684 00:31:29,100 --> 00:31:31,870 to 2, to 3, to 4, we also have a physical way now 685 00:31:31,870 --> 00:31:37,390 of representing these 0's and 1's, not only temporarily in stuff like RAM 686 00:31:37,390 --> 00:31:41,110 and inside of your computer by way of transistors turning things on and off, 687 00:31:41,110 --> 00:31:42,430 but also permanently. 688 00:31:42,430 --> 00:31:49,060 So to be clear, I am often reminded when we talk about hard disks and storage 689 00:31:49,060 --> 00:31:51,980 of this guy from many years ago. 690 00:31:51,980 --> 00:31:53,970 Although, maybe he still exists. 691 00:31:53,970 --> 00:31:55,280 Wooly Willy. 692 00:31:55,280 --> 00:31:59,600 If you remember this little toy-- it's just a plastic container, 693 00:31:59,600 --> 00:32:00,902 below which is a face. 694 00:32:00,902 --> 00:32:03,360 And then there's all these little black magnetic particles. 695 00:32:03,360 --> 00:32:06,010 And you get a little red stick that itself has a magnet on it. 696 00:32:06,010 --> 00:32:09,520 And you can draw mustaches and hair and so forth on his face. 697 00:32:09,520 --> 00:32:14,620 But those little magnetic particles are, essentially, a much larger analog 698 00:32:14,620 --> 00:32:15,820 of this thing here. 699 00:32:15,820 --> 00:32:19,640 So as the video discusses, having these 0's and 1's represented 700 00:32:19,640 --> 00:32:23,220 by these little blue and red ovals, that's 701 00:32:23,220 --> 00:32:26,600 like saying if the particle is oriented like this, it might represent a 1. 702 00:32:26,600 --> 00:32:29,420 And if it, instead, is this way, south, north, instead of north, 703 00:32:29,420 --> 00:32:31,810 south, it might represent a 0. 704 00:32:31,810 --> 00:32:34,250 If you ever, years ago, remember floppy disks, 705 00:32:34,250 --> 00:32:37,240 and you ever moved that little metal sheath over the floppy disk 706 00:32:37,240 --> 00:32:39,650 and touched it, there was, indeed, a floppy disk inside. 707 00:32:39,650 --> 00:32:42,210 But what you're touching is a platter, not unlike this, 708 00:32:42,210 --> 00:32:47,490 that had a lot of magnetic particles that, unfortunately, you just 709 00:32:47,490 --> 00:32:51,270 moved or destroyed or corrupted, essentially, by touching them. 710 00:32:51,270 --> 00:32:55,370 And that's why there was that metal sheath on top of it. 711 00:32:55,370 --> 00:32:55,960 All right. 712 00:32:55,960 --> 00:32:59,450 So if we can store permanently or temporarily 713 00:32:59,450 --> 00:33:01,430 0's and 1's, that all fine and good. 714 00:33:01,430 --> 00:33:05,560 But it seems that all computers are good for is computing things like numbers 715 00:33:05,560 --> 00:33:07,040 or calculating, really. 716 00:33:07,040 --> 00:33:12,980 How do we get from 0's and 1's and 2's and 3's and just numbers, 717 00:33:12,980 --> 00:33:16,850 more generally-- 4 billion, maybe that high-- to things like letters, 718 00:33:16,850 --> 00:33:20,020 so that we can actually implement Microsoft Word and email? 719 00:33:20,020 --> 00:33:24,790 And how do we then get higher still to things like image and movies? 720 00:33:24,790 --> 00:33:26,170 Let's start with the first. 721 00:33:26,170 --> 00:33:30,460 If all you have is 0's and 1's in your alphabet, how could you send messages, 722 00:33:30,460 --> 00:33:37,841 textually, to someone else if we have just 0's and 1's? 723 00:33:37,841 --> 00:33:38,340 Yeah. 724 00:33:38,340 --> 00:33:42,550 AUDIENCE: It could be the A would be 1, B would be 2, C 3-- 725 00:33:42,550 --> 00:33:43,530 DAVID MALAN: Yeah. 726 00:33:43,530 --> 00:33:44,030 OK. 727 00:33:44,030 --> 00:33:45,650 What do people think about that? 728 00:33:45,650 --> 00:33:50,950 A is 1, B is 2, C is 3, and so forth. 729 00:33:50,950 --> 00:33:52,770 Like it? 730 00:33:52,770 --> 00:33:53,270 Yes? 731 00:33:53,270 --> 00:33:54,380 No? 732 00:33:54,380 --> 00:33:56,230 It's kind of arbitrary, but it's clean. 733 00:33:56,230 --> 00:33:56,780 It's nice. 734 00:33:56,780 --> 00:34:00,662 And so long as all of us humans agree, it's actually perfectly correct. 735 00:34:00,662 --> 00:34:02,370 Now, it turns out that world didn't quite 736 00:34:02,370 --> 00:34:06,406 standardize on 1, 2, 3 for A, B, C. They started counting a little higher just 737 00:34:06,406 --> 00:34:08,780 because of punctuation and other symbols on the keyboard. 738 00:34:08,780 --> 00:34:10,639 But indeed, that's exactly the case. 739 00:34:10,639 --> 00:34:13,940 It turns out that the world decided some time ago 740 00:34:13,940 --> 00:34:16,449 that, if a computer is to store the capital letter 741 00:34:16,449 --> 00:34:19,610 A for the purposes of a document or an email or whatnot, 742 00:34:19,610 --> 00:34:25,030 it's actually going to represent that A using the decimal number 65 743 00:34:25,030 --> 00:34:29,614 or, more specifically, whatever pattern of bits represents the number 65. 744 00:34:29,614 --> 00:34:31,030 And let me try to figure this out. 745 00:34:31,030 --> 00:34:37,159 So if I have the ones place, the twos place, the fours, the eights, 746 00:34:37,159 --> 00:34:44,679 16's, 32's, 64's, in this case, I need 1, 2, 3, 4, 5, 6, 7. 747 00:34:44,679 --> 00:34:47,730 And indeed, it turns out that 7 is going to be significant in a moment. 748 00:34:47,730 --> 00:34:51,699 How do I represent the number 65 using binary? 749 00:34:51,699 --> 00:34:54,957 I need 7 bits, seven 0's and 1's, but what pattern? 750 00:34:54,957 --> 00:34:56,041 AUDIENCE: [INAUDIBLE]. 751 00:34:56,041 --> 00:34:56,790 DAVID MALAN: Yeah. 752 00:34:56,790 --> 00:34:59,620 So thankfully, this one's actually a little easy because you just need a 1 753 00:34:59,620 --> 00:35:00,210 at both ends. 754 00:35:00,210 --> 00:35:02,070 You need a 64, and you need a 1. 755 00:35:02,070 --> 00:35:05,490 So that gives us 65, which is to say, if you're writing a Word document 756 00:35:05,490 --> 00:35:09,000 or you're writing an email, at the end of the day, what you're really 757 00:35:09,000 --> 00:35:11,850 doing when you hit the capital letter A on your keyboard 758 00:35:11,850 --> 00:35:14,610 is telling the computer, store the decimal number 65. 759 00:35:14,610 --> 00:35:15,610 But what does that mean? 760 00:35:15,610 --> 00:35:17,100 It can't store 6, 5. 761 00:35:17,100 --> 00:35:18,990 But it can store 0's and 1's. 762 00:35:18,990 --> 00:35:21,864 So you're really telling the computer when you hit the capital letter 763 00:35:21,864 --> 00:35:26,260 A, give me seven bits, permute them to look like this, 764 00:35:26,260 --> 00:35:30,660 and store those bits somewhere in the computer's memory. 765 00:35:30,660 --> 00:35:34,186 And indeed, it turns out that the capital letter B, by convention, is 66. 766 00:35:34,186 --> 00:35:36,330 C is 67. 767 00:35:36,330 --> 00:35:37,060 Dot, dot, dot. 768 00:35:37,060 --> 00:35:39,510 Lowercase A is 97. 769 00:35:39,510 --> 00:35:41,810 Lowercase B is 98. 770 00:35:41,810 --> 00:35:44,880 And there's a couple of hundred more because of all the various symbols 771 00:35:44,880 --> 00:35:45,650 on the keyboard. 772 00:35:45,650 --> 00:35:47,820 And at the end of the day, this is a system 773 00:35:47,820 --> 00:35:53,000 called 7-bit ASCII, which is just a fancy way of saying American Standard 774 00:35:53,000 --> 00:35:56,250 Code for Information Interchange, which is not something you need to remember. 775 00:35:56,250 --> 00:36:02,520 But it's a slightly more refined system than just the obvious A is 1, B is 2, 776 00:36:02,520 --> 00:36:03,340 C is 3. 777 00:36:03,340 --> 00:36:06,760 They also took into account punctuation and other symbols, as well. 778 00:36:06,760 --> 00:36:10,870 Now it turns out that 7 bits isn't all that much. 779 00:36:10,870 --> 00:36:13,500 Not to dwell too much on math today, but how high 780 00:36:13,500 --> 00:36:16,330 can you count if you only have 7 bits? 781 00:36:16,330 --> 00:36:20,810 What's the largest number you can reach? 782 00:36:20,810 --> 00:36:21,770 It's 128. 783 00:36:21,770 --> 00:36:22,440 Why is that? 784 00:36:22,440 --> 00:36:25,231 Well, if you have two possible values, here two possible values 785 00:36:25,231 --> 00:36:27,730 here, two possible values here, it's 2 times 2 times 2 times 786 00:36:27,730 --> 00:36:31,640 2, which is 2 to the seventh, which does equal 128. 787 00:36:31,640 --> 00:36:36,960 That's all fine and good for American English because we've got A through Z, 788 00:36:36,960 --> 00:36:38,070 so that's 26. 789 00:36:38,070 --> 00:36:40,930 But then lowercase and uppercase-- so that's 52. 790 00:36:40,930 --> 00:36:42,420 I like exclamation points. 791 00:36:42,420 --> 00:36:43,520 So that's 53. 792 00:36:43,520 --> 00:36:45,330 There's space bar, 54. 793 00:36:45,330 --> 00:36:46,500 There's bunches of others. 794 00:36:46,500 --> 00:36:49,420 But certainly, in other languages, especially certain Asian languages 795 00:36:49,420 --> 00:36:53,340 where there's a whole symbology, 128 total possible characters 796 00:36:53,340 --> 00:36:54,280 isn't going to cut it. 797 00:36:54,280 --> 00:36:57,150 So this was very American-centric-- American Standard Code 798 00:36:57,150 --> 00:36:58,490 for Information Interchange. 799 00:36:58,490 --> 00:37:02,090 So nowadays, not only is it more common to use, certainly, 800 00:37:02,090 --> 00:37:09,050 8-bit for extended ASCII, but actually, 16-bit values called Unicode. 801 00:37:09,050 --> 00:37:11,300 And Unicode is just a smarter system that 802 00:37:11,300 --> 00:37:14,450 actually accommodates the fact that not everyone in the world 803 00:37:14,450 --> 00:37:15,790 only needs 7 bits. 804 00:37:15,790 --> 00:37:18,620 We sometimes need more to represent certain symbols. 805 00:37:18,620 --> 00:37:23,297 And I guess, probably the last math exercise-- what's 2 to the 16? 806 00:37:23,297 --> 00:37:24,880 How many characters can we handle now? 807 00:37:24,880 --> 00:37:26,671 How many keys on the keyboard, so to speak? 808 00:37:26,671 --> 00:37:30,160 809 00:37:30,160 --> 00:37:31,070 It's bigger. 810 00:37:31,070 --> 00:37:33,230 65,536. 811 00:37:33,230 --> 00:37:37,270 I know that only because I ask that rhetorical question so often. 812 00:37:37,270 --> 00:37:38,330 So that's a lot. 813 00:37:38,330 --> 00:37:41,154 And that's decent, certainly, to represent textual characters. 814 00:37:41,154 --> 00:37:43,320 So at the end of the day, what's the key ingredient? 815 00:37:43,320 --> 00:37:45,620 Well, we just had to decide on a system. 816 00:37:45,620 --> 00:37:47,800 We just had to decide, somewhat arbitrarily, 817 00:37:47,800 --> 00:37:50,830 but globally consistently, 65 shall represent 818 00:37:50,830 --> 00:37:55,250 capital A. 66 shall represent capital B. And it's this mapping, this code, 819 00:37:55,250 --> 00:37:58,040 that we all just need to agree upon. 820 00:37:58,040 --> 00:38:04,460 But then how does the computer know when a pattern of bits, 821 00:38:04,460 --> 00:38:09,458 0's and 1's, represents A or 65? 822 00:38:09,458 --> 00:38:14,550 823 00:38:14,550 --> 00:38:15,944 How might we address this? 824 00:38:15,944 --> 00:38:16,444 Yeah, Avi? 825 00:38:16,444 --> 00:38:18,620 AVI: Just one switch that changes the mode. 826 00:38:18,620 --> 00:38:19,370 DAVID MALAN: Yeah. 827 00:38:19,370 --> 00:38:21,390 One switch that changes the mode. 828 00:38:21,390 --> 00:38:22,040 Not bad. 829 00:38:22,040 --> 00:38:24,090 Not bad. 830 00:38:24,090 --> 00:38:28,060 Unfortunately, the catch there is this-- we're only, at the moment, narrowly 831 00:38:28,060 --> 00:38:30,830 talking about numbers and letters. 832 00:38:30,830 --> 00:38:35,210 But what about images and movies and any number of other file formats? 833 00:38:35,210 --> 00:38:38,570 That seems a slippery slope, if we have a way of encoding the type of program 834 00:38:38,570 --> 00:38:42,720 because there could be an infinite type of files that people create over time. 835 00:38:42,720 --> 00:38:45,530 So the storage space is just going to grow and grow and grow. 836 00:38:45,530 --> 00:38:47,480 So not bad, but it's probably going to run 837 00:38:47,480 --> 00:38:53,580 into problems as soon as we want to do more than just numbers and letters. 838 00:38:53,580 --> 00:38:56,552 What might you do instead? 839 00:38:56,552 --> 00:38:58,011 AUDIENCE: Have another code for 65. 840 00:38:58,011 --> 00:38:58,968 DAVID MALAN: I'm sorry? 841 00:38:58,968 --> 00:39:00,580 AUDIENCE: Have another code for 65. 842 00:39:00,580 --> 00:39:02,750 DAVID MALAN: So have another code for 65. 843 00:39:02,750 --> 00:39:03,900 It's not bad. 844 00:39:03,900 --> 00:39:07,830 But at the end of the day, that code is going to have to be a pattern of bits. 845 00:39:07,830 --> 00:39:10,940 So we could absolutely come up with some other pattern of bits, 846 00:39:10,940 --> 00:39:14,780 but the problem is there's an infinite number of numbers in the world. 847 00:39:14,780 --> 00:39:18,410 We can count up past 4 billion, as humans, to 8 billion, to 16 billion, 848 00:39:18,410 --> 00:39:19,420 to a trillion. 849 00:39:19,420 --> 00:39:24,510 And unless we decide no one can ever use the following numbers in a math 850 00:39:24,510 --> 00:39:28,220 program, you can't really reserve any patterns of bits 851 00:39:28,220 --> 00:39:30,916 for your A's and your B's and your C's. 852 00:39:30,916 --> 00:39:33,500 So we need them both to co-exist, somehow, 853 00:39:33,500 --> 00:39:42,792 where sometimes this represents 65, but other times it represents A. Yeah? 854 00:39:42,792 --> 00:39:43,291 Grace? 855 00:39:43,291 --> 00:39:44,644 GRACE: [INAUDIBLE] logic in the individual program 856 00:39:44,644 --> 00:39:46,450 that knows how to read the file then? 857 00:39:46,450 --> 00:39:47,200 DAVID MALAN: Yeah. 858 00:39:47,200 --> 00:39:49,140 Why don't we kick it to the program to decide? 859 00:39:49,140 --> 00:39:53,710 So it's not bad intuition to kind of try to embed the information in the data 860 00:39:53,710 --> 00:39:54,530 itself. 861 00:39:54,530 --> 00:39:57,170 But it's easier and, daresay, more scalable 862 00:39:57,170 --> 00:40:00,830 to just leave it to the program that you're using to decide, 863 00:40:00,830 --> 00:40:03,630 am I looking at numbers, or am I looking at letters? 864 00:40:03,630 --> 00:40:07,660 And to oversimplify, Microsoft Word, when it sees a pattern of bits, 865 00:40:07,660 --> 00:40:09,962 presumably is going to interpret that pattern of bits 866 00:40:09,962 --> 00:40:11,670 as letter, letter, letter, letter, letter 867 00:40:11,670 --> 00:40:14,680 because, together, that gives you a whole essay or document or whatnot. 868 00:40:14,680 --> 00:40:18,256 Meanwhile Excel might view that same pattern of bits as numbers. 869 00:40:18,256 --> 00:40:20,130 But of course, Excel can handle other things. 870 00:40:20,130 --> 00:40:22,810 An email program might view it as letters. 871 00:40:22,810 --> 00:40:25,020 A calculator program might view it as numbers. 872 00:40:25,020 --> 00:40:27,477 But of course, those programs could use different patterns 873 00:40:27,477 --> 00:40:29,560 for different types of data-- numbers and letters. 874 00:40:29,560 --> 00:40:30,960 So it all is context dependent. 875 00:40:30,960 --> 00:40:32,360 And so Grace is spot on. 876 00:40:32,360 --> 00:40:34,110 It really just depends on the program. 877 00:40:34,110 --> 00:40:37,570 It is up to the program to decide whether it's 878 00:40:37,570 --> 00:40:40,000 looking at numbers or letters. 879 00:40:40,000 --> 00:40:40,500 Yeah? 880 00:40:40,500 --> 00:40:43,818 AUDIENCE: Does it have something to do with the [INAUDIBLE] strings, binary 881 00:40:43,818 --> 00:40:45,945 [INAUDIBLE] that we find in programming, maybe? 882 00:40:45,945 --> 00:40:46,820 DAVID MALAN: It does. 883 00:40:46,820 --> 00:40:47,690 Yeah, absolutely. 884 00:40:47,690 --> 00:40:50,339 In fact, we'll see a little bit of this tomorrow when we 885 00:40:50,339 --> 00:40:51,880 talk about programming, specifically. 886 00:40:51,880 --> 00:40:54,140 A lot of programming languages actually put the burden 887 00:40:54,140 --> 00:40:57,950 on the programmer, the author of the software, to decide in advance, 888 00:40:57,950 --> 00:41:00,340 do you want to represent a character or a number 889 00:41:00,340 --> 00:41:01,840 with the following sequence of bits? 890 00:41:01,840 --> 00:41:04,640 And these are called data types in programming languages. 891 00:41:04,640 --> 00:41:06,790 So it turns out, we leave it to the program. 892 00:41:06,790 --> 00:41:10,480 And it just has to decide how it's going to interpret these patterns of bits. 893 00:41:10,480 --> 00:41:13,600 All right, so if that's the case, we now have this scheme 894 00:41:13,600 --> 00:41:17,630 for encoding letters and numbers. 895 00:41:17,630 --> 00:41:18,590 What about colors? 896 00:41:18,590 --> 00:41:22,090 Let's kind of step things up a notch. 897 00:41:22,090 --> 00:41:24,083 How could we represent colors? 898 00:41:24,083 --> 00:41:26,680 899 00:41:26,680 --> 00:41:27,415 Yeah, Sarah? 900 00:41:27,415 --> 00:41:31,430 SARAH: [INAUDIBLE] similar string of numbers, like, what is it, hexogonal-- 901 00:41:31,430 --> 00:41:32,180 DAVID MALAN: Yeah. 902 00:41:32,180 --> 00:41:32,680 Hexadecimal. 903 00:41:32,680 --> 00:41:33,842 SARAH: Hexadecimal. 904 00:41:33,842 --> 00:41:34,550 DAVID MALAN: Yep. 905 00:41:34,550 --> 00:41:36,780 So we do have systems like that. 906 00:41:36,780 --> 00:41:41,760 And in fact, we'll see this, actually, in HTML later today. 907 00:41:41,760 --> 00:41:43,580 You can see this in Photoshop, actually. 908 00:41:43,580 --> 00:41:49,080 And in fact, I don't know if I'm going to be able to launch Photoshop on here 909 00:41:49,080 --> 00:41:50,020 in this account. 910 00:41:50,020 --> 00:41:51,860 Let me see. 911 00:41:51,860 --> 00:41:52,870 I'll accept that. 912 00:41:52,870 --> 00:41:55,530 913 00:41:55,530 --> 00:41:58,450 Oh, we got away with it, this guest account. 914 00:41:58,450 --> 00:42:00,170 No, dammit. 915 00:42:00,170 --> 00:42:02,950 Wait, let's see if we can use it, anyway. 916 00:42:02,950 --> 00:42:03,770 OK we can. 917 00:42:03,770 --> 00:42:05,520 All right, this feature is free. 918 00:42:05,520 --> 00:42:11,450 So notice here I have the ability to type in this number down here. 919 00:42:11,450 --> 00:42:14,740 I'm going to go ahead and type in 000000. 920 00:42:14,740 --> 00:42:17,840 And notice what color I get-- is black. 921 00:42:17,840 --> 00:42:21,330 And this is actually equivalent to this here, 0, 0, 0. 922 00:42:21,330 --> 00:42:25,890 And these letters, you might recall from yesteryear, RGB. 923 00:42:25,890 --> 00:42:28,220 It's an old school expression, but still has meaning. 924 00:42:28,220 --> 00:42:29,287 What's RGB? 925 00:42:29,287 --> 00:42:30,370 AUDIENCE: Red, green blue. 926 00:42:30,370 --> 00:42:31,620 DAVID MALAN: Red, green, blue. 927 00:42:31,620 --> 00:42:34,480 So it turns out that you can make any color of the rainbow 928 00:42:34,480 --> 00:42:37,650 by just mixing in some red, some green, and blue-- so different wavelengths 929 00:42:37,650 --> 00:42:38,200 of light. 930 00:42:38,200 --> 00:42:39,592 So let me go ahead and try that. 931 00:42:39,592 --> 00:42:41,550 Let me give a little bit-- and notice right now 932 00:42:41,550 --> 00:42:43,591 we're at black because I have 0 of each of those. 933 00:42:43,591 --> 00:42:45,960 So the absence of any of those colors shall be black. 934 00:42:45,960 --> 00:42:49,436 And now let me give myself a little bit of red. 935 00:42:49,436 --> 00:42:50,810 That didn't really change things. 936 00:42:50,810 --> 00:42:53,670 And actually, let me change this to black, 937 00:42:53,670 --> 00:42:58,040 so we can actually see a difference here, so new and current. 938 00:42:58,040 --> 00:43:00,385 So let's give it a little red. 939 00:43:00,385 --> 00:43:02,760 Definitely don't notice the difference on this projector. 940 00:43:02,760 --> 00:43:04,860 How about 10 of red? 941 00:43:04,860 --> 00:43:05,360 No. 942 00:43:05,360 --> 00:43:06,260 How about 100 of red? 943 00:43:06,260 --> 00:43:07,070 OK. 944 00:43:07,070 --> 00:43:10,090 So once we ramp it up to 100, that's a good amount of red. 945 00:43:10,090 --> 00:43:11,390 Let me try 200. 946 00:43:11,390 --> 00:43:12,590 Oh, that's really red. 947 00:43:12,590 --> 00:43:15,840 And now 255, really red. 948 00:43:15,840 --> 00:43:18,350 How about 1,000? 949 00:43:18,350 --> 00:43:22,850 That's a bug because you can only count as high as 255. 950 00:43:22,850 --> 00:43:26,090 So here we're already seeing issues of representation. 951 00:43:26,090 --> 00:43:29,180 Photoshop, to represent the amount of red in a program, 952 00:43:29,180 --> 00:43:30,903 is using how many bits, apparently? 953 00:43:30,903 --> 00:43:35,184 954 00:43:35,184 --> 00:43:36,076 AUDIENCE: 8. 955 00:43:36,076 --> 00:43:36,950 DAVID MALAN: 8, yeah. 956 00:43:36,950 --> 00:43:39,420 So I keep asking numbers, but I think I'm only 957 00:43:39,420 --> 00:43:42,545 asking the same three numbers all the time, or maybe the same four numbers. 958 00:43:42,545 --> 00:43:47,210 128, 256, 65,536, or 4 billion shall be the answer to any math question today. 959 00:43:47,210 --> 00:43:51,980 So 8 bits is sufficient because 2 the 8 is 256. 960 00:43:51,980 --> 00:43:55,260 So indeed, it looks like Photoshop, to represent the amount of red 961 00:43:55,260 --> 00:43:59,450 in the program, is using 8 bits where, apparently, 0 means no red, 962 00:43:59,450 --> 00:44:01,289 and 255 means a lot of red. 963 00:44:01,289 --> 00:44:02,080 So let me try that. 964 00:44:02,080 --> 00:44:05,480 255 gives me, indeed, what looks like a lot of red. 965 00:44:05,480 --> 00:44:08,681 Now, if I change that back to 0, how about a lot of green? 966 00:44:08,681 --> 00:44:09,180 Ah. 967 00:44:09,180 --> 00:44:11,070 You see that's how we can represent green. 968 00:44:11,070 --> 00:44:15,570 And if we get away from that and do 255, we might represent a lot of blue 969 00:44:15,570 --> 00:44:16,164 in this way. 970 00:44:16,164 --> 00:44:17,830 And now we can really start to have fun. 971 00:44:17,830 --> 00:44:22,140 If we do a lot of red, a lot of green and blue, 972 00:44:22,140 --> 00:44:25,140 we get white, as though you're combining all those different wavelengths 973 00:44:25,140 --> 00:44:26,140 of light. 974 00:44:26,140 --> 00:44:29,190 How about an even mix of 100, 100, 100? 975 00:44:29,190 --> 00:44:31,510 That's, apparently, how you represent gray. 976 00:44:31,510 --> 00:44:35,936 Anyone want to request a value? 977 00:44:35,936 --> 00:44:37,810 There's not much intellectual upside of this, 978 00:44:37,810 --> 00:44:40,640 but we'll just try one more color. 979 00:44:40,640 --> 00:44:45,570 50-- so give me 50 red, 50 green, 50 blue-- still gray. 980 00:44:45,570 --> 00:44:47,520 Even quantity seems to give us gray. 981 00:44:47,520 --> 00:44:49,250 So how about we ramp this up to 250? 982 00:44:49,250 --> 00:44:50,130 That's an even. 983 00:44:50,130 --> 00:44:51,080 Still red. 984 00:44:51,080 --> 00:44:51,890 How about 100? 985 00:44:51,890 --> 00:44:53,160 Oh, there's orange. 986 00:44:53,160 --> 00:44:56,240 150-- so that's how you make orange, by mixing in that. 987 00:44:56,240 --> 00:44:57,650 And what if we ramp this up? 988 00:44:57,650 --> 00:45:00,260 Now it's a little more peach-like on my screen, at least. 989 00:45:00,260 --> 00:45:01,260 That's how you get pink. 990 00:45:01,260 --> 00:45:04,260 And we could do this all day long and really not get anything out of it. 991 00:45:04,260 --> 00:45:05,940 So what's the real takeaway here? 992 00:45:05,940 --> 00:45:10,430 RGB is really telling us how much red do you want? 993 00:45:10,430 --> 00:45:11,190 How much green? 994 00:45:11,190 --> 00:45:12,500 How much blue? 995 00:45:12,500 --> 00:45:14,650 Each of these is 8-bit values. 996 00:45:14,650 --> 00:45:16,790 So we have a number and a number and a number. 997 00:45:16,790 --> 00:45:19,980 And combining those numbers-- 8 plus 8 plus 8 bits-- 998 00:45:19,980 --> 00:45:23,070 gives me what I would generally call 42-bit color. 999 00:45:23,070 --> 00:45:26,210 So if you've ever seen that, maybe even in your Mac or PC-- if you ever 1000 00:45:26,210 --> 00:45:29,750 futz around your display Control Panel or the equivalent, sometimes 1001 00:45:29,750 --> 00:45:31,770 you'll see, do you want thousands of colors? 1002 00:45:31,770 --> 00:45:32,940 Millions of colors? 1003 00:45:32,940 --> 00:45:34,740 Or even bigger numbers still? 1004 00:45:34,740 --> 00:45:36,990 That's just the user-friendly way of saying, 1005 00:45:36,990 --> 00:45:42,380 do you want 16-bit color whereby you're using only 16 bits to represent 1006 00:45:42,380 --> 00:45:43,930 the color of a dot on a screen? 1007 00:45:43,930 --> 00:45:46,210 Do you want 24-bit color, which means do you 1008 00:45:46,210 --> 00:45:49,210 want to use 24 bits to represent the color of each dot? 1009 00:45:49,210 --> 00:45:51,060 Or perhaps even more still? 1010 00:45:51,060 --> 00:45:54,090 Back in the day, when some of you first got computers, 1011 00:45:54,090 --> 00:45:55,760 how many bit color was there? 1012 00:45:55,760 --> 00:45:59,140 1013 00:45:59,140 --> 00:46:00,687 16 was actually pretty good. 1014 00:46:00,687 --> 00:46:03,020 Games were starting to look pretty nice in 16-bit color. 1015 00:46:03,020 --> 00:46:06,035 Windows 3.1 was probably 16-bit color. 1016 00:46:06,035 --> 00:46:08,120 Or, no, it was probably 8-bit color. 1017 00:46:08,120 --> 00:46:14,490 So 8-bit, back in the day, but some of you surely had older computers still. 1018 00:46:14,490 --> 00:46:19,937 Even my first games were two colors for which you only need one bit. 1019 00:46:19,937 --> 00:46:22,770 And it wasn't even black and white, it was probably black and green, 1020 00:46:22,770 --> 00:46:24,590 where green was white. 1021 00:46:24,590 --> 00:46:26,670 And so that was monochrome, which is really 1022 00:46:26,670 --> 00:46:29,510 just a fancy way of saying 1-bit color. 1023 00:46:29,510 --> 00:46:31,790 Or maybe this is the fancy way of saying monochrome. 1024 00:46:31,790 --> 00:46:33,380 So what's the takeaway here? 1025 00:46:33,380 --> 00:46:37,870 We can represent colors simply by using numbers, 1026 00:46:37,870 --> 00:46:40,970 for instance, 0 to 255, where 0 means very little of this, 1027 00:46:40,970 --> 00:46:42,710 255 means a lot of this. 1028 00:46:42,710 --> 00:46:45,580 And so long as we humans standardize the world of colors, 1029 00:46:45,580 --> 00:46:50,240 also, as we did for letters, with something like RGB-- how much red, 1030 00:46:50,240 --> 00:46:53,380 how much green, how much blue do you want-- we can mix those together. 1031 00:46:53,380 --> 00:46:57,120 And now, in the context of graphical programs or maybe web browsers, 1032 00:46:57,120 --> 00:46:59,880 we can say, oh, this pattern of 24 bits is 1033 00:46:59,880 --> 00:47:03,040 meant to be represented as the color of a dot on a screen. 1034 00:47:03,040 --> 00:47:06,960 I shall interpret it as such and not as a number or as a really big letter 1035 00:47:06,960 --> 00:47:09,310 or as a sequence of three letters. 1036 00:47:09,310 --> 00:47:13,990 So this gives us the ability to represent the color of one dot, one 1037 00:47:13,990 --> 00:47:15,660 so-called pixel, on your screen. 1038 00:47:15,660 --> 00:47:17,920 And pixels are so small you can't really see them. 1039 00:47:17,920 --> 00:47:20,227 But if we went up to the TV, on the screen here, 1040 00:47:20,227 --> 00:47:23,060 or if you have an older school TV at home, if you go up close to it, 1041 00:47:23,060 --> 00:47:27,040 you can probably see tiny, little dots, essentially, pixels. 1042 00:47:27,040 --> 00:47:28,010 That's not an image. 1043 00:47:28,010 --> 00:47:29,140 That's just a dot. 1044 00:47:29,140 --> 00:47:31,500 So what, then, is an image? 1045 00:47:31,500 --> 00:47:34,849 How does a computer represent images? 1046 00:47:34,849 --> 00:47:36,140 AUDIENCE: A sequence of pixels. 1047 00:47:36,140 --> 00:47:37,848 DAVID MALAN: A sequence of pixels, right. 1048 00:47:37,848 --> 00:47:40,700 An image, at the end of the day, especially old school comic books, 1049 00:47:40,700 --> 00:47:47,060 is really just a sequence of pixels, something like this. 1050 00:47:47,060 --> 00:47:51,920 Whereby this is a 4 by 4 grid of pixels. 1051 00:47:51,920 --> 00:47:56,140 And so long as I allocate 24 bits for this color, 24 bits for this color, 1052 00:47:56,140 --> 00:48:00,870 24 bits for this color, and so forth, I can represent a graphic. 1053 00:48:00,870 --> 00:48:03,440 And in fact, let me I can find one real fast. 1054 00:48:03,440 --> 00:48:06,610 Actually, let's see if we can make one real fast. 1055 00:48:06,610 --> 00:48:12,727 So if I draw a grid like this. 1056 00:48:12,727 --> 00:48:14,810 Let's see if I can allocate enough-- not to scale. 1057 00:48:14,810 --> 00:48:17,880 1058 00:48:17,880 --> 00:48:21,220 But if I have a grid, each of which allows 1059 00:48:21,220 --> 00:48:29,090 me to store the color of that pixel in the screen, you can imagine now using, 1060 00:48:29,090 --> 00:48:30,830 let's just say, 1-bit color. 1061 00:48:30,830 --> 00:48:34,380 So here is that old monochrome screen from yesteryear. 1062 00:48:34,380 --> 00:48:36,550 The grid just means you have rows and columns. 1063 00:48:36,550 --> 00:48:39,820 And either I want to put a 1 or a 0 in each of these boxes. 1064 00:48:39,820 --> 00:48:41,400 Well, how do you represent an image? 1065 00:48:41,400 --> 00:48:45,760 Well, let me try something kind of arbitrary. 1066 00:48:45,760 --> 00:48:56,515 How about 1, 1, 1, 1, 1, 1-- no, not there-- 1, 1, 1, 1, 1-- 1067 00:48:56,515 --> 00:48:57,390 this is not to scale. 1068 00:48:57,390 --> 00:48:59,040 Dammit. 1069 00:48:59,040 --> 00:49:02,720 OK, 1, 1, 1, 1, 1, 1. 1070 00:49:02,720 --> 00:49:03,889 What did I draw? 1071 00:49:03,889 --> 00:49:04,680 AUDIENCE: A circle. 1072 00:49:04,680 --> 00:49:06,230 DAVID MALAN: It's just a filled-in circle. 1073 00:49:06,230 --> 00:49:08,188 It was supposed to be a smiley face, but then I 1074 00:49:08,188 --> 00:49:11,000 realized I didn't leave enough room for the eyes or the nose. 1075 00:49:11,000 --> 00:49:12,160 So this is a circle. 1076 00:49:12,160 --> 00:49:14,572 This is how a computer would represent a circle. 1077 00:49:14,572 --> 00:49:16,030 But it really is as simple as that. 1078 00:49:16,030 --> 00:49:19,375 So if you think back to those green and black screens, all that was going on 1079 00:49:19,375 --> 00:49:21,750 was the computer had a pattern of bits, but in this case, 1080 00:49:21,750 --> 00:49:26,720 it was 1 bit per cell in this grid of rows and columns. 1081 00:49:26,720 --> 00:49:28,620 And if it were a 1, it should be green. 1082 00:49:28,620 --> 00:49:31,110 And if it should be black, it should be 0, or vice versa. 1083 00:49:31,110 --> 00:49:33,680 Doesn't matter, so long as we're consistent. 1084 00:49:33,680 --> 00:49:35,690 So now this is an image. 1085 00:49:35,690 --> 00:49:37,830 An image is a sequence of pixels. 1086 00:49:37,830 --> 00:49:40,150 A pixel is just a pattern of 0's and 1's. 1087 00:49:40,150 --> 00:49:43,160 Those 0's and 1's are just three different numbers. 1088 00:49:43,160 --> 00:49:46,370 And those numbers are, respectively, just patterns of bits. 1089 00:49:46,370 --> 00:49:47,380 Notice the layering. 1090 00:49:47,380 --> 00:49:49,838 And this, too, is going to be a theme of today or tomorrow. 1091 00:49:49,838 --> 00:49:53,870 Lowest level, which we won't really come back to beyond today, is the bits, 1092 00:49:53,870 --> 00:49:54,740 the 0's and 1's. 1093 00:49:54,740 --> 00:49:57,360 Now we're at this point in the story where we've forgotten 1094 00:49:57,360 --> 00:49:59,247 about bits and letters and pixels. 1095 00:49:59,247 --> 00:50:00,580 We're just talking about images. 1096 00:50:00,580 --> 00:50:01,895 What comes next? 1097 00:50:01,895 --> 00:50:02,770 Well, what's a video? 1098 00:50:02,770 --> 00:50:05,697 1099 00:50:05,697 --> 00:50:07,530 How do you implement a video as an engineer? 1100 00:50:07,530 --> 00:50:07,830 Grace? 1101 00:50:07,830 --> 00:50:08,796 GRACE: [INAUDIBLE]. 1102 00:50:08,796 --> 00:50:11,790 I mean, it's sequential images. 1103 00:50:11,790 --> 00:50:12,540 DAVID MALAN: Yeah. 1104 00:50:12,540 --> 00:50:13,910 It's just sequential images. 1105 00:50:13,910 --> 00:50:16,410 So the phone book doesn't quite behave in the same way, 1106 00:50:16,410 --> 00:50:18,618 but if you remember those little books from childhood 1107 00:50:18,618 --> 00:50:20,340 where you flip the pages really fast, you 1108 00:50:20,340 --> 00:50:24,620 would actually see Mickey Mouse or whatever moving as though there 1109 00:50:24,620 --> 00:50:26,141 were actually a video in your hands. 1110 00:50:26,141 --> 00:50:27,890 But really, all that's happening is you're 1111 00:50:27,890 --> 00:50:31,380 seeing an artist's sequence of pictures where Mickey in one picture 1112 00:50:31,380 --> 00:50:34,740 looks like this, then the next one he looks like this, this, this, this-- 1113 00:50:34,740 --> 00:50:36,840 until he's waving at you. 1114 00:50:36,840 --> 00:50:40,400 But that's just because it's 100 different pixel pictures where 1115 00:50:40,400 --> 00:50:44,110 in each one, his hand is moving as though it's in a waving movement. 1116 00:50:44,110 --> 00:50:45,394 And so that's all a video is. 1117 00:50:45,394 --> 00:50:48,310 A video that you might double click or watch on YouTube or live really 1118 00:50:48,310 --> 00:50:52,990 is just a sequence of images, moving pictures, as they used to be called. 1119 00:50:52,990 --> 00:50:56,770 Motion pictures are just pictures that move, that fly by the screen. 1120 00:50:56,770 --> 00:51:01,390 We humans typically expect at least 24 frames or pictures per second, 1121 00:51:01,390 --> 00:51:04,500 or TV commonly has 30 frames per second. 1122 00:51:04,500 --> 00:51:07,060 Beyond that, we don't really notice the difference. 1123 00:51:07,060 --> 00:51:11,410 Although, if any of you have-- a lot of smart TVs 1124 00:51:11,410 --> 00:51:17,180 these days have auto motion plus or 60 Hertz or 120 Hertz. 1125 00:51:17,180 --> 00:51:19,080 If you've ever noticed that all of your TV 1126 00:51:19,080 --> 00:51:21,360 shows on your nice, new TV look like soap operas, 1127 00:51:21,360 --> 00:51:26,300 like daytime soap operas where the movement is just sort of unnaturally 1128 00:51:26,300 --> 00:51:28,540 smooth-- and yet, that is more natural because it's 1129 00:51:28,540 --> 00:51:30,540 capturing more of the image-- that's because you 1130 00:51:30,540 --> 00:51:33,670 have this feature that manufacturers decided would be better whereby 1131 00:51:33,670 --> 00:51:38,830 even if a show or movie has been shot 24 frames per second, 1132 00:51:38,830 --> 00:51:40,350 they actually fill in the gaps. 1133 00:51:40,350 --> 00:51:43,820 They interpolate what the scenes might have looked like for those split 1134 00:51:43,820 --> 00:51:45,200 seconds between those frames. 1135 00:51:45,200 --> 00:51:49,060 And the result is what looks more like a soap opera, which tends 1136 00:51:49,060 --> 00:51:50,927 to be shot at 30 frames per second. 1137 00:51:50,927 --> 00:51:53,010 So they're just smoother, which is not necessarily 1138 00:51:53,010 --> 00:51:56,990 the director or the photographer's intention. 1139 00:51:56,990 --> 00:51:58,970 So that's all related there, too. 1140 00:51:58,970 --> 00:52:03,310 So if a video is just a sequence of pictures, well, to represent a circle, 1141 00:52:03,310 --> 00:52:04,910 we need this many bits. 1142 00:52:04,910 --> 00:52:10,160 If we want to represent a whole second in a movie, we might need 24 times 1143 00:52:10,160 --> 00:52:12,690 this many bits or 30 times this many bits 1144 00:52:12,690 --> 00:52:15,920 if we want 24 pictures per second or 30 frames per second. 1145 00:52:15,920 --> 00:52:19,030 And this is why videos are so damn large. 1146 00:52:19,030 --> 00:52:23,390 There are so many individual pictures in them, those bits need to be stored. 1147 00:52:23,390 --> 00:52:25,250 And that, too, is a bit of a white lie. 1148 00:52:25,250 --> 00:52:28,760 In reality, there is fancy algorithms or processes for compressing things. 1149 00:52:28,760 --> 00:52:31,172 So you don't need one true image per frame. 1150 00:52:31,172 --> 00:52:34,130 But that's actually a perfect segue way to the last of our ingredients, 1151 00:52:34,130 --> 00:52:37,940 which is this one here. 1152 00:52:37,940 --> 00:52:39,090 Algorithms. 1153 00:52:39,090 --> 00:52:40,700 But where have we left things now? 1154 00:52:40,700 --> 00:52:43,180 Started with bits, we went to numbers. 1155 00:52:43,180 --> 00:52:44,250 We went to letters. 1156 00:52:44,250 --> 00:52:46,110 We then went to colors or pixels. 1157 00:52:46,110 --> 00:52:47,160 We then went to images. 1158 00:52:47,160 --> 00:52:48,720 We then went to videos. 1159 00:52:48,720 --> 00:52:52,160 And now we've pretty much abstracted so far away, 1160 00:52:52,160 --> 00:52:54,640 we don't even need to care about the 0's and 1's anymore. 1161 00:52:54,640 --> 00:52:57,015 And indeed, when you walk out of here today and tomorrow, 1162 00:52:57,015 --> 00:52:59,450 you shouldn't really care much about the 0's and 1's that 1163 00:52:59,450 --> 00:53:03,552 underlie any of your data because of this feature known as abstraction. 1164 00:53:03,552 --> 00:53:06,510 And indeed, this is one of the powerful tools in a computer scientist's 1165 00:53:06,510 --> 00:53:06,890 toolkit. 1166 00:53:06,890 --> 00:53:08,650 We're just playing with it verbally today, 1167 00:53:08,650 --> 00:53:10,790 but indeed, when writing software, abstraction 1168 00:53:10,790 --> 00:53:13,010 is actually a feature of programming languages 1169 00:53:13,010 --> 00:53:15,250 that we'll see a little bit of tomorrow whereby 1170 00:53:15,250 --> 00:53:19,190 you don't need to know or care how something is implemented. 1171 00:53:19,190 --> 00:53:21,660 You can think of a computer as just a black box that 1172 00:53:21,660 --> 00:53:24,190 has certain functionality built in because other humans 1173 00:53:24,190 --> 00:53:27,680 before you have abstracted away these lower-level details. 1174 00:53:27,680 --> 00:53:30,950 Or more casually, you can think of it as standing on the shoulders of people 1175 00:53:30,950 --> 00:53:32,030 who came before you. 1176 00:53:32,030 --> 00:53:35,000 Someone, years ago, figured out how to store 0's and 1's. 1177 00:53:35,000 --> 00:53:38,330 Someone after that figured out how to store letters and pixels. 1178 00:53:38,330 --> 00:53:41,510 But thereafter, we humans can build on top of that work 1179 00:53:41,510 --> 00:53:44,080 and implement things like pictures and movies 1180 00:53:44,080 --> 00:53:46,630 and yet other file formats, still. 1181 00:53:46,630 --> 00:53:49,132 And so that general feature of abstraction or layering 1182 00:53:49,132 --> 00:53:51,090 is actually a powerful ingredient when it comes 1183 00:53:51,090 --> 00:53:53,414 to actually solving some problems. 1184 00:53:53,414 --> 00:53:53,972 JP: David? 1185 00:53:53,972 --> 00:53:54,680 DAVID MALAN: Yes. 1186 00:53:54,680 --> 00:53:55,730 JP: [INAUDIBLE]. 1187 00:53:55,730 --> 00:53:55,980 DAVID MALAN: Yes. 1188 00:53:55,980 --> 00:53:56,480 Of course. 1189 00:53:56,480 --> 00:53:57,156 JP: OK. 1190 00:53:57,156 --> 00:53:57,822 DAVID MALAN: JP. 1191 00:53:57,822 --> 00:54:03,050 JP: [INAUDIBLE] because I think [INAUDIBLE] talking about that. 1192 00:54:03,050 --> 00:54:04,896 So we're back to the bits. 1193 00:54:04,896 --> 00:54:08,832 That bit we saw there on the screen, is it being used in several codes? 1194 00:54:08,832 --> 00:54:11,292 So one bit's being used in several codes, 1195 00:54:11,292 --> 00:54:13,260 like [INAUDIBLE], letter, number. 1196 00:54:13,260 --> 00:54:14,736 Or is it being used once? 1197 00:54:14,736 --> 00:54:19,144 And then, how are we to know to use it as a bit? [INAUDIBLE]. 1198 00:54:19,144 --> 00:54:20,810 DAVID MALAN: Good question-- the latter. 1199 00:54:20,810 --> 00:54:25,320 A bit is only used one time, so if the picture that's on the screen right now 1200 00:54:25,320 --> 00:54:27,280 is just the colorful version of this-- So 1201 00:54:27,280 --> 00:54:30,695 if this is a top-down view of a platter inside of your hard drive-- 1202 00:54:30,695 --> 00:54:32,820 which, a platter is just like an old school record. 1203 00:54:32,820 --> 00:54:36,080 And on this platter are whole bunches of bits 1204 00:54:36,080 --> 00:54:39,000 that are either north, south or south, north. 1205 00:54:39,000 --> 00:54:40,230 So they're not all 1's. 1206 00:54:40,230 --> 00:54:44,250 These are just actually-- do we have any other colors? 1207 00:54:44,250 --> 00:54:45,850 No other colors here. 1208 00:54:45,850 --> 00:54:49,160 So there's all these little magnetic particles, much like the Woolly Willy 1209 00:54:49,160 --> 00:54:50,780 photograph I pulled up earlier. 1210 00:54:50,780 --> 00:54:55,780 So if you create a Microsoft Word file, the operating system, Windows, or Mac 1211 00:54:55,780 --> 00:55:00,840 OS or Linux or whatever else, decides, OK, that's a pretty medium-sized file, 1212 00:55:00,840 --> 00:55:06,180 this shall be your resume.docx or some such file. 1213 00:55:06,180 --> 00:55:11,915 If you then have an image like reunion.jpg from your family reunion, 1214 00:55:11,915 --> 00:55:13,790 the operating system might decide, all right, 1215 00:55:13,790 --> 00:55:15,280 it's actually a pretty big image. 1216 00:55:15,280 --> 00:55:17,140 You took it at really high resolution. 1217 00:55:17,140 --> 00:55:21,580 These bits shall be used for your reunion.jpg. 1218 00:55:21,580 --> 00:55:26,420 JP: At the level of bits, if you have a high-definition screen, right, 1219 00:55:26,420 --> 00:55:29,927 every pixel you have, you know, [INAUDIBLE]. 1220 00:55:29,927 --> 00:55:30,760 DAVID MALAN: Indeed. 1221 00:55:30,760 --> 00:55:32,570 JP: [INAUDIBLE]. 1222 00:55:32,570 --> 00:55:33,570 DAVID MALAN: Absolutely. 1223 00:55:33,570 --> 00:55:36,560 JP: Because the number of bits is insanely high. 1224 00:55:36,560 --> 00:55:37,386 DAVID MALAN: It is. 1225 00:55:37,386 --> 00:55:37,960 It is. 1226 00:55:37,960 --> 00:55:40,240 So on our screen alone-- so we can see this, actually. 1227 00:55:40,240 --> 00:55:44,760 In Mac OS, and Windows has an analog here, if I go to Display, 1228 00:55:44,760 --> 00:55:48,160 I am currently in a resolution called 720p, 1229 00:55:48,160 --> 00:55:53,010 which means 720 pixels, top to bottom, and 1280-- 1230 00:55:53,010 --> 00:55:55,910 this is implicit-- 1,280 pixels across. 1231 00:55:55,910 --> 00:56:04,510 Which means on my Mac screen here alone, I have this many pixels, so 921,600, 1232 00:56:04,510 --> 00:56:05,720 just on my screen alone. 1233 00:56:05,720 --> 00:56:07,520 JP: But every pixel has a different color. 1234 00:56:07,520 --> 00:56:09,478 DAVID MALAN: Every pixel has a different color. 1235 00:56:09,478 --> 00:56:12,890 And if my computer is in 24-bit color, that 1236 00:56:12,890 --> 00:56:17,550 means I'm using this many bits just to represent what 1237 00:56:17,550 --> 00:56:19,710 you are seeing on my screen right now. 1238 00:56:19,710 --> 00:56:25,300 So this is-- 22 million bits are being used just 1239 00:56:25,300 --> 00:56:27,310 to display what's on the screen. 1240 00:56:27,310 --> 00:56:29,870 But that's OK because let's consider this. 1241 00:56:29,870 --> 00:56:32,430 So if that's bits-- I didn't use this word formally 1242 00:56:32,430 --> 00:56:36,230 before but a byte, which is the unit of measure with which most humans speak, 1243 00:56:36,230 --> 00:56:37,840 is just 8 bits. 1244 00:56:37,840 --> 00:56:40,930 So to represent everything on my screen right now 1245 00:56:40,930 --> 00:56:46,010 is actually just 2 million bytes. 1246 00:56:46,010 --> 00:56:51,200 And how many bytes are in, say, a kilobyte? 1247 00:56:51,200 --> 00:56:54,490 This is 2,700 kilobytes. 1248 00:56:54,490 --> 00:57:02,550 And if I divide it again by 1,024, it takes roughly 2.6 megabytes 1249 00:57:02,550 --> 00:57:06,960 of information, 2.6 million bytes, to store the colors of everything 1250 00:57:06,960 --> 00:57:11,110 you see on my screen here, whether it's black and white or perfectly colorful. 1251 00:57:11,110 --> 00:57:13,930 1252 00:57:13,930 --> 00:57:18,585 JP: How does it know that that particular section is [INAUDIBLE]? 1253 00:57:18,585 --> 00:57:19,710 DAVID MALAN: Good question. 1254 00:57:19,710 --> 00:57:22,950 So the latter piece of your question is answered by the operating system. 1255 00:57:22,950 --> 00:57:26,360 One of the purposes in life of Mac OS or Windows 1256 00:57:26,360 --> 00:57:28,730 is to manage the space on your hard drive. 1257 00:57:28,730 --> 00:57:32,360 And essentially, all of the bytes on your hard drive, 1258 00:57:32,360 --> 00:57:35,860 much like all of the bytes in RAM, the technology we discussed earlier, 1259 00:57:35,860 --> 00:57:36,720 have addresses. 1260 00:57:36,720 --> 00:57:40,980 So if you have a 4 terabyte hard drive, which is actually-- no, 1261 00:57:40,980 --> 00:57:44,470 let's call it a 4 gigabyte hard drive, which is actually 1262 00:57:44,470 --> 00:57:46,160 super small these days, certainly. 1263 00:57:46,160 --> 00:57:48,330 But if you can only store 4 gigabytes, you 1264 00:57:48,330 --> 00:57:54,370 can think of each of the areas of this hard drive-- if each of these squares 1265 00:57:54,370 --> 00:58:00,260 represents a byte, you can think of this as being 0, 1, 2, 3, 4, 5, 6. 1266 00:58:00,260 --> 00:58:04,010 You can imagine numbering all of the bytes of space on a hard drive. 1267 00:58:04,010 --> 00:58:07,580 What an operating system has underneath the hood 1268 00:58:07,580 --> 00:58:11,920 is a directory, many directories, actually, that 1269 00:58:11,920 --> 00:58:17,150 has at least two columns-- the file and its location. 1270 00:58:17,150 --> 00:58:21,620 So resume.docx might have an entry in this table, a.k.a. 1271 00:58:21,620 --> 00:58:29,840 a directory, and it might be at location 7, whereas reunion.jpg-- this 1272 00:58:29,840 --> 00:58:31,310 is a little farther to the right. 1273 00:58:31,310 --> 00:58:34,990 So I'm going to say that this is at location 117. 1274 00:58:34,990 --> 00:58:36,270 I made that one up. 1275 00:58:36,270 --> 00:58:39,010 So your operating system literally has a table, 1276 00:58:39,010 --> 00:58:42,600 not unlike what Microsoft Excel might do or Google spreadsheets, that just 1277 00:58:42,600 --> 00:58:46,140 maps file names to locations on disk. 1278 00:58:46,140 --> 00:58:48,880 And in fact, this is a good opportunity to raise 1279 00:58:48,880 --> 00:58:51,310 one of tomorrow's topics, privacy and security. 1280 00:58:51,310 --> 00:58:53,645 What does it mean when you delete resume.docx? 1281 00:58:53,645 --> 00:58:56,115 1282 00:58:56,115 --> 00:58:57,990 And better yet, suppose it's not resume.docx, 1283 00:58:57,990 --> 00:59:01,770 suppose it's your financial information or passwords.docx. 1284 00:59:01,770 --> 00:59:03,980 You decide, oh, I probably don't want this anymore. 1285 00:59:03,980 --> 00:59:05,300 I don't want someone seeing it. 1286 00:59:05,300 --> 00:59:06,330 So you delete it. 1287 00:59:06,330 --> 00:59:09,740 What does it mean in Mac OS or Windows when you drag a file 1288 00:59:09,740 --> 00:59:11,692 to the trash can or the recycle bin? 1289 00:59:11,692 --> 00:59:13,900 AUDIENCE: It might just take it out of the directory. 1290 00:59:13,900 --> 00:59:16,025 DAVID MALAN: It just takes it out of the directory. 1291 00:59:16,025 --> 00:59:18,306 And can you recover the file, still? 1292 00:59:18,306 --> 00:59:19,810 AUDIENCE: [INAUDIBLE]. 1293 00:59:19,810 --> 00:59:21,550 DAVID MALAN: Yeah, it's in the trash can. 1294 00:59:21,550 --> 00:59:24,550 So really, there's a separate table for what's in the trash can. 1295 00:59:24,550 --> 00:59:26,360 But suppose you're smarter than that. 1296 00:59:26,360 --> 00:59:29,400 You know that just dragging something to the trash can doesn't remove, 1297 00:59:29,400 --> 00:59:30,530 empty the trash. 1298 00:59:30,530 --> 00:59:32,090 It's still actually there. 1299 00:59:32,090 --> 00:59:34,960 So what happens when Mac OS or Windows users actually 1300 00:59:34,960 --> 00:59:38,000 empty the trash can or recycle bin? 1301 00:59:38,000 --> 00:59:39,570 AUDIENCE: It deletes the location. 1302 00:59:39,570 --> 00:59:40,903 DAVID MALAN: That's all it does. 1303 00:59:40,903 --> 00:59:43,770 When you delete a file, typically, on a modern operating system, 1304 00:59:43,770 --> 00:59:45,780 all you're doing is that. 1305 00:59:45,780 --> 00:59:47,990 You're forgetting where the file is. 1306 00:59:47,990 --> 00:59:51,210 But what have I not changed on the white board? 1307 00:59:51,210 --> 00:59:52,140 AUDIENCE: The disk. 1308 00:59:52,140 --> 00:59:52,931 DAVID MALAN: Right. 1309 00:59:52,931 --> 00:59:54,720 I have not touched the magnetic particles 1310 00:59:54,720 --> 00:59:57,530 on the hard drive, which is to say, if you remember programs 1311 00:59:57,530 --> 01:00:00,950 like Norton Utilities or other such programs 1312 01:00:00,950 --> 01:00:04,660 from yesteryear that claim to be able to undelete files, how do they do that? 1313 01:00:04,660 --> 01:00:07,070 Well, they scour your hard drive looking for what 1314 01:00:07,070 --> 01:00:10,590 looks like the remnants of files like resume.docx. 1315 01:00:10,590 --> 01:00:13,200 And if it finds them, with high probability, 1316 01:00:13,200 --> 01:00:17,190 it creates a new file with those same bits inside of them. 1317 01:00:17,190 --> 01:00:19,840 So this is a side effect of computers remembering where 1318 01:00:19,840 --> 01:00:22,370 things are by way of these directories. 1319 01:00:22,370 --> 01:00:25,480 But deleting is usually just a matter of forgetting, 1320 01:00:25,480 --> 01:00:31,710 not securely changing those 0's and 1's to random nonsense or all 1's or all 1321 01:00:31,710 --> 01:00:32,507 0's. 1322 01:00:32,507 --> 01:00:34,590 So this was a bit of a tangent from your question, 1323 01:00:34,590 --> 01:00:37,980 but does that make sense as to how the computer is storing that information? 1324 01:00:37,980 --> 01:00:40,260 In short, the computer has a little cheat sheet 1325 01:00:40,260 --> 01:00:43,860 that remembers which bytes are used for which files. 1326 01:00:43,860 --> 01:00:44,555 Yeah. 1327 01:00:44,555 --> 01:00:47,305 AUDIENCE: But over time, didn't you use your computer? [INAUDIBLE] 1328 01:00:47,305 --> 01:00:49,554 the bytes [? started being ?] organized, and the files 1329 01:00:49,554 --> 01:00:50,840 will be eventually be deleted? 1330 01:00:50,840 --> 01:00:52,210 DAVID MALAN: They will not so much get deleted. 1331 01:00:52,210 --> 01:00:54,070 They will get overwritten or reused. 1332 01:00:54,070 --> 01:00:54,570 Correct. 1333 01:00:54,570 --> 01:00:55,694 You can't just delete bits. 1334 01:00:55,694 --> 01:00:58,420 You can't remove-- I mean, if you open the old school floppy disk 1335 01:00:58,420 --> 01:01:01,410 and rubbed it, you would move the magnetic particles off. 1336 01:01:01,410 --> 01:01:04,620 That doesn't, of course, happen underneath the hood of your computer. 1337 01:01:04,620 --> 01:01:06,550 But yes, you'll eventually overwrite files. 1338 01:01:06,550 --> 01:01:07,550 And I'm oversimplifying. 1339 01:01:07,550 --> 01:01:10,750 It turns out reunion.docx wouldn't necessarily 1340 01:01:10,750 --> 01:01:12,760 be all contiguous like this. 1341 01:01:12,760 --> 01:01:16,030 Hard drives and SSDs get fragmented, with some file bits 1342 01:01:16,030 --> 01:01:18,220 over here, over here, over here, over here. 1343 01:01:18,220 --> 01:01:21,050 So really, you can think of this as being like a list. 1344 01:01:21,050 --> 01:01:23,190 Well, some of the bytes are at 117. 1345 01:01:23,190 --> 01:01:24,490 Others start at 200. 1346 01:01:24,490 --> 01:01:27,020 Others start at 350, and so forth. 1347 01:01:27,020 --> 01:01:29,485 So there's this whole notion of linking files together just 1348 01:01:29,485 --> 01:01:31,360 so that you can consume the whole hard drive. 1349 01:01:31,360 --> 01:01:34,679 However, if some of you had PCs years ago, 1350 01:01:34,679 --> 01:01:37,720 you might have had something like Norton Utilities, one of whose features 1351 01:01:37,720 --> 01:01:39,237 was to defragment a hard disk. 1352 01:01:39,237 --> 01:01:41,320 And this was something tech people would sometimes 1353 01:01:41,320 --> 01:01:45,250 recommend-- that you should actually move around all the 0's and 1's so 1354 01:01:45,250 --> 01:01:48,890 that all your files are, in fact, next to each other 1355 01:01:48,890 --> 01:01:50,280 for efficiency on the disk. 1356 01:01:50,280 --> 01:01:52,780 The reality is these days disks are so fast that this is not 1357 01:01:52,780 --> 01:01:53,570 a good use of time. 1358 01:01:53,570 --> 01:01:56,278 So if people are still telling you to defragment your hard drive, 1359 01:01:56,278 --> 01:02:00,582 they're living in the past, for the most part. 1360 01:02:00,582 --> 01:02:02,040 Let the hard drive do the thinking. 1361 01:02:02,040 --> 01:02:06,090 Don't let utilities that you pay for have to worry about it anymore. 1362 01:02:06,090 --> 01:02:07,560 Used to be useful. 1363 01:02:07,560 --> 01:02:09,628 Other questions? 1364 01:02:09,628 --> 01:02:10,127 Yeah? 1365 01:02:10,127 --> 01:02:14,330 AUDIENCE: [INAUDIBLE] would be 16-bit. 1366 01:02:14,330 --> 01:02:17,401 Is that the reason for the Excel sheet [INAUDIBLE]? 1367 01:02:17,401 --> 01:02:18,150 DAVID MALAN: Yeah. 1368 01:02:18,150 --> 01:02:23,560 So for years Excel would only allow you to have 65,535 rows 1369 01:02:23,560 --> 01:02:27,370 possible, after which you just had to upgrade and pay for Microsoft 1370 01:02:27,370 --> 01:02:28,802 Access, a database program. 1371 01:02:28,802 --> 01:02:30,760 That was because they were using 16-bit values. 1372 01:02:30,760 --> 01:02:32,400 And I know this only because in graduate school 1373 01:02:32,400 --> 01:02:34,260 I was working with really large data sets. 1374 01:02:34,260 --> 01:02:37,135 And it was just convenient be able to load them into Excel sometimes. 1375 01:02:37,135 --> 01:02:40,650 And I remember swearing under my breath when I couldn't load my really big data 1376 01:02:40,650 --> 01:02:42,280 set because Excel wouldn't support it. 1377 01:02:42,280 --> 01:02:43,970 So they've since upgraded. 1378 01:02:43,970 --> 01:02:46,030 They now use bigger values for their rows. 1379 01:02:46,030 --> 01:02:46,958 Yeah, David? 1380 01:02:46,958 --> 01:02:54,533 DAVID: You said, when you talked about 32-bits and [INAUDIBLE] 64-bits. 1381 01:02:54,533 --> 01:02:58,349 But now machines have [INAUDIBLE] 32-bit registers, 1382 01:02:58,349 --> 01:03:04,156 64-bit registers, and it seems like they put them in blocks and [INAUDIBLE]. 1383 01:03:04,156 --> 01:03:07,650 What's that terminology for and why's it used? 1384 01:03:07,650 --> 01:03:08,400 DAVID MALAN: Sure. 1385 01:03:08,400 --> 01:03:12,510 So a register is really the smallest usable chunk 1386 01:03:12,510 --> 01:03:14,290 of memory inside of a computer. 1387 01:03:14,290 --> 01:03:17,390 Those registers are typically inside of the CPU itself. 1388 01:03:17,390 --> 01:03:19,530 When we say, Intel inside, that means that it's 1389 01:03:19,530 --> 01:03:21,610 an Intel CPU, central processing unit. 1390 01:03:21,610 --> 01:03:24,760 And the CPU is the device that, at the end of the day, 1391 01:03:24,760 --> 01:03:26,710 does all of the thinking in the computer. 1392 01:03:26,710 --> 01:03:28,120 It does all of the arithmetic. 1393 01:03:28,120 --> 01:03:30,050 And indeed, we didn't go down to this level. 1394 01:03:30,050 --> 01:03:32,750 It turns out that all of the operations we know on a computer 1395 01:03:32,750 --> 01:03:36,110 really do boil down to addition and subtraction and multiplication 1396 01:03:36,110 --> 01:03:37,360 and just moving memory around. 1397 01:03:37,360 --> 01:03:38,920 It really is that low level. 1398 01:03:38,920 --> 01:03:40,100 So that's what the CPU does. 1399 01:03:40,100 --> 01:03:42,470 So when someone claims that a computer has 1400 01:03:42,470 --> 01:03:45,880 a 32-bit register or 64-bit register, that just 1401 01:03:45,880 --> 01:03:51,980 means that when the CPU understands operations like add or subtract 1402 01:03:51,980 --> 01:03:55,290 or multiply, the value on the left and the value on the right 1403 01:03:55,290 --> 01:03:58,930 are each 32- or each 64-bits. 1404 01:03:58,930 --> 01:04:01,470 So the bigger the register, the bigger the math 1405 01:04:01,470 --> 01:04:03,560 the computer can do all at once. 1406 01:04:03,560 --> 01:04:07,080 So computers can still do math on really big numbers 1407 01:04:07,080 --> 01:04:09,660 on 33-bit values or 65-bit values, but they 1408 01:04:09,660 --> 01:04:13,620 need to use multiple numbers or multiple sets of bits 1409 01:04:13,620 --> 01:04:15,520 to represent bigger numbers. 1410 01:04:15,520 --> 01:04:18,731 The bigger a byte a computer can take out of a problem, though, typically, 1411 01:04:18,731 --> 01:04:19,230 the better. 1412 01:04:19,230 --> 01:04:24,720 So 64-bit registers or a 64-bit CPU can generally do more work per unit of time 1413 01:04:24,720 --> 01:04:26,460 than a 32-bit computer. 1414 01:04:26,460 --> 01:04:27,210 So more is better. 1415 01:04:27,210 --> 01:04:30,930 And we're kind of in that stage of life where 64-bit machines are all the rage. 1416 01:04:30,930 --> 01:04:34,790 And most of us in this room, if not everyone, have 64-bit computers. 1417 01:04:34,790 --> 01:04:36,686 And I don't know if it's available. 1418 01:04:36,686 --> 01:04:39,950 1419 01:04:39,950 --> 01:04:41,720 Mac OS doesn't say it here. 1420 01:04:41,720 --> 01:04:44,800 1421 01:04:44,800 --> 01:04:46,690 Does it say somewhere? 1422 01:04:46,690 --> 01:04:52,020 If I poked around enough-- let me try this. 1423 01:04:52,020 --> 01:04:52,520 OK. 1424 01:04:52,520 --> 01:04:53,270 Here we go. 1425 01:04:53,270 --> 01:04:56,340 So this is an esoteric command that most people would never execute. 1426 01:04:56,340 --> 01:04:59,750 But I just asked my computer via this text-based interface for information 1427 01:04:59,750 --> 01:05:00,440 about it. 1428 01:05:00,440 --> 01:05:05,820 And the fact that it says x86 64 here and here, 1429 01:05:05,820 --> 01:05:09,410 that means this is a 64-bit computer. 1430 01:05:09,410 --> 01:05:10,500 All Macs are this way. 1431 01:05:10,500 --> 01:05:12,790 PCs-- some 32-bit machines still exist. 1432 01:05:12,790 --> 01:05:15,720 And the symptoms you would run into is if you try and install 1433 01:05:15,720 --> 01:05:21,030 a new program on old hardware, you might not be able to. 1434 01:05:21,030 --> 01:05:24,909 For instance, Windows 10 maybe only works on 64-bit machines. 1435 01:05:24,909 --> 01:05:25,450 I'm not sure. 1436 01:05:25,450 --> 01:05:26,449 I'd have to Google that. 1437 01:05:26,449 --> 01:05:29,490 But newer software often no longer supports older hardware. 1438 01:05:29,490 --> 01:05:32,070 So that's the only time you would really care these days. 1439 01:05:32,070 --> 01:05:32,570 Felicia? 1440 01:05:32,570 --> 01:05:35,070 FELICIA: [INAUDIBLE] like the comment in memory, 1441 01:05:35,070 --> 01:05:36,954 like if the program is running in memory. 1442 01:05:36,954 --> 01:05:37,870 That's a speed factor. 1443 01:05:37,870 --> 01:05:41,207 You're referencing that because? 1444 01:05:41,207 --> 01:05:42,790 DAVID MALAN: Can you be more specific? 1445 01:05:42,790 --> 01:05:46,814 FELICIA: [INAUDIBLE] program is like [INAUDIBLE] intelligence tools 1446 01:05:46,814 --> 01:05:48,260 like [INAUDIBLE]. 1447 01:05:48,260 --> 01:05:52,239 [? Oh, ?] it runs in memory, as if it's a [INAUDIBLE] feature that-- 1448 01:05:52,239 --> 01:05:55,280 DAVID MALAN: Can you elaborate on what those programs are supposed to do, 1449 01:05:55,280 --> 01:05:57,270 and I can try to infer what they mean? 1450 01:05:57,270 --> 01:06:02,429 FELICIA: [INAUDIBLE] do a calculation, drawing graphs, [INAUDIBLE]. 1451 01:06:02,429 --> 01:06:03,970 DAVID MALAN: I'd have to look closer. 1452 01:06:03,970 --> 01:06:05,930 It sounds like stupid marketing speak, to me. 1453 01:06:05,930 --> 01:06:07,030 FELICIA: OK. 1454 01:06:07,030 --> 01:06:09,190 DAVID MALAN: I think that "me" is meaningless. 1455 01:06:09,190 --> 01:06:12,720 That's where computers store all of their data while being used. 1456 01:06:12,720 --> 01:06:15,724 I'm probably doing them a slight disservice. 1457 01:06:15,724 --> 01:06:19,402 AUDIENCE: Well, I use them, and basically, it's 1458 01:06:19,402 --> 01:06:24,416 a difference that it's an analytics tool that is pre-loaded in that case. 1459 01:06:24,416 --> 01:06:28,699 So rather than querying against a database, it's done its aggregation. 1460 01:06:28,699 --> 01:06:29,532 DAVID MALAN: Oh, OK. 1461 01:06:29,532 --> 01:06:32,964 AUDIENCE: And as you're doing analytics it gets-- 1462 01:06:32,964 --> 01:06:36,170 it's pre-aggregated, pre-analyzed data. 1463 01:06:36,170 --> 01:06:39,054 You're exploring, but you're not hitting against the database. 1464 01:06:39,054 --> 01:06:39,720 DAVID MALAN: OK. 1465 01:06:39,720 --> 01:06:43,270 So that's a little more illuminating. 1466 01:06:43,270 --> 01:06:46,520 The reality is-- and we really talk about this later today, 1467 01:06:46,520 --> 01:06:48,740 but databases tend to be relatively slow. 1468 01:06:48,740 --> 01:06:51,360 But it's where you store data long term, much like for files, 1469 01:06:51,360 --> 01:06:52,630 get stored on a hard disk. 1470 01:06:52,630 --> 01:06:56,390 But in so far as they're slow, if you do want to do a lot of real-time analysis, 1471 01:06:56,390 --> 01:06:59,080 it's better to read all of the data from the database 1472 01:06:59,080 --> 01:07:03,390 where it could be living in disk space, physical disk space, into RAM. 1473 01:07:03,390 --> 01:07:05,460 But even then, it's not necessarily the database. 1474 01:07:05,460 --> 01:07:10,640 You can have databases that, themselves, exist entirely in memory or in RAM, 1475 01:07:10,640 --> 01:07:11,280 not on disk. 1476 01:07:11,280 --> 01:07:13,440 So that's probably what they're pointing to and probably 1477 01:07:13,440 --> 01:07:16,356 how they're justifying charging you more for the additional RAM that's 1478 01:07:16,356 --> 01:07:18,010 requisite for that. 1479 01:07:18,010 --> 01:07:20,430 So before I impugn some software I've never 1480 01:07:20,430 --> 01:07:24,250 used-- but it's also a little bit of marketing speak, it sounds. 1481 01:07:24,250 --> 01:07:26,880 I would hope it would be in memory. 1482 01:07:26,880 --> 01:07:28,990 OK other questions? 1483 01:07:28,990 --> 01:07:29,490 All right. 1484 01:07:29,490 --> 01:07:32,820 Well, let's address the last of these ingredients, algorithms, 1485 01:07:32,820 --> 01:07:34,440 and make this a little more concrete. 1486 01:07:34,440 --> 01:07:37,140 We've talked, daresay, ad nauseum about inputs and outputs 1487 01:07:37,140 --> 01:07:38,890 and how we might represent them and how we 1488 01:07:38,890 --> 01:07:40,760 might abstract from the lowest-level details 1489 01:07:40,760 --> 01:07:43,290 to the highest-level incarnations of them. 1490 01:07:43,290 --> 01:07:47,200 But what's important when it comes to things like algorithms? 1491 01:07:47,200 --> 01:07:49,584 Well, I promised that I would take out this. 1492 01:07:49,584 --> 01:07:52,250 And this is a problem that most of us don't really have anymore, 1493 01:07:52,250 --> 01:07:54,840 looking up someone's phone number in a device like this. 1494 01:07:54,840 --> 01:07:56,460 These days, you take out your phone. 1495 01:07:56,460 --> 01:07:59,543 But even the phone is just kind of the digital incarnation of this because 1496 01:07:59,543 --> 01:08:03,740 on Android or iOS, if you go to the contacts app, 1497 01:08:03,740 --> 01:08:05,810 everything is still sorted alphabetically. 1498 01:08:05,810 --> 01:08:08,240 So even though what we're about to do is very physical, 1499 01:08:08,240 --> 01:08:10,720 turns out that even digitally, the problem is the same. 1500 01:08:10,720 --> 01:08:14,140 It's just implemented not with physical hands but with software. 1501 01:08:14,140 --> 01:08:15,370 So more on that in a bit. 1502 01:08:15,370 --> 01:08:16,149 So this is a phone book. 1503 01:08:16,149 --> 01:08:17,565 Let's assume it's all white pages. 1504 01:08:17,565 --> 01:08:20,507 And let's assume I'm looking for someone like Mike Smith. 1505 01:08:20,507 --> 01:08:22,590 If I want to look up Mike Smith in the phone book, 1506 01:08:22,590 --> 01:08:25,670 I could open up the phone book, look on page 1, look down. 1507 01:08:25,670 --> 01:08:27,890 I'm in the A section, so Mike's obviously not here. 1508 01:08:27,890 --> 01:08:31,630 So I keep turning the page, turning the page, turning the page. 1509 01:08:31,630 --> 01:08:36,550 So these are step-by-step instructions for solving this problem. 1510 01:08:36,550 --> 01:08:40,120 I'm looking at-- I'm supposed to be looking at each page for Mike Smith 1511 01:08:40,120 --> 01:08:41,069 until I find him. 1512 01:08:41,069 --> 01:08:43,750 Is this algorithm, these step-by-step instructions, 1513 01:08:43,750 --> 01:08:46,122 correct for finding Mike Smith? 1514 01:08:46,122 --> 01:08:46,926 AUDIENCE: Yes. 1515 01:08:46,926 --> 01:08:47,676 DAVID MALAN: Yeah. 1516 01:08:47,676 --> 01:08:49,689 If Mike is in here, I will find him. 1517 01:08:49,689 --> 01:08:52,010 But what's the obvious objection? 1518 01:08:52,010 --> 01:08:52,920 It's just slow. 1519 01:08:52,920 --> 01:08:53,569 This is silly. 1520 01:08:53,569 --> 01:08:57,680 So in grade school, two's, like in 2, 4, 6, 8-- 1521 01:08:57,680 --> 01:09:00,019 this algorithm is twice as fast-- twice as inaccurate 1522 01:09:00,019 --> 01:09:01,810 because I'm not really doing two at a time. 1523 01:09:01,810 --> 01:09:04,040 But if I did this accurately, it's twice as fast. 1524 01:09:04,040 --> 01:09:04,710 Is it correct? 1525 01:09:04,710 --> 01:09:07,220 1526 01:09:07,220 --> 01:09:07,720 Yes? 1527 01:09:07,720 --> 01:09:08,303 I heard a yes. 1528 01:09:08,303 --> 01:09:10,920 I heard a no. 1529 01:09:10,920 --> 01:09:11,930 It's not precise. 1530 01:09:11,930 --> 01:09:12,470 How so? 1531 01:09:12,470 --> 01:09:13,670 AUDIENCE: [INAUDIBLE]. 1532 01:09:13,670 --> 01:09:14,420 DAVID MALAN: Yeah. 1533 01:09:14,420 --> 01:09:15,880 So it's buggy, so to speak. 1534 01:09:15,880 --> 01:09:18,760 It has a potential mistake because what if Mike just 1535 01:09:18,760 --> 01:09:22,770 happens to be sandwiched between two pages as I fly by? 1536 01:09:22,770 --> 01:09:25,270 So is this irrecoverable, or can I fix this? 1537 01:09:25,270 --> 01:09:29,066 Or do I have to go back to the one page at a time approach? 1538 01:09:29,066 --> 01:09:31,899 What's a fix for this algorithm if I'm flying through the phone book 1539 01:09:31,899 --> 01:09:35,743 two pages at a time, and I don't want to risk missing Mike altogether? 1540 01:09:35,743 --> 01:09:37,960 AUDIENCE: [INAUDIBLE]. 1541 01:09:37,960 --> 01:09:38,979 DAVID MALAN: Yeah. 1542 01:09:38,979 --> 01:09:43,330 I know it's alphabetical, so maybe my heuristic is, if I hit the T section, 1543 01:09:43,330 --> 01:09:46,649 I'd better double back at least one page because I've clearly gone past Mike. 1544 01:09:46,649 --> 01:09:49,531 Or maybe he wasn't there, but I'd better go back one page at a time. 1545 01:09:49,531 --> 01:09:51,655 So you might fly through the problem twice as fast, 1546 01:09:51,655 --> 01:09:53,446 but you might have to double back a little. 1547 01:09:53,446 --> 01:09:56,800 So overall, the net effect is certainly a faster algorithm, 1548 01:09:56,800 --> 01:09:59,374 but it's not quite as simple as just two pages at a time. 1549 01:09:59,374 --> 01:10:01,790 But none of us are going to do either of these algorithms. 1550 01:10:01,790 --> 01:10:06,050 What's a typical human going to do 10 years ago? 1551 01:10:06,050 --> 01:10:07,630 Or recently, I suppose? 1552 01:10:07,630 --> 01:10:09,200 AUDIENCE: Look for the first letter. 1553 01:10:09,200 --> 01:10:10,180 DAVID MALAN: Look for the first letter. 1554 01:10:10,180 --> 01:10:10,679 OK. 1555 01:10:10,679 --> 01:10:12,590 But I don't know where the first letter is. 1556 01:10:12,590 --> 01:10:13,910 AUDIENCE: [INAUDIBLE]. 1557 01:10:13,910 --> 01:10:15,410 DAVID MALAN: 2/3 of the way through. 1558 01:10:15,410 --> 01:10:15,910 All right. 1559 01:10:15,910 --> 01:10:16,540 So here we are. 1560 01:10:16,540 --> 01:10:17,920 I didn't go quite far enough. 1561 01:10:17,920 --> 01:10:19,470 I'm in the M section. 1562 01:10:19,470 --> 01:10:23,990 So what do I do? 1563 01:10:23,990 --> 01:10:24,822 What comes next? 1564 01:10:24,822 --> 01:10:26,280 I start turning one page at a time? 1565 01:10:26,280 --> 01:10:27,312 AUDIENCE: [INAUDIBLE]. 1566 01:10:27,312 --> 01:10:28,770 DAVID MALAN: Yeah, a second letter. 1567 01:10:28,770 --> 01:10:34,255 But I'm in the M section, so I'm still looking for Smith, S. 1568 01:10:34,255 --> 01:10:35,380 AUDIENCE: Flop over, like-- 1569 01:10:35,380 --> 01:10:37,690 DAVID MALAN: Yeah, flop over like this much. 1570 01:10:37,690 --> 01:10:39,130 So it's kind of the same problem. 1571 01:10:39,130 --> 01:10:40,160 A moment ago I was here. 1572 01:10:40,160 --> 01:10:43,710 I went roughly 2/3 or halfway, and I ended up here. 1573 01:10:43,710 --> 01:10:46,119 But now I know, by process of elimination, 1574 01:10:46,119 --> 01:10:48,910 Mike has got to be in this half of the phone book, if he's in here, 1575 01:10:48,910 --> 01:10:51,320 because he's an S, and this is the M page. 1576 01:10:51,320 --> 01:11:00,720 So both literally and figuratively, we can tear this problem in half once. 1577 01:11:00,720 --> 01:11:01,400 So close. 1578 01:11:01,400 --> 01:11:02,520 Almost recycle. 1579 01:11:02,520 --> 01:11:04,840 So now we have fundamentally the same problem, 1580 01:11:04,840 --> 01:11:08,657 but instead of it being 1,000 pages, now it's only 500 pages. 1581 01:11:08,657 --> 01:11:09,740 But it's the same problem. 1582 01:11:09,740 --> 01:11:10,781 How do I find Mike Smith? 1583 01:11:10,781 --> 01:11:13,119 I don't want to devolve back to the original algorithm. 1584 01:11:13,119 --> 01:11:15,410 I, again, want to go, let's say, roughly to the middle. 1585 01:11:15,410 --> 01:11:16,340 Keep it simple. 1586 01:11:16,340 --> 01:11:16,840 And now, oh. 1587 01:11:16,840 --> 01:11:17,900 I went a little too far. 1588 01:11:17,900 --> 01:11:19,550 Now I'm in the T section. 1589 01:11:19,550 --> 01:11:22,050 But again, I can tear the problem in half, 1590 01:11:22,050 --> 01:11:27,780 going to a problem that's now 250 pages, throw that half of the problem away. 1591 01:11:27,780 --> 01:11:29,080 Problem is still the same. 1592 01:11:29,080 --> 01:11:31,327 And what's sort of amazing about this approach 1593 01:11:31,327 --> 01:11:32,910 is that the algorithm is not changing. 1594 01:11:32,910 --> 01:11:34,310 The input is changing. 1595 01:11:34,310 --> 01:11:37,000 The input's getting halved and halved and halved and halved. 1596 01:11:37,000 --> 01:11:39,666 So the problem is getting smaller and smaller until, eventually, 1597 01:11:39,666 --> 01:11:42,500 if I repeat this process, I'm left, theoretically, 1598 01:11:42,500 --> 01:11:45,800 with just one page on which Mike either is or isn't. 1599 01:11:45,800 --> 01:11:50,110 And I can decide whether to call him or give up, if he's not actually there. 1600 01:11:50,110 --> 01:11:54,830 So if this did, indeed, have 1,000 pages, that first algorithm, 1601 01:11:54,830 --> 01:12:00,330 one page at a time, how many steps might it have taken me to find Mike Smith? 1602 01:12:00,330 --> 01:12:01,652 Or anyone, for that matter? 1603 01:12:01,652 --> 01:12:02,610 What's the upper bound? 1604 01:12:02,610 --> 01:12:05,070 In the worst case, how many times can I turn the page 1605 01:12:05,070 --> 01:12:07,780 to look for someone who may or may not be there? 1606 01:12:07,780 --> 01:12:08,385 1,000, right? 1607 01:12:08,385 --> 01:12:09,260 Maybe it's not Smith. 1608 01:12:09,260 --> 01:12:12,330 It's someone with the last name of Z. And so I only really 1609 01:12:12,330 --> 01:12:13,870 know if I go all the way to the end. 1610 01:12:13,870 --> 01:12:15,060 It might be 1,000 pages. 1611 01:12:15,060 --> 01:12:16,530 So that's something. 1612 01:12:16,530 --> 01:12:19,713 How about, though, the second algorithm, two pages at a time? 1613 01:12:19,713 --> 01:12:20,296 AUDIENCE: 500. 1614 01:12:20,296 --> 01:12:21,046 DAVID MALAN: Yeah. 1615 01:12:21,046 --> 01:12:25,020 It's like 500, 501 just in case I have to double back one page to see 1616 01:12:25,020 --> 01:12:26,780 if someone was in between two pages. 1617 01:12:26,780 --> 01:12:27,410 So that's good. 1618 01:12:27,410 --> 01:12:28,750 That's half as big. 1619 01:12:28,750 --> 01:12:30,960 But what about if the phone book is 1,000 pages, 1620 01:12:30,960 --> 01:12:34,459 and I use that third approach where I use Grace's intuition of sort 1621 01:12:34,459 --> 01:12:36,500 of splitting it and splitting it or, if you will, 1622 01:12:36,500 --> 01:12:39,470 dividing and conquering the problem again and again? 1623 01:12:39,470 --> 01:12:40,760 How many steps does that take? 1624 01:12:40,760 --> 01:12:41,334 AUDIENCE: 16. 1625 01:12:41,334 --> 01:12:42,000 DAVID MALAN: 16? 1626 01:12:42,000 --> 01:12:45,410 Even fewer if it's 1,000, but that order of magnitude-- 1627 01:12:45,410 --> 01:12:47,350 a little more-- 10 or so. 1628 01:12:47,350 --> 01:12:51,671 You can go from 1,000 to 500 to 250 to 125 to 67-ish. 1629 01:12:51,671 --> 01:12:53,920 We have to deal with the rounding errors a little bit. 1630 01:12:53,920 --> 01:12:58,190 But we get to one page much, much faster. 1631 01:12:58,190 --> 01:13:04,010 So if we were to plot this-- and we can reuse this space here. 1632 01:13:04,010 --> 01:13:07,030 If we were to plot the relationship among all of these numbers, 1633 01:13:07,030 --> 01:13:08,310 let's consider where we're at. 1634 01:13:08,310 --> 01:13:10,170 So we don't have to worry too much about numbers. 1635 01:13:10,170 --> 01:13:11,520 Let's just worry about shapes. 1636 01:13:11,520 --> 01:13:14,880 If this is an xy plot, and this is the size of my problem 1637 01:13:14,880 --> 01:13:16,880 that a computer scientist would usually describe 1638 01:13:16,880 --> 01:13:20,540 as n-- n is the number of pages, the size of the input, whatever 1639 01:13:20,540 --> 01:13:24,490 your unit of measure is-- and then this axis is time-- number of seconds, 1640 01:13:24,490 --> 01:13:26,740 number of page turns, however you want to count things 1641 01:13:26,740 --> 01:13:31,450 up-- the first algorithm has a very linear relationship 1642 01:13:31,450 --> 01:13:33,820 whereby, if there's more pages in the phone book, 1643 01:13:33,820 --> 01:13:35,330 it's going to take me more seconds. 1644 01:13:35,330 --> 01:13:37,704 Or put another way, if Verizon, or whoever the phone book 1645 01:13:37,704 --> 01:13:43,290 person is, doubles the number of pages-- instead of it being 1,000 pages here 1646 01:13:43,290 --> 01:13:45,934 and ending up here, if we have 2,000 pages, 1647 01:13:45,934 --> 01:13:47,600 it's going to double the amount of time. 1648 01:13:47,600 --> 01:13:50,600 This isn't quite to scale, but this would have intersected twice as high 1649 01:13:50,600 --> 01:13:51,800 on the chart. 1650 01:13:51,800 --> 01:13:56,010 Meanwhile, the second algorithm, where I go two pages at a time, 1651 01:13:56,010 --> 01:14:01,770 still has a linear relationship, but it's faster, so it's a little lower. 1652 01:14:01,770 --> 01:14:07,470 In other words, I'm going to call this on the order of n. 1653 01:14:07,470 --> 01:14:10,870 This is a computer science notation for on the order of 1654 01:14:10,870 --> 01:14:12,700 or the size of the problem. 1655 01:14:12,700 --> 01:14:16,121 Whereas this one, I'm going to call order of n over 2. 1656 01:14:16,121 --> 01:14:17,370 And I'm cheating a little bit. 1657 01:14:17,370 --> 01:14:20,380 We normally wouldn't say over 2, even here. 1658 01:14:20,380 --> 01:14:22,100 But the shape is fundamentally the same. 1659 01:14:22,100 --> 01:14:23,310 It's still a straight line. 1660 01:14:23,310 --> 01:14:28,647 But if there's 1,000 pages, my first algorithm might take 1,000 seconds. 1661 01:14:28,647 --> 01:14:31,230 But my second algorithm is only going to take 500-- and again, 1662 01:14:31,230 --> 01:14:32,040 not quite to scale. 1663 01:14:32,040 --> 01:14:34,280 Otherwise, this would be split perfectly. 1664 01:14:34,280 --> 01:14:38,260 But that third algorithm is kind of an interesting beast 1665 01:14:38,260 --> 01:14:42,840 because the bigger the problem gets, the more pages in the phone book, 1666 01:14:42,840 --> 01:14:45,500 the bigger my bytes automatically gets. 1667 01:14:45,500 --> 01:14:49,330 The first two algorithms, I'm always taking a one-page byte or two-page byte 1668 01:14:49,330 --> 01:14:50,090 out of it. 1669 01:14:50,090 --> 01:14:52,410 But the third algorithm is kind of impressive. 1670 01:14:52,410 --> 01:14:57,370 It takes 500-page bytes, then a little smaller, but still 250-page bytes, 1671 01:14:57,370 --> 01:15:02,450 then 125-page bytes, which is certainly bigger than 1 and 2. 1672 01:15:02,450 --> 01:15:05,240 So what might the shape of that graph look like? 1673 01:15:05,240 --> 01:15:08,410 A straight line, but much lower? 1674 01:15:08,410 --> 01:15:09,556 It's more of a curve. 1675 01:15:09,556 --> 01:15:12,840 And if you remember your logarithms, it's 1676 01:15:12,840 --> 01:15:14,570 something that looks a little like this. 1677 01:15:14,570 --> 01:15:15,960 It never gets perfectly flat. 1678 01:15:15,960 --> 01:15:21,250 It's always increasing, but it increases ever so slowly over time. 1679 01:15:21,250 --> 01:15:24,400 And you can appreciate this in the following way. 1680 01:15:24,400 --> 01:15:27,260 So 1, we already know that if you have 1,000 pages, 1681 01:15:27,260 --> 01:15:29,580 this third algorithm was the fastest so far. 1682 01:15:29,580 --> 01:15:32,680 But this algorithm is way more powerful and impressive when 1683 01:15:32,680 --> 01:15:35,020 you think about even bigger inputs. 1684 01:15:35,020 --> 01:15:38,390 Suppose that Verizon had a 4 billion page phone book-- 1685 01:15:38,390 --> 01:15:41,900 promised we'll stick with these same numbers-- so 4 billion page phone book. 1686 01:15:41,900 --> 01:15:44,110 With that first algorithm, one page at a time, 1687 01:15:44,110 --> 01:15:46,660 how many pages might I turn before concluding that someone 1688 01:15:46,660 --> 01:15:48,910 is in or not in the phone book? 1689 01:15:48,910 --> 01:15:49,620 4 billion, right? 1690 01:15:49,620 --> 01:15:51,300 That person might be at the very end, and I 1691 01:15:51,300 --> 01:15:53,010 might have to turn all 4 billion pages. 1692 01:15:53,010 --> 01:15:56,485 Second algorithm, 2 billion because I'm going two pages at a time, 1693 01:15:56,485 --> 01:15:58,860 plus 1, so 2 billion and 1 in case I have to double back. 1694 01:15:58,860 --> 01:15:59,900 That's faster. 1695 01:15:59,900 --> 01:16:02,160 That's twice as fast. 1696 01:16:02,160 --> 01:16:04,520 But how many times can you divide a 4 billion 1697 01:16:04,520 --> 01:16:08,440 page phone book in half, in half, in half, 1698 01:16:08,440 --> 01:16:11,190 until you're left with just one page? 1699 01:16:11,190 --> 01:16:13,490 Only 32. 1700 01:16:13,490 --> 01:16:15,050 And that's kind of amazing. 1701 01:16:15,050 --> 01:16:17,910 You start with a 4 billion page problem. 1702 01:16:17,910 --> 01:16:21,110 And those first two algorithms take 4 billion or 2 billion steps, 1703 01:16:21,110 --> 01:16:22,680 give or take, worst case. 1704 01:16:22,680 --> 01:16:27,230 By contrast, this fairly intuitive thing that we've been doing for 20 30, 40, 1705 01:16:27,230 --> 01:16:30,960 50 years is so much more powerful out of the box 1706 01:16:30,960 --> 01:16:33,930 because it only can be divided in half 32 times 1707 01:16:33,930 --> 01:16:36,930 before you actually get to the page in question. 1708 01:16:36,930 --> 01:16:38,990 And that's why this line is so low. 1709 01:16:38,990 --> 01:16:41,420 Even as the problem gets massive, it's still not 1710 01:16:41,420 --> 01:16:43,330 going to take you all that many steps. 1711 01:16:43,330 --> 01:16:46,460 Conversely, if Verizon doubles the number of pages 1712 01:16:46,460 --> 01:16:50,000 next year, from 1,000 to 2,000, each of those first two algorithms 1713 01:16:50,000 --> 01:16:55,140 takes twice as long, either 2,000 steps or a full 1,000 steps 1714 01:16:55,140 --> 01:16:56,610 for a 2,000 page problem. 1715 01:16:56,610 --> 01:16:59,670 By contrast, if Verizon doubles the size of the phone book 1716 01:16:59,670 --> 01:17:02,480 from 1,000 to 2,000 pages, and previously it 1717 01:17:02,480 --> 01:17:06,280 took 10 steps to find Mike Smith, how many steps 1718 01:17:06,280 --> 01:17:09,920 does it take if Verizon doubles the phone from 1,000 to 2,000 steps 1719 01:17:09,920 --> 01:17:11,533 if we use the third algorithm? 1720 01:17:11,533 --> 01:17:12,364 AUDIENCE: 11. 1721 01:17:12,364 --> 01:17:13,030 DAVID MALAN: 11. 1722 01:17:13,030 --> 01:17:14,540 And that's what's really powerful. 1723 01:17:14,540 --> 01:17:17,350 And so, indeed, one of the exciting takeaways of computer science 1724 01:17:17,350 --> 01:17:19,710 is that, even though it, by the nature of the hardware 1725 01:17:19,710 --> 01:17:21,740 devices with which we're surrounded, might 1726 01:17:21,740 --> 01:17:25,900 seem very unfamiliar, if not a little intimidating, the ideas that engineers 1727 01:17:25,900 --> 01:17:28,480 and, specifically, programmers bring to bear on problems 1728 01:17:28,480 --> 01:17:32,010 are often not that dissimilar to intuition we've long had. 1729 01:17:32,010 --> 01:17:35,320 It's just a matter of applying that same intuition 1730 01:17:35,320 --> 01:17:36,730 to bigger and bigger problems. 1731 01:17:36,730 --> 01:17:40,230 We don't really have 4 billion page phone book problems, necessarily. 1732 01:17:40,230 --> 01:17:44,640 But Google certainly has a 4 billion page web page search problem-- 1733 01:17:44,640 --> 01:17:47,700 or trillions of pages these days, or financial transactions 1734 01:17:47,700 --> 01:17:50,527 in other companies, or logs in some data analytics companies. 1735 01:17:50,527 --> 01:17:52,610 And so there are so many applications of big data, 1736 01:17:52,610 --> 01:17:55,270 so to speak, whereby getting the right algorithm, 1737 01:17:55,270 --> 01:17:58,650 the right middle ingredient here, really, really, 1738 01:17:58,650 --> 01:18:00,570 really has an impact on the performance. 1739 01:18:00,570 --> 01:18:02,649 And in fact, your question of hardware, too, 1740 01:18:02,649 --> 01:18:04,440 is sort of a different view of the problem. 1741 01:18:04,440 --> 01:18:07,440 Rather than focus on the algorithms, they were focusing on the hardware. 1742 01:18:07,440 --> 01:18:11,730 And simply having more RAM, presumably, with which to query the data 1743 01:18:11,730 --> 01:18:15,710 means things can operate faster because of that trade off between cost 1744 01:18:15,710 --> 01:18:18,480 and speed and size of memory. 1745 01:18:18,480 --> 01:18:23,540 So these ideas are recurring and they really aren't that dissimilar. 1746 01:18:23,540 --> 01:18:25,660 So there is one catch here. 1747 01:18:25,660 --> 01:18:29,910 Unfortunately, computers only really understand what you tell them. 1748 01:18:29,910 --> 01:18:31,532 They're fairly dumb devices. 1749 01:18:31,532 --> 01:18:33,490 They only know what we've trained them to know. 1750 01:18:33,490 --> 01:18:36,610 They can't just infer or fill in the blanks. 1751 01:18:36,610 --> 01:18:39,220 They can only do literally what they've been told. 1752 01:18:39,220 --> 01:18:42,950 And so a useful way of seeing that is the following. 1753 01:18:42,950 --> 01:18:47,250 Might someone be comfy volunteering and coming up front here? 1754 01:18:47,250 --> 01:18:51,310 You have to be comfortable appearing on video and, in turn, on the internet. 1755 01:18:51,310 --> 01:18:54,130 But no dumb questions here. 1756 01:18:54,130 --> 01:18:55,170 We're all friends. 1757 01:18:55,170 --> 01:18:58,130 Just need someone to come look at what's on my screen 1758 01:18:58,130 --> 01:19:01,960 without anyone else seeing or looking behind you. 1759 01:19:01,960 --> 01:19:03,510 I forgot about that one. 1760 01:19:03,510 --> 01:19:04,810 No one look behind. 1761 01:19:04,810 --> 01:19:09,660 I need one volunteer who didn't look behind already. 1762 01:19:09,660 --> 01:19:11,811 One volunteer. 1763 01:19:11,811 --> 01:19:15,060 One volunteer. 1764 01:19:15,060 --> 01:19:16,750 There's room full of 25 people. 1765 01:19:16,750 --> 01:19:19,100 No one is volunteering. 1766 01:19:19,100 --> 01:19:20,970 Who wants extra lunch? 1767 01:19:20,970 --> 01:19:22,510 OK, Grace, come on up. 1768 01:19:22,510 --> 01:19:23,050 Thank you. 1769 01:19:23,050 --> 01:19:23,360 All right. 1770 01:19:23,360 --> 01:19:24,776 So Grace is going to come on down. 1771 01:19:24,776 --> 01:19:26,485 And honor system-- no one look at that TV 1772 01:19:26,485 --> 01:19:29,484 because I'm not sure how to turn it off without physically unplugging it 1773 01:19:29,484 --> 01:19:30,420 at the moment. 1774 01:19:30,420 --> 01:19:31,944 And let me go ahead and do this. 1775 01:19:31,944 --> 01:19:33,860 We're going to give everyone else in the room, 1776 01:19:33,860 --> 01:19:37,400 if you don't mind helping out for just a moment-- can you just pass those around 1777 01:19:37,400 --> 01:19:37,950 on the left. 1778 01:19:37,950 --> 01:19:39,680 And I'll pass this around on the right. 1779 01:19:39,680 --> 01:19:41,263 Everyone just take one sheet of paper. 1780 01:19:41,263 --> 01:20:01,980 1781 01:20:01,980 --> 01:20:04,300 All right. 1782 01:20:04,300 --> 01:20:04,800 OK. 1783 01:20:04,800 --> 01:20:05,940 There we go. 1784 01:20:05,940 --> 01:20:08,970 So Grace, if you'd like to come over here-- Grace, 1785 01:20:08,970 --> 01:20:12,030 now, is going to be, we'll say, the programmer. 1786 01:20:12,030 --> 01:20:14,910 And everyone else in the room should be the computer, 1787 01:20:14,910 --> 01:20:17,410 playing the role of computer, so much so that you're only 1788 01:20:17,410 --> 01:20:19,880 allowed to do what you're told to do. 1789 01:20:19,880 --> 01:20:21,080 You can't make assumptions. 1790 01:20:21,080 --> 01:20:24,230 And so any abstractions that you might have 1791 01:20:24,230 --> 01:20:26,652 come in the room with this morning can't necessarily 1792 01:20:26,652 --> 01:20:29,610 be leveraged because you can't ask any questions or for clarifications. 1793 01:20:29,610 --> 01:20:34,220 But we're going to see just how well Grace can communicate or can program 1794 01:20:34,220 --> 01:20:36,947 the room-- such that she's going to give you some instructions, 1795 01:20:36,947 --> 01:20:39,780 you're going to do what she says with the respect your pencil or pen 1796 01:20:39,780 --> 01:20:42,870 and the piece of paper, and we'll see if you can draw exactly what Grace 1797 01:20:42,870 --> 01:20:45,800 sees before herself here. 1798 01:20:45,800 --> 01:20:48,090 So if you could tell people how to draw this picture. 1799 01:20:48,090 --> 01:20:51,490 And let me hide it in this folder. 1800 01:20:51,490 --> 01:20:52,550 OK. 1801 01:20:52,550 --> 01:20:53,140 All right. 1802 01:20:53,140 --> 01:20:55,640 Execute. 1803 01:20:55,640 --> 01:21:04,450 GRACE: You're going to draw four shapes on a horizontal line. 1804 01:21:04,450 --> 01:21:10,310 Don't draw a line-- horizontally in the middle third of your page, which 1805 01:21:10,310 --> 01:21:13,400 should be landscape. 1806 01:21:13,400 --> 01:21:22,480 The farthest left shape is a square that is about 1/3 the height of the page. 1807 01:21:22,480 --> 01:21:25,700 And it's in the middle between the top and the bottom. 1808 01:21:25,700 --> 01:21:31,810 Directly to the right of that, in the second quarter of the page, 1809 01:21:31,810 --> 01:21:35,060 from left to right, is a circle. 1810 01:21:35,060 --> 01:21:42,130 Then there is a diagonal line in the third quarter 1811 01:21:42,130 --> 01:21:46,220 of the page that is from approximately the bottom of the circle 1812 01:21:46,220 --> 01:21:50,240 to the top of the circle, same height as the square and the circle, 1813 01:21:50,240 --> 01:21:53,720 and then a triangle that is also approximately the same height as those 1814 01:21:53,720 --> 01:21:57,302 shapes in the final, right-hand quarter of the page. 1815 01:21:57,302 --> 01:21:58,260 DAVID MALAN: All right. 1816 01:21:58,260 --> 01:21:59,020 End scene. 1817 01:21:59,020 --> 01:21:59,625 Thank you. 1818 01:21:59,625 --> 01:22:00,125 GRACE: OK. 1819 01:22:00,125 --> 01:22:01,920 DAVID MALAN: And now let me come around. 1820 01:22:01,920 --> 01:22:03,460 And you're welcome to return. 1821 01:22:03,460 --> 01:22:09,170 I'll come around to everyone else just so we can project some answers here. 1822 01:22:09,170 --> 01:22:12,420 And so one of the takeaways here, to set the stage for what we'll do tomorrow, 1823 01:22:12,420 --> 01:22:15,370 especially when we translate computational thinking to programming, 1824 01:22:15,370 --> 01:22:18,760 is just how much in the way of detail we humans take for granted, 1825 01:22:18,760 --> 01:22:20,940 and how a programmer, an engineer, really 1826 01:22:20,940 --> 01:22:23,269 has to think through details at the lowest level 1827 01:22:23,269 --> 01:22:26,310 so that what appears on the screen ultimately, or what the software does, 1828 01:22:26,310 --> 01:22:31,030 is actually what's intended but is expressed in as clear as possible way. 1829 01:22:31,030 --> 01:22:35,200 If I can steal some of these sheets-- I don't need to grab all. 1830 01:22:35,200 --> 01:22:38,490 Let me just grab a few from each side, over here. 1831 01:22:38,490 --> 01:22:39,950 Thank you. 1832 01:22:39,950 --> 01:22:41,680 Over here. 1833 01:22:41,680 --> 01:22:43,070 OK. 1834 01:22:43,070 --> 01:22:43,690 Very good. 1835 01:22:43,690 --> 01:22:44,460 Thank you. 1836 01:22:44,460 --> 01:22:44,970 Thank you. 1837 01:22:44,970 --> 01:22:45,470 Sure. 1838 01:22:45,470 --> 01:22:46,920 Thank you. 1839 01:22:46,920 --> 01:22:48,030 OK. 1840 01:22:48,030 --> 01:22:48,820 Sorry. 1841 01:22:48,820 --> 01:22:49,750 There you go. 1842 01:22:49,750 --> 01:22:50,250 OK. 1843 01:22:50,250 --> 01:22:51,420 That's OK. 1844 01:22:51,420 --> 01:22:55,018 Let me grab a couple from the other side. 1845 01:22:55,018 --> 01:22:56,120 All right. 1846 01:22:56,120 --> 01:22:56,620 OK. 1847 01:22:56,620 --> 01:22:57,610 May I reach here? 1848 01:22:57,610 --> 01:22:58,500 Thank you. 1849 01:22:58,500 --> 01:22:59,770 All right. 1850 01:22:59,770 --> 01:23:00,390 Wonderful. 1851 01:23:00,390 --> 01:23:05,990 So we have a nice variety of interpretations here, if you will. 1852 01:23:05,990 --> 01:23:09,150 And let's take a look at what some of them came out to be. 1853 01:23:09,150 --> 01:23:12,430 So here we have this one here. 1854 01:23:12,430 --> 01:23:13,060 All right. 1855 01:23:13,060 --> 01:23:15,840 Quite a few of you had something that looked like that. 1856 01:23:15,840 --> 01:23:19,840 Indeed, here's another such drawing. 1857 01:23:19,840 --> 01:23:24,380 And notice, actually, they differ only in so far as 1858 01:23:24,380 --> 01:23:27,360 which way the line goes, if you can see. 1859 01:23:27,360 --> 01:23:29,890 Then we had some other interpretations here. 1860 01:23:29,890 --> 01:23:31,456 This one had it touching. 1861 01:23:31,456 --> 01:23:34,370 1862 01:23:34,370 --> 01:23:37,610 So that's a little different, but a similar angle. 1863 01:23:37,610 --> 01:23:41,780 This one I like to see, so definitely a little different. 1864 01:23:41,780 --> 01:23:45,060 The line is going the right way, but it's inside. 1865 01:23:45,060 --> 01:23:50,010 This one was sort of an undo, perhaps, over there. 1866 01:23:50,010 --> 01:23:53,490 This one is cute in some way, over here. 1867 01:23:53,490 --> 01:23:55,460 And then this one, too, was a little different. 1868 01:23:55,460 --> 01:23:57,804 So reasonable people will certainly disagree. 1869 01:23:57,804 --> 01:23:59,470 It is perhaps one of the takeaways here. 1870 01:23:59,470 --> 01:24:04,860 What Grace was actually drawing was this. 1871 01:24:04,860 --> 01:24:08,250 So it looks like the majority, just over majority, did indeed get this right. 1872 01:24:08,250 --> 01:24:10,790 But you can notice the sort of ambiguity sometimes. 1873 01:24:10,790 --> 01:24:14,020 And she did take some liberties, certainly, 1874 01:24:14,020 --> 01:24:17,409 like assuming that we all know what a square is, which is fine. 1875 01:24:17,409 --> 01:24:18,450 But think about a square. 1876 01:24:18,450 --> 01:24:19,540 What is a square? 1877 01:24:19,540 --> 01:24:23,660 That's kind of an abstraction for a lower-level implementation of what 1878 01:24:23,660 --> 01:24:26,790 really is just four lines-- four lines that are all connected 1879 01:24:26,790 --> 01:24:28,660 and form right angles with each other. 1880 01:24:28,660 --> 01:24:34,390 But no one would say, draw four lines, each at a right angle and equidistant. 1881 01:24:34,390 --> 01:24:36,000 We just say, draw a square. 1882 01:24:36,000 --> 01:24:38,520 And so that is an example of an abstraction that's 1883 01:24:38,520 --> 01:24:41,360 useful because, otherwise, you get lost in the weeds, so to speak, 1884 01:24:41,360 --> 01:24:42,570 when trying to communicate. 1885 01:24:42,570 --> 01:24:45,920 But it does leave possible some ambiguities, as we saw. 1886 01:24:45,920 --> 01:24:47,990 The line going from bottom left to top right 1887 01:24:47,990 --> 01:24:49,800 was misinterpreted in a couple of places. 1888 01:24:49,800 --> 01:24:52,400 The triangle could, perhaps, have been rotated. 1889 01:24:52,400 --> 01:24:54,527 I'm not sure if you specified if the flat edge was 1890 01:24:54,527 --> 01:24:57,110 on the bottom, though most people just seem to assume as much. 1891 01:24:57,110 --> 01:24:59,200 But that was not terribly precise. 1892 01:24:59,200 --> 01:25:02,580 And indeed, it's no coincidence, perhaps, 1893 01:25:02,580 --> 01:25:05,330 that some of the earliest programming environments-- if any of you 1894 01:25:05,330 --> 01:25:08,980 have heard of Logo, for instance-- were sort of graphical in nature. 1895 01:25:08,980 --> 01:25:11,810 You might write textual commands, but all you could do 1896 01:25:11,810 --> 01:25:15,530 is tell a turtle in one version of the software's case, 1897 01:25:15,530 --> 01:25:19,720 to go up, down, left, or right and it could put down 1898 01:25:19,720 --> 01:25:22,020 a marker or a paintbrush, essentially. 1899 01:25:22,020 --> 01:25:24,770 And if you turned on the paintbrush, it could actually draw a line 1900 01:25:24,770 --> 01:25:26,520 as it moved around the screen. 1901 01:25:26,520 --> 01:25:29,270 And so in this way, you could imagine that Grace could have really 1902 01:25:29,270 --> 01:25:30,960 kind of belabored the point here. 1903 01:25:30,960 --> 01:25:35,080 And she could have said something like, OK, put the paper in landscape mode. 1904 01:25:35,080 --> 01:25:36,460 Lift up your pen. 1905 01:25:36,460 --> 01:25:39,540 Hold it over the left third of the page. 1906 01:25:39,540 --> 01:25:41,040 Touch pen to paper. 1907 01:25:41,040 --> 01:25:42,470 Move it down 2 inches. 1908 01:25:42,470 --> 01:25:43,620 Move it right 2 inches. 1909 01:25:43,620 --> 01:25:44,750 Move it up 2 inches. 1910 01:25:44,750 --> 01:25:45,890 Move it left 2 inches. 1911 01:25:45,890 --> 01:25:48,050 And with, maybe, higher probability, we would 1912 01:25:48,050 --> 01:25:51,430 have all been able to draw it perfectly the same. 1913 01:25:51,430 --> 01:25:53,670 But we would lack, then, the sort of mental model 1914 01:25:53,670 --> 01:25:54,870 for what it is we're doing. 1915 01:25:54,870 --> 01:25:58,512 And so these abstractions both help, as in the case of draw a square, 1916 01:25:58,512 --> 01:26:00,220 but might potentially hurt if you're just 1917 01:26:00,220 --> 01:26:03,705 trying to communicate to a higher, sort of, form device. 1918 01:26:03,705 --> 01:26:06,830 And so if you think about maybe some of our more modern technology, iPhones 1919 01:26:06,830 --> 01:26:08,970 and Androids and things like Siri and Cortana 1920 01:26:08,970 --> 01:26:13,210 and the like-- those are trying to be more human-like, so that you could say, 1921 01:26:13,210 --> 01:26:15,090 hey, Siri, draw me a square. 1922 01:26:15,090 --> 01:26:17,400 Whereas back in the day, or even in this room, 1923 01:26:17,400 --> 01:26:20,380 we might need to be ever more precise as to what that actually means. 1924 01:26:20,380 --> 01:26:23,720 Let's try just one other example, flipping the tables this time 1925 01:26:23,720 --> 01:26:32,539 if we could, whereby we need one more brave volunteer to join me up here. 1926 01:26:32,539 --> 01:26:36,720 1927 01:26:36,720 --> 01:26:39,220 Everyone's really busy checking their mail now or something. 1928 01:26:39,220 --> 01:26:39,720 OK. 1929 01:26:39,720 --> 01:26:40,680 Come on down. 1930 01:26:40,680 --> 01:26:41,990 And we have Griff. 1931 01:26:41,990 --> 01:26:43,901 Come on down. 1932 01:26:43,901 --> 01:26:44,400 All right. 1933 01:26:44,400 --> 01:26:48,920 So Griff, the only rule here is you take the pen this time, 1934 01:26:48,920 --> 01:26:52,010 face only this direction without looking at any of the three screens 1935 01:26:52,010 --> 01:26:53,560 that are about to spoil what this is. 1936 01:26:53,560 --> 01:26:56,184 And everyone else here is going to play the role of programmer. 1937 01:26:56,184 --> 01:26:59,151 And we'll sort of round robin, take one instruction from each person, 1938 01:26:59,151 --> 01:27:01,900 see if we can't learn a little something from the previous example 1939 01:27:01,900 --> 01:27:08,930 as to precision, while still making it possible for Griff to get this right. 1940 01:27:08,930 --> 01:27:09,950 All right. 1941 01:27:09,950 --> 01:27:12,521 So don't look anywhere other than straight ahead. 1942 01:27:12,521 --> 01:27:13,020 GRIFF: OK. 1943 01:27:13,020 --> 01:27:13,978 DAVID MALAN: All right. 1944 01:27:13,978 --> 01:27:18,110 And we're going to give you this one here. 1945 01:27:18,110 --> 01:27:18,640 All right. 1946 01:27:18,640 --> 01:27:21,760 Would someone in the audience-- not Griff, 1947 01:27:21,760 --> 01:27:29,410 who should only be looking straight ahead-- like to propose how to begin? 1948 01:27:29,410 --> 01:27:29,910 Yes? 1949 01:27:29,910 --> 01:27:30,410 Owen? 1950 01:27:30,410 --> 01:27:34,430 OWEN: Draw a circle near the top of the board. 1951 01:27:34,430 --> 01:27:37,044 1952 01:27:37,044 --> 01:27:37,710 DAVID MALAN: OK. 1953 01:27:37,710 --> 01:27:38,390 Someone else? 1954 01:27:38,390 --> 01:27:38,900 Yes? 1955 01:27:38,900 --> 01:27:42,300 AUDIENCE: Draw a straight line from the bottom tip of the circle 1956 01:27:42,300 --> 01:27:45,694 to almost the middle of the board. 1957 01:27:45,694 --> 01:27:48,110 DAVID MALAN: Straight line to almost the middle the board. 1958 01:27:48,110 --> 01:27:48,330 Good. 1959 01:27:48,330 --> 01:27:49,621 AUDIENCE: I think that's right. 1960 01:27:49,621 --> 01:27:53,340 DAVID MALAN: Oh, a little longer, little longer. 1961 01:27:53,340 --> 01:27:54,590 AUDIENCE: To 3/4 of the board. 1962 01:27:54,590 --> 01:27:55,310 DAVID MALAN: 3/4 of the board. 1963 01:27:55,310 --> 01:27:56,060 There we go. 1964 01:27:56,060 --> 01:27:58,280 OK. 1965 01:27:58,280 --> 01:27:58,900 Someone else? 1966 01:27:58,900 --> 01:28:01,522 1967 01:28:01,522 --> 01:28:03,520 Someone else? 1968 01:28:03,520 --> 01:28:04,430 Yeah, Dan? 1969 01:28:04,430 --> 01:28:10,876 DAN: From the end of that line, draw down, angled slightly to the left, 1970 01:28:10,876 --> 01:28:14,040 like, let's say, a 15 degree angle-- 1971 01:28:14,040 --> 01:28:16,278 AUDIENCE: 7 o'clock. 1972 01:28:16,278 --> 01:28:19,840 DAN: Yeah, thank you, toward 7 o'clock. 1973 01:28:19,840 --> 01:28:20,780 DAVID MALAN: OK. 1974 01:28:20,780 --> 01:28:22,740 7 o'clock. 1975 01:28:22,740 --> 01:28:25,940 Someone else? 1976 01:28:25,940 --> 01:28:29,751 AUDIENCE: Put an identical line to the top of your original line 1977 01:28:29,751 --> 01:28:34,520 that you drew-- yep, an identical line also at that angle. 1978 01:28:34,520 --> 01:28:35,270 DAVID MALAN: Nice. 1979 01:28:35,270 --> 01:28:37,760 A little copy, paste there. 1980 01:28:37,760 --> 01:28:38,260 What's next? 1981 01:28:38,260 --> 01:28:41,604 1982 01:28:41,604 --> 01:28:44,060 AUDIENCE: Draw another line from where you just 1983 01:28:44,060 --> 01:28:48,650 ended back to close to the end of [INAUDIBLE] straight line 1984 01:28:48,650 --> 01:28:49,763 that's coming down. 1985 01:28:49,763 --> 01:28:52,150 AUDIENCE: Yeah. 1986 01:28:52,150 --> 01:28:55,580 DAVID MALAN: Seems the computer is able to ask some questions here, but OK. 1987 01:28:55,580 --> 01:28:56,610 All right. 1988 01:28:56,610 --> 01:28:57,464 Almost there. 1989 01:28:57,464 --> 01:29:00,370 1990 01:29:00,370 --> 01:29:01,590 What's last? 1991 01:29:01,590 --> 01:29:02,645 Or next to last? 1992 01:29:02,645 --> 01:29:08,330 1993 01:29:08,330 --> 01:29:09,445 Anyone? 1994 01:29:09,445 --> 01:29:11,185 Yeah, Dan again? 1995 01:29:11,185 --> 01:29:18,209 DAN: From the point in the circle where the second line goes out, 1996 01:29:18,209 --> 01:29:23,380 draw that same angle, but going to the right. 1997 01:29:23,380 --> 01:29:27,040 So the first line will go to about 5 o'clock, 1998 01:29:27,040 --> 01:29:30,810 and then it'll be another angle. 1999 01:29:30,810 --> 01:29:35,470 The point, the two lines intersecting with a circle from there, 2000 01:29:35,470 --> 01:29:36,874 put your pen there. 2001 01:29:36,874 --> 01:29:43,950 And now draw a short line towards 5 o'clock. 2002 01:29:43,950 --> 01:29:45,410 A little bit longer. 2003 01:29:45,410 --> 01:29:45,910 Keep going. 2004 01:29:45,910 --> 01:29:46,890 Yeah. 2005 01:29:46,890 --> 01:29:47,870 Keep going there. 2006 01:29:47,870 --> 01:29:51,580 And now, from the end of that point, angle it 2007 01:29:51,580 --> 01:29:56,687 a little bit to the right again, towards, say, 4 o'clock. 2008 01:29:56,687 --> 01:29:57,186 Yeah. 2009 01:29:57,186 --> 01:30:00,810 2010 01:30:00,810 --> 01:30:01,890 DAVID MALAN: All right. 2011 01:30:01,890 --> 01:30:02,520 Almost there. 2012 01:30:02,520 --> 01:30:04,620 And I forgot one piece, one more step. 2013 01:30:04,620 --> 01:30:08,640 2014 01:30:08,640 --> 01:30:11,640 One step remains, pun sort of intended. 2015 01:30:11,640 --> 01:30:12,140 OK. 2016 01:30:12,140 --> 01:30:13,943 AUDIENCE: Now you do the clock. 2017 01:30:13,943 --> 01:30:16,889 Go back 2/3 of the way down the long line. 2018 01:30:16,889 --> 01:30:23,272 Draw a line to, I guess, 4:30. 2019 01:30:23,272 --> 01:30:26,218 Half the distance of that big line. 2020 01:30:26,218 --> 01:30:30,599 2021 01:30:30,599 --> 01:30:31,432 DAVID MALAN: Repeat. 2022 01:30:31,432 --> 01:30:32,559 AUDIENCE: Start there. 2023 01:30:32,559 --> 01:30:33,600 DAVID MALAN: Start there. 2024 01:30:33,600 --> 01:30:36,042 AUDIENCE: Draw a line that's as long as half 2025 01:30:36,042 --> 01:30:41,470 [INAUDIBLE] of that line toward 4:30. 2026 01:30:41,470 --> 01:30:41,970 [INAUDIBLE] 2027 01:30:41,970 --> 01:30:45,042 2028 01:30:45,042 --> 01:30:45,750 DAVID MALAN: And? 2029 01:30:45,750 --> 01:30:48,790 2030 01:30:48,790 --> 01:30:49,700 Just that? 2031 01:30:49,700 --> 01:30:57,864 AUDIENCE: Oh, and then another line from there till 5:00 the same length. 2032 01:30:57,864 --> 01:30:59,220 DAVID MALAN: All right. 2033 01:30:59,220 --> 01:31:01,220 And Griff, what do you appear to have drawn? 2034 01:31:01,220 --> 01:31:02,010 GRIFF: A person walking. 2035 01:31:02,010 --> 01:31:03,110 DAVID MALAN: A person walking. 2036 01:31:03,110 --> 01:31:05,310 All right, how about a round of applause for Griff. 2037 01:31:05,310 --> 01:31:07,110 Thank you. 2038 01:31:07,110 --> 01:31:11,207 And most of us, upon first glance, would describe this as what? 2039 01:31:11,207 --> 01:31:12,040 Draw a stick figure. 2040 01:31:12,040 --> 01:31:13,790 And what's interesting about this is that, 2041 01:31:13,790 --> 01:31:19,090 by contrast, whereas the square and the circle and the triangle on the line 2042 01:31:19,090 --> 01:31:23,490 all have, perhaps, a more obvious semantic meaning, draw a stick figure 2043 01:31:23,490 --> 01:31:26,156 is probably not nearly precise enough for anyone 2044 01:31:26,156 --> 01:31:29,030 to have recreated precisely this stick figure that I just so happened 2045 01:31:29,030 --> 01:31:30,590 to find on Google Images. 2046 01:31:30,590 --> 01:31:34,050 There's enough sort of kinks in his legs and his arms at certain angles 2047 01:31:34,050 --> 01:31:36,727 that much more precision was, indeed, necessary. 2048 01:31:36,727 --> 01:31:39,060 And what's interesting, too, is that on a few occasions, 2049 01:31:39,060 --> 01:31:42,940 we were sort of struggling to orient Griff as to where he should go. 2050 01:31:42,940 --> 01:31:45,520 And so it felt like there was this opportunity even 2051 01:31:45,520 --> 01:31:49,070 to add some metadata to the picture, whereby, maybe, every time we 2052 01:31:49,070 --> 01:31:53,910 had him put his pen down, we could say, define that point as A or B 2053 01:31:53,910 --> 01:31:56,605 or just some way of verbally back referencing it later. 2054 01:31:56,605 --> 01:31:59,480 And indeed, we'll see a little bit of this tomorrow with programming. 2055 01:31:59,480 --> 01:32:03,390 It's actually quite useful to declare things like variables, placeholders, 2056 01:32:03,390 --> 01:32:07,460 so that you can reset yourself to some known past position. 2057 01:32:07,460 --> 01:32:10,870 And we were using far more words to sort of reorient Griff, when, had we 2058 01:32:10,870 --> 01:32:14,300 simply put some bread crumbs, defined some variables, so to speak, 2059 01:32:14,300 --> 01:32:17,610 we could have jumped right back to that point. 2060 01:32:17,610 --> 01:32:18,724