1 00:00:00,000 --> 00:00:09,840 2 00:00:09,840 --> 00:00:10,824 >> [VIDEO PLAYBACK] 3 00:00:10,824 --> 00:00:13,284 >> [CAR DOOR SHUTTING] 4 00:00:13,284 --> 00:00:15,744 >> [CAR ENGINE STARTING] 5 00:00:15,744 --> 00:00:19,188 >> [MUSIC PLAYING] 6 00:00:19,188 --> 00:00:20,172 7 00:00:20,172 --> 00:00:24,516 >> -Moving right along in search of good times and good news. 8 00:00:24,516 --> 00:00:26,871 With good friends you can't lose. 9 00:00:26,871 --> 00:00:28,755 >> -This could become a habit. 10 00:00:28,755 --> 00:00:32,460 >> -Opportunity knocks Let's just reach out and grab it. 11 00:00:32,460 --> 00:00:32,960 -Yeah! 12 00:00:32,960 --> 00:00:34,920 -Together we'll nab it. 13 00:00:34,920 --> 00:00:37,370 -We'll hitch hike, bus, or yellow cab it. 14 00:00:37,370 --> 00:00:38,840 -Dammit. 15 00:00:38,840 --> 00:00:40,800 -We're moving right along. 16 00:00:40,800 --> 00:00:43,750 -Footloose and fancy free. 17 00:00:43,750 --> 00:00:45,960 -Getting there is half the fun. 18 00:00:45,960 --> 00:00:47,718 Come share it with me. 19 00:00:47,718 --> 00:00:49,654 >> -We're moving right along. 20 00:00:49,654 --> 00:00:52,558 >> -We're going to share the load. 21 00:00:52,558 --> 00:00:57,604 >> -We don't need a map to get this show on the road. 22 00:00:57,604 --> 00:01:00,520 -Hey Fozzy, I want you to turn left if you come to a fork in the road. 23 00:01:00,520 --> 00:01:01,020 -Yes, sir. 24 00:01:01,020 --> 00:01:03,334 Turn left at the fork in the road. 25 00:01:03,334 --> 00:01:05,222 Turn left. 26 00:01:05,222 --> 00:01:07,582 >> -I don't believe that. 27 00:01:07,582 --> 00:01:11,720 >> -Cruising right along we found the lights on the highway. 28 00:01:11,720 --> 00:01:13,664 >> -And your way or my way. 29 00:01:13,664 --> 00:01:16,154 >> -So trust my navigation. 30 00:01:16,154 --> 00:01:21,134 >> -Movie stars with flashy cars and life with the top down. 31 00:01:21,134 --> 00:01:23,126 >> -We're storming the big hills. 32 00:01:23,126 --> 00:01:24,122 >> -Yeah, storm is right. 33 00:01:24,122 --> 00:01:25,160 Should it be snowing? 34 00:01:25,160 --> 00:01:26,220 >> -No, I don't think so. 35 00:01:26,220 --> 00:01:28,505 >> -Moving right along. 36 00:01:28,505 --> 00:01:30,980 >> -Footloose and fancy free. 37 00:01:30,980 --> 00:01:32,960 >> -You're ready for the big time. 38 00:01:32,960 --> 00:01:34,445 >> -Is it ready for me? 39 00:01:34,445 --> 00:01:38,900 40 00:01:38,900 --> 00:01:42,860 >> -Moving right along. 41 00:01:42,860 --> 00:01:47,315 Moving right along. 42 00:01:47,315 --> 00:01:52,265 Moving right along. 43 00:01:52,265 --> 00:01:56,131 Moving right along. 44 00:01:56,131 --> 00:01:57,380 -I think you better pull over. 45 00:01:57,380 --> 00:01:58,020 -Yes, sir. 46 00:01:58,020 --> 00:02:02,475 47 00:02:02,475 --> 00:02:03,960 >> [END PLAYBACK] 48 00:02:03,960 --> 00:02:07,425 >> [APPLAUSE] 49 00:02:07,425 --> 00:02:09,405 50 00:02:09,405 --> 00:02:11,930 >> DAVID J. MALAN: This is CS50. 51 00:02:11,930 --> 00:02:15,940 And this is the end of Week 0, but the start of a beautiful friendship. 52 00:02:15,940 --> 00:02:18,250 We are so excited to be here at Yale University 53 00:02:18,250 --> 00:02:21,530 for the very first time with our friend Scaz, and Jason, and Andy. 54 00:02:21,530 --> 00:02:24,320 All 40 of CS50's TF's and CA's here at Yale. 55 00:02:24,320 --> 00:02:25,440 And all of you. 56 00:02:25,440 --> 00:02:28,470 And in fact, it's probably time to-- 57 00:02:28,470 --> 00:02:31,914 >> [APPLAUSE] 58 00:02:31,914 --> 00:02:43,722 59 00:02:43,722 --> 00:02:47,920 >> So, even though most of the lectures will indeed be in Cambridge this year, 60 00:02:47,920 --> 00:02:51,250 the reality is that by design, and very much deliberately in CS50, 61 00:02:51,250 --> 00:02:54,740 I do think we're nearing the point technologically, and pedagogically, 62 00:02:54,740 --> 00:02:57,930 where it can be a superior educational experience to engage with some 63 00:02:57,930 --> 00:02:59,610 of the course's material online. 64 00:02:59,610 --> 00:03:02,862 Indeed, the reality-- and if I believe this philosophically-- is that lectures 65 00:03:02,862 --> 00:03:05,070 are not a particularly effective means for delivering 66 00:03:05,070 --> 00:03:06,900 fairly complex information. 67 00:03:06,900 --> 00:03:09,219 Certainly over hour plus long spans of time. 68 00:03:09,219 --> 00:03:11,760 And indeed every few minutes-- I remember myself in college-- 69 00:03:11,760 --> 00:03:14,210 you zone out for a moment, you miss some complex topic, 70 00:03:14,210 --> 00:03:16,540 and you're gone pretty much for the next 45 minutes. 71 00:03:16,540 --> 00:03:19,414 And the reality is that whether you're here in New Haven or Cambridge 72 00:03:19,414 --> 00:03:22,930 or beyond, the simplicity of having the ability to pause and fast forward, 73 00:03:22,930 --> 00:03:26,270 rewind, hyperlink to related resources, search full text transcripts 74 00:03:26,270 --> 00:03:29,900 and the like is an opportunity that I dare say for our online students 75 00:03:29,900 --> 00:03:32,530 well beyond New Haven, offers them an opportunity 76 00:03:32,530 --> 00:03:34,700 to really grasp the conceptual material that we 77 00:03:34,700 --> 00:03:36,700 introduce in lectures all the better. 78 00:03:36,700 --> 00:03:39,415 >> But ultimately in CS50, is the students' experience 79 00:03:39,415 --> 00:03:43,099 is characterized so, so much more by the course's problem sets, 80 00:03:43,099 --> 00:03:46,140 or weekly programming projects, the course's sections led by the teaching 81 00:03:46,140 --> 00:03:49,600 fellows, the nightly office hours led by the course assistants and the teaching 82 00:03:49,600 --> 00:03:52,330 fellows, and indeed such events as CS50 Puzzle 83 00:03:52,330 --> 00:03:56,500 Day, CS50's Hack-a-thon, the CS50 Fair, weekly lunches, and so much more. 84 00:03:56,500 --> 00:03:59,580 And so whether you're here in New Haven, or tuning in from afar, 85 00:03:59,580 --> 00:04:02,270 today in Cambridge, and we'll see you again soon, 86 00:04:02,270 --> 00:04:04,580 the reality is this is one and the same class. 87 00:04:04,580 --> 00:04:07,990 And we are so excited to be here all together today. 88 00:04:07,990 --> 00:04:11,110 And so at the end of the semester, whether here or afar, well 89 00:04:11,110 --> 00:04:14,910 hopefully you wear proudly, happily, and perhaps with a bit of relief, 90 00:04:14,910 --> 00:04:19,459 the shirt that bears witness to you having taken CS50. 91 00:04:19,459 --> 00:04:21,700 >> So where did we leave off on Wednesday? 92 00:04:21,700 --> 00:04:24,410 We took a look at computational thinking. 93 00:04:24,410 --> 00:04:27,830 And that's toward what we distilled computer science unto, at least 94 00:04:27,830 --> 00:04:28,800 for now. 95 00:04:28,800 --> 00:04:31,990 But we distilled it little further into at least three components elements. 96 00:04:31,990 --> 00:04:34,570 >> Inputs, so what is the problem we're trying to solve? 97 00:04:34,570 --> 00:04:36,650 Outputs, what is the answer we're hoping to get? 98 00:04:36,650 --> 00:04:38,210 And the representation there of. 99 00:04:38,210 --> 00:04:41,870 And we won't dwell here on after on binary, or even ASCII, 100 00:04:41,870 --> 00:04:44,050 and the like so much, but rather take for granted 101 00:04:44,050 --> 00:04:47,520 that we can represent this information, because the far more interesting parts 102 00:04:47,520 --> 00:04:51,010 of those problems are not just the inputs and outputs, but the algorithms 103 00:04:51,010 --> 00:04:53,020 that go into solving those problems. 104 00:04:53,020 --> 00:04:55,120 >> And you might recall from the other day that we 105 00:04:55,120 --> 00:04:59,860 took a fairly traditional concept of looking someone up 106 00:04:59,860 --> 00:05:03,240 in a fairly large phone book, or more generally digitally these days, 107 00:05:03,240 --> 00:05:04,420 just a very large data set. 108 00:05:04,420 --> 00:05:07,840 A really big contacts list, with lots of names alphabetically sorted. 109 00:05:07,840 --> 00:05:11,310 And we realized that while I could approach this problem simply 110 00:05:11,310 --> 00:05:14,520 by using a linear approach-- page by page, 111 00:05:14,520 --> 00:05:17,775 or even two's at a time-- we realized that the more intuitive algorithm-- 112 00:05:17,775 --> 00:05:20,840 just kind of dividing and conquering the problem again, and again, 113 00:05:20,840 --> 00:05:24,670 and again-- halving it with each time, gave us this green result. 114 00:05:24,670 --> 00:05:27,080 And it's so much flatter because it suggests 115 00:05:27,080 --> 00:05:29,160 that even as this problem gets bigger and bigger, 116 00:05:29,160 --> 00:05:32,470 as is the case these days with data sets and reality-- Facebook and Google 117 00:05:32,470 --> 00:05:34,630 search results and the like-- does our algorithm 118 00:05:34,630 --> 00:05:37,660 perform just as effectively with those bigger bites 119 00:05:37,660 --> 00:05:40,310 as it did even with the smaller bites. 120 00:05:40,310 --> 00:05:45,330 >> Now it begs the question, what can we actually solve similarly 121 00:05:45,330 --> 00:05:46,820 with this kind of intuition? 122 00:05:46,820 --> 00:05:48,740 This sort of division and conquering? 123 00:05:48,740 --> 00:05:51,029 Well, we could do something like this today here. 124 00:05:51,029 --> 00:05:52,070 We could take attendance. 125 00:05:52,070 --> 00:05:56,102 So maybe like 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11-- 126 00:05:56,102 --> 00:05:57,560 not going to be all that efficient. 127 00:05:57,560 --> 00:05:58,990 So wait, grade school. 128 00:05:58,990 --> 00:06:02,770 2, 4, 6, 8, 10, 12, 14, 16, 18 and so forth. 129 00:06:02,770 --> 00:06:04,140 But could we do a little better? 130 00:06:04,140 --> 00:06:06,630 >> I'm pretty sure I can't do this by myself. 131 00:06:06,630 --> 00:06:09,420 So if you'll humor us for just a moment, we brought with us 132 00:06:09,420 --> 00:06:11,640 an algorithm that's just got three steps, 133 00:06:11,640 --> 00:06:15,130 but it does require-- if you don't mind-- all of us stand up, 134 00:06:15,130 --> 00:06:15,690 if you would. 135 00:06:15,690 --> 00:06:23,901 136 00:06:23,901 --> 00:06:29,380 So, with all of us now standing, step one of this algorithm is the following. 137 00:06:29,380 --> 00:06:31,680 Stand up and assign yourself the number 1. 138 00:06:31,680 --> 00:06:34,180 So at this point in time, literally everyone in this room 139 00:06:34,180 --> 00:06:38,830 hopefully is thinking to themselves, however awkwardly, the number 1. 140 00:06:38,830 --> 00:06:42,020 >> Now step two of this algorithm is going to involve the following. 141 00:06:42,020 --> 00:06:44,680 Step two, pair off with someone standing, 142 00:06:44,680 --> 00:06:47,970 add your numbers together, and adopt the sum as your new number. 143 00:06:47,970 --> 00:06:53,110 144 00:06:53,110 --> 00:06:55,620 Quick sanity check. 145 00:06:55,620 --> 00:06:58,180 What number is everyone thinking of now? 146 00:06:58,180 --> 00:07:01,930 >> So 2, except maybe for one, awkward, lonesome person. 147 00:07:01,930 --> 00:07:04,269 If we have an odd number of people in the room. 148 00:07:04,269 --> 00:07:06,560 So one person might still be the number 1, that's fine. 149 00:07:06,560 --> 00:07:09,440 But step three here, one of you should sit down. 150 00:07:09,440 --> 00:07:13,620 The other should go back to step two, and repeat, if you would. 151 00:07:13,620 --> 00:07:54,430 152 00:07:54,430 --> 00:07:58,240 >> So if still standing, you should be among those going back to step two. 153 00:07:58,240 --> 00:08:13,910 154 00:08:13,910 --> 00:08:14,574 Keep going. 155 00:08:14,574 --> 00:08:20,790 156 00:08:20,790 --> 00:08:22,130 A few people still standing. 157 00:08:22,130 --> 00:08:33,590 158 00:08:33,590 --> 00:08:35,614 >> So, if still standing, pair up with someone. 159 00:08:35,614 --> 00:08:53,710 160 00:08:53,710 --> 00:08:55,020 All right, dwindling down. 161 00:08:55,020 --> 00:09:06,394 162 00:09:06,394 --> 00:09:07,560 A few people still standing. 163 00:09:07,560 --> 00:09:08,600 I'll help if need be. 164 00:09:08,600 --> 00:09:11,855 Remember the key takeaway here, is how much faster this is than me counting. 165 00:09:11,855 --> 00:09:15,090 166 00:09:15,090 --> 00:09:16,200 >> So let's see. 167 00:09:16,200 --> 00:09:16,900 I can help out. 168 00:09:16,900 --> 00:09:19,425 So what number are you still thinking of? 169 00:09:19,425 --> 00:09:20,320 >> AUDIENCE: I'm at 44. 170 00:09:20,320 --> 00:09:22,400 >> DAVID J. MALAN: 44, so you go ahead and sit down. 171 00:09:22,400 --> 00:09:23,733 What number are you thinking of? 172 00:09:23,733 --> 00:09:24,840 AUDIENCE: 74. 173 00:09:24,840 --> 00:09:27,006 >> DAVID J. MALAN: 74. 174 00:09:27,006 --> 00:09:28,380 All right, go ahead and sit down. 175 00:09:28,380 --> 00:09:30,390 Who else is still standing? 176 00:09:30,390 --> 00:09:31,550 86. 177 00:09:31,550 --> 00:09:33,340 And is anyone else still standing? 178 00:09:33,340 --> 00:09:34,976 >> What number? 179 00:09:34,976 --> 00:09:37,380 I heard 67. 180 00:09:37,380 --> 00:09:39,370 And then in top? 181 00:09:39,370 --> 00:09:40,900 32. 182 00:09:40,900 --> 00:09:44,230 Anyone else still standing and thinking of a number? 183 00:09:44,230 --> 00:09:44,730 >> Oh, hi. 184 00:09:44,730 --> 00:09:45,230 Sorry. 185 00:09:45,230 --> 00:09:48,350 Be right back. 186 00:09:48,350 --> 00:09:49,520 42. 187 00:09:49,520 --> 00:09:51,758 Anyone else? 188 00:09:51,758 --> 00:09:52,610 >> AUDIENCE: 47. 189 00:09:52,610 --> 00:09:54,930 >> DAVID J. MALAN: 47. 190 00:09:54,930 --> 00:09:57,980 Is anyone else still standing who hasn't been counted? 191 00:09:57,980 --> 00:10:06,450 So the final number of people in a room that has 497 seats is-- all of which 192 00:10:06,450 --> 00:10:10,930 are filled-- is 390. 193 00:10:10,930 --> 00:10:12,230 So this is great. 194 00:10:12,230 --> 00:10:16,435 >> We will soon discuss the notion of a bug in a computer program. 195 00:10:16,435 --> 00:10:19,660 But we'll come back to that before long. 196 00:10:19,660 --> 00:10:22,440 But in theory, what might have happened just now? 197 00:10:22,440 --> 00:10:25,930 So even though there were three big steps to this algorithm, each of those 198 00:10:25,930 --> 00:10:27,510 was just kind of one big operation. 199 00:10:27,510 --> 00:10:31,020 And there was this cyclicity to it in that if you were still standing, 200 00:10:31,020 --> 00:10:34,870 you kept going from step three to two, step three to two, step three to two. 201 00:10:34,870 --> 00:10:37,330 >> But what kept happening on each iteration? 202 00:10:37,330 --> 00:10:39,440 Each cycle of this loop? 203 00:10:39,440 --> 00:10:41,940 What was happening elsewhere in the room? 204 00:10:41,940 --> 00:10:45,170 Not only the same thing, but what was happening to half of you? 205 00:10:45,170 --> 00:10:46,170 Sitting down. 206 00:10:46,170 --> 00:10:49,710 And so there in lies this insight, much like the phone book example, 207 00:10:49,710 --> 00:10:52,050 in that if half of you are sitting down each time, 208 00:10:52,050 --> 00:10:54,560 the problem is starting with maybe 400 people, 209 00:10:54,560 --> 00:10:57,780 then to 200 people, than 100 people, then 50 people, and so forth. 210 00:10:57,780 --> 00:11:00,660 >> And so we whittle down in theory to just one person, 211 00:11:00,660 --> 00:11:02,830 thinking of the total value of everyone. 212 00:11:02,830 --> 00:11:05,777 Now reality, some social dynamics, and some arithmetic errors 213 00:11:05,777 --> 00:11:07,360 might contribute to that ultimate bug. 214 00:11:07,360 --> 00:11:10,300 But in theory, while I was still counting away, 215 00:11:10,300 --> 00:11:12,860 taking several dozen steps, or hundreds of steps 216 00:11:12,860 --> 00:11:16,240 to count yourselves, to count a roomful of 500 or so people 217 00:11:16,240 --> 00:11:20,560 should have taken far fewer steps, because you can only divide 500 and 1/2 218 00:11:20,560 --> 00:11:21,350 so many times. 219 00:11:21,350 --> 00:11:24,120 And so just like with the phone book example the other day, 220 00:11:24,120 --> 00:11:26,740 did we have something logarithmic so to speak, 221 00:11:26,740 --> 00:11:28,870 whereby if we were all operating in unison, 222 00:11:28,870 --> 00:11:32,000 and ignoring the addition errors, would we 223 00:11:32,000 --> 00:11:34,140 have achieved exactly that kind of running time? 224 00:11:34,140 --> 00:11:37,900 >> Now to be fair, kind of cheated, in that I leveraged another resource. 225 00:11:37,900 --> 00:11:40,320 Whereas it's just one of me, I leveraged hundreds of you. 226 00:11:40,320 --> 00:11:43,340 But that might be said to be an example of parallel processing, 227 00:11:43,340 --> 00:11:46,400 or a state of art very much in vogue where computers these days have 228 00:11:46,400 --> 00:11:49,830 multiple CPUs, or more technically, more multiple cores, 229 00:11:49,830 --> 00:11:52,550 and can truly do multiple things at once, much like you 230 00:11:52,550 --> 00:11:54,706 all we're doing there, in parallel. 231 00:11:54,706 --> 00:11:56,580 But recall that what we also did on Wednesday 232 00:11:56,580 --> 00:12:02,640 was try to capture this intuition and formalize it in code. 233 00:12:02,640 --> 00:12:04,165 Something like pseudo-code. 234 00:12:04,165 --> 00:12:07,040 And in fact, and I hope you'll forgive, it's like 80 degrees in here. 235 00:12:07,040 --> 00:12:09,420 So I'm going to take this off for just a little bit. 236 00:12:09,420 --> 00:12:12,410 What I thought we'd do is transition now to an application whereby 237 00:12:12,410 --> 00:12:16,300 we again engage the audience, but write a program in English 238 00:12:16,300 --> 00:12:19,537 like syntax, with which to solve this problem here. 239 00:12:19,537 --> 00:12:20,203 [VIDEO PLAYBACK] 240 00:12:20,203 --> 00:12:22,266 -It's peanut butter jelly time. 241 00:12:22,266 --> 00:12:23,890 Peanut butter jelly time. 242 00:12:23,890 --> 00:12:25,620 Peanut butter jelly time. 243 00:12:25,620 --> 00:12:26,320 >> Way ya! 244 00:12:26,320 --> 00:12:26,927 Way ya! 245 00:12:26,927 --> 00:12:27,781 Way ya! 246 00:12:27,781 --> 00:12:28,350 Way ya! 247 00:12:28,350 --> 00:12:29,723 Now there you go! 248 00:12:29,723 --> 00:12:30,264 There you go! 249 00:12:30,264 --> 00:12:30,805 There you go! 250 00:12:30,805 --> 00:12:31,710 There you go! 251 00:12:31,710 --> 00:12:33,156 Peanut butter jelly! 252 00:12:33,156 --> 00:12:34,602 Peanut butter jelly! 253 00:12:34,602 --> 00:12:36,530 >> Peanut butter jelly! 254 00:12:36,530 --> 00:12:37,494 Peanut butter jelly! 255 00:12:37,494 --> 00:12:38,940 Peanut, peanut butter jelly! 256 00:12:38,940 --> 00:12:39,904 Peanut butter jelly! 257 00:12:39,904 --> 00:12:41,840 Peanut butter jelly with a baseball bat. 258 00:12:41,840 --> 00:12:42,423 >> [END PLAYBACK] 259 00:12:42,423 --> 00:12:45,510 DAVID J. MALAN: --that video, but it is a little addictive, 260 00:12:45,510 --> 00:12:46,540 if not a bit annoying. 261 00:12:46,540 --> 00:12:49,623 But to do this, I thought what we'd do is try to write a program together, 262 00:12:49,623 --> 00:12:51,870 for which we need three volunteers. 263 00:12:51,870 --> 00:12:54,350 Have to be comfortable on camera and internet. 264 00:12:54,350 --> 00:12:57,820 Sam, come on up. 265 00:12:57,820 --> 00:12:59,830 Purple shirt, right here, come on up. 266 00:12:59,830 --> 00:13:03,470 >> And from over here, let me go a little farther back. 267 00:13:03,470 --> 00:13:05,280 Crimson and blue shirts, come on up. 268 00:13:05,280 --> 00:13:06,980 Perfect. 269 00:13:06,980 --> 00:13:09,790 Come on now. 270 00:13:09,790 --> 00:13:12,490 Come on up, come on up. 271 00:13:12,490 --> 00:13:13,581 >> And what's your name? 272 00:13:13,581 --> 00:13:14,080 Erica. 273 00:13:14,080 --> 00:13:15,289 David, nice to meet you. 274 00:13:15,289 --> 00:13:16,830 If you'd like to take this seat here. 275 00:13:16,830 --> 00:13:17,900 This is Sam. 276 00:13:17,900 --> 00:13:19,690 >> What's your name? 277 00:13:19,690 --> 00:13:20,260 Antonio. 278 00:13:20,260 --> 00:13:21,595 Antonio, nice to meet you. 279 00:13:21,595 --> 00:13:23,790 Erica and Sam, if you'd like to have a seat here. 280 00:13:23,790 --> 00:13:26,700 What we've come prepared with, as these guys are discovering, 281 00:13:26,700 --> 00:13:30,580 is the ingredients with which to make a peanut butter and jelly sandwich. 282 00:13:30,580 --> 00:13:33,520 >> Now this might be something that you take very much for granted. 283 00:13:33,520 --> 00:13:35,430 But we've given each of our three volunteers 284 00:13:35,430 --> 00:13:40,500 here-- two volunteers and Sam here, a loaf of bread each, a plate, a knife, 285 00:13:40,500 --> 00:13:43,740 a jar of jelly or jam, and a jar of peanut butter. 286 00:13:43,740 --> 00:13:46,190 And the goal at hand now is going to be for these three 287 00:13:46,190 --> 00:13:48,030 to make a peanut butter and jelly sandwich. 288 00:13:48,030 --> 00:13:51,000 But what we're going to do is expect the audience-- since all of you 289 00:13:51,000 --> 00:13:53,710 surely know how to do this so well in reality-- 290 00:13:53,710 --> 00:13:56,380 are going to provide us with the step by step instructions. 291 00:13:56,380 --> 00:13:57,970 The pseudo-code, if you will. 292 00:13:57,970 --> 00:13:59,922 >> So I'll play the role of scribe here. 293 00:13:59,922 --> 00:14:02,880 And I've got a little to-do list, and so as each of you, one at a time, 294 00:14:02,880 --> 00:14:04,588 calls out a potential instructional, I'll 295 00:14:04,588 --> 00:14:06,110 write it down, repeat it as needed. 296 00:14:06,110 --> 00:14:09,650 And then you guys are going to make a peanut butter and jelly sandwich 297 00:14:09,650 --> 00:14:11,171 only by doing what you are told. 298 00:14:11,171 --> 00:14:12,670 So think of yourselves as computers. 299 00:14:12,670 --> 00:14:13,740 >> You can only do what you're told. 300 00:14:13,740 --> 00:14:14,948 No assumptions, no questions. 301 00:14:14,948 --> 00:14:16,660 You just need to do it. 302 00:14:16,660 --> 00:14:20,460 So who would like to hazard the first instruction for making a PBJ sandwich? 303 00:14:20,460 --> 00:14:21,460 On the balcony there. 304 00:14:21,460 --> 00:14:22,801 >> AUDIENCE: Open the bag of bread. 305 00:14:22,801 --> 00:14:26,430 >> DAVID J. MALAN: Open the bag of bread, if you will. 306 00:14:26,430 --> 00:14:34,440 307 00:14:34,440 --> 00:14:35,230 So let's see. 308 00:14:35,230 --> 00:14:37,910 Let's iterate, and get a little more precise. 309 00:14:37,910 --> 00:14:39,040 >> Good way to begin though. 310 00:14:39,040 --> 00:14:42,340 Step two, someone else. 311 00:14:42,340 --> 00:14:43,590 Now no one wants to volunteer. 312 00:14:43,590 --> 00:14:44,616 Step two, in front. 313 00:14:44,616 --> 00:14:46,532 AUDIENCE: Open the inner bag of bread as well. 314 00:14:46,532 --> 00:14:50,600 DAVID J. MALAN: Open the inner bag of bread as well. 315 00:14:50,600 --> 00:14:51,880 Great, we learning. 316 00:14:51,880 --> 00:14:57,880 317 00:14:57,880 --> 00:14:59,090 A little more precise. 318 00:14:59,090 --> 00:15:00,240 Let's get this working. 319 00:15:00,240 --> 00:15:01,180 Yes, in green shirt. 320 00:15:01,180 --> 00:15:04,608 >> AUDIENCE: [INAUDIBLE] 321 00:15:04,608 --> 00:15:05,108 322 00:15:05,108 --> 00:15:09,040 DAVID J. MALAN: Slices of bread. 323 00:15:09,040 --> 00:15:11,110 Gently remove two slices of bread. 324 00:15:11,110 --> 00:15:20,350 325 00:15:20,350 --> 00:15:21,000 That's good. 326 00:15:21,000 --> 00:15:24,300 Step four, someone else? 327 00:15:24,300 --> 00:15:25,170 Over here, yes? 328 00:15:25,170 --> 00:15:26,130 >> AUDIENCE: [INAUDIBLE] 329 00:15:26,130 --> 00:15:28,810 >> DAVID J. MALAN: Place bread on plate. 330 00:15:28,810 --> 00:15:33,490 331 00:15:33,490 --> 00:15:35,290 Step five? 332 00:15:35,290 --> 00:15:36,020 Step five, yeah? 333 00:15:36,020 --> 00:15:39,440 >> AUDIENCE: [INAUDIBLE] 334 00:15:39,440 --> 00:15:39,940 335 00:15:39,940 --> 00:15:43,860 DAVID J. MALAN: On top of-- oh, hand. 336 00:15:43,860 --> 00:15:46,967 Place hand on top of peanut butter. 337 00:15:46,967 --> 00:15:47,800 Is that what I head? 338 00:15:47,800 --> 00:15:49,160 >> AUDIENCE: Yeah, and unscrew. 339 00:15:49,160 --> 00:15:51,370 >> DAVID J. MALAN: And-- say it again. 340 00:15:51,370 --> 00:15:52,696 >> AUDIENCE: [INAUDIBLE] 341 00:15:52,696 --> 00:15:57,990 >> DAVID J. MALAN: And put the lid next to the peanut butter. 342 00:15:57,990 --> 00:16:00,370 Lightly place hand on top of peanut butter, 343 00:16:00,370 --> 00:16:03,240 and unscrew, and put the lid next to the peanut butter. 344 00:16:03,240 --> 00:16:14,760 345 00:16:14,760 --> 00:16:16,260 OK, step six. 346 00:16:16,260 --> 00:16:17,520 Step six, someone else. 347 00:16:17,520 --> 00:16:19,366 Yeah? 348 00:16:19,366 --> 00:16:22,740 >> AUDIENCE: [INAUDIBLE] 349 00:16:22,740 --> 00:16:29,197 350 00:16:29,197 --> 00:16:30,405 DAVID J. MALAN: Say it again. 351 00:16:30,405 --> 00:16:31,946 AUDIENCE: Repeat step five again. 352 00:16:31,946 --> 00:16:37,380 DAVID J. MALAN: And repeat step five again, 353 00:16:37,380 --> 00:16:39,400 which is going to create a bit of a problem 354 00:16:39,400 --> 00:16:42,600 now if we're doing this step by step. 355 00:16:42,600 --> 00:16:44,640 So now we go back to step five. 356 00:16:44,640 --> 00:16:47,760 Lightly place hand on top of peanut butter and unscrew 357 00:16:47,760 --> 00:16:50,990 and put lid next to the peanut butter. 358 00:16:50,990 --> 00:16:55,340 Then grasp the peanut butter and repeat step five again. 359 00:16:55,340 --> 00:16:58,410 >> So we'll override that infinite loop, if you will. 360 00:16:58,410 --> 00:17:00,400 Step seven, someone else. 361 00:17:00,400 --> 00:17:02,918 Yeah, in back. 362 00:17:02,918 --> 00:17:06,397 >> AUDIENCE: [INAUDIBLE] 363 00:17:06,397 --> 00:17:16,084 364 00:17:16,084 --> 00:17:17,769 >> DAVID J. MALAN: --on top of other. 365 00:17:17,769 --> 00:17:20,529 >> AUDIENCE: [INAUDIBLE] 366 00:17:20,529 --> 00:17:23,175 >> DAVID J. MALAN: On the other hand on the other top. 367 00:17:23,175 --> 00:17:28,880 368 00:17:28,880 --> 00:17:30,895 Do you want to just come up here? 369 00:17:30,895 --> 00:17:34,750 How do I finish the instruction? 370 00:17:34,750 --> 00:17:37,790 What's the rest of the instruction? 371 00:17:37,790 --> 00:17:39,140 >> AUDIENCE: Ignoring that part. 372 00:17:39,140 --> 00:17:41,050 >> DAVID J. MALAN: Ignoring that part. 373 00:17:41,050 --> 00:17:44,192 374 00:17:44,192 --> 00:17:44,900 Let's start over. 375 00:17:44,900 --> 00:17:45,400 Step seven. 376 00:17:45,400 --> 00:17:48,516 377 00:17:48,516 --> 00:17:51,883 >> AUDIENCE: [INAUDIBLE] 378 00:17:51,883 --> 00:17:56,090 >> DAVID J. MALAN: Grasp with opposing hand-- this is good. 379 00:17:56,090 --> 00:17:58,544 This is actually good. 380 00:17:58,544 --> 00:18:01,750 >> AUDIENCE: [INAUDIBLE] 381 00:18:01,750 --> 00:18:03,975 >> DAVID J. MALAN: And plastic jar-- 382 00:18:03,975 --> 00:18:06,675 >> AUDIENCE: [INAUDIBLE] 383 00:18:06,675 --> 00:18:08,420 >> DAVID J. MALAN: And twist-- 384 00:18:08,420 --> 00:18:11,488 >> AUDIENCE: [INAUDIBLE] 385 00:18:11,488 --> 00:18:13,730 >> DAVID J. MALAN: For two seconds. 386 00:18:13,730 --> 00:18:15,800 Just open the peanut butter jar. 387 00:18:15,800 --> 00:18:19,020 388 00:18:19,020 --> 00:18:20,632 I hope you'll forgive. 389 00:18:20,632 --> 00:18:21,840 So let's assume we got there. 390 00:18:21,840 --> 00:18:23,240 Open the peanut butter jar. 391 00:18:23,240 --> 00:18:27,008 392 00:18:27,008 --> 00:18:32,570 >> [APPLAUSE] 393 00:18:32,570 --> 00:18:34,790 >> DAVID J. MALAN: Step eight, let's go. 394 00:18:34,790 --> 00:18:37,510 Step eight, yes, in back. 395 00:18:37,510 --> 00:18:38,470 >> AUDIENCE: [INAUDIBLE] 396 00:18:38,470 --> 00:18:44,772 397 00:18:44,772 --> 00:18:45,700 >> DAVID J. MALAN: Good. 398 00:18:45,700 --> 00:18:47,040 Step nine, yes? 399 00:18:47,040 --> 00:18:48,924 >> AUDIENCE: [INAUDIBLE] 400 00:18:48,924 --> 00:18:51,567 >> DAVID J. MALAN: --out of the peanut butter jar. 401 00:18:51,567 --> 00:18:53,830 And-- and what? 402 00:18:53,830 --> 00:18:54,729 >> AUDIENCE: [INAUDIBLE] 403 00:18:54,729 --> 00:18:58,222 >> DAVID J. MALAN: And put knife back into peanut butter. 404 00:18:58,222 --> 00:19:11,130 405 00:19:11,130 --> 00:19:12,090 Step ten. 406 00:19:12,090 --> 00:19:13,050 Step ten. 407 00:19:13,050 --> 00:19:14,970 >> AUDIENCE: [INAUDIBLE] 408 00:19:14,970 --> 00:19:20,710 >> DAVID J. MALAN: Put the knife out, and then remove the seal. 409 00:19:20,710 --> 00:19:23,060 Nice. 410 00:19:23,060 --> 00:19:24,400 Off the peanut butter. 411 00:19:24,400 --> 00:19:34,490 412 00:19:34,490 --> 00:19:36,406 All right, step 11. 413 00:19:36,406 --> 00:19:37,322 >> AUDIENCE: [INAUDIBLE] 414 00:19:37,322 --> 00:19:42,520 415 00:19:42,520 --> 00:19:48,164 >> DAVID J. MALAN: OK, grey computer follow blue or red computer. 416 00:19:48,164 --> 00:19:49,631 Good. 417 00:19:49,631 --> 00:19:53,054 >> [APPLAUSE] 418 00:19:53,054 --> 00:19:55,920 419 00:19:55,920 --> 00:19:57,170 DAVID J. MALAN: Bring us home. 420 00:19:57,170 --> 00:19:59,570 Couple more steps. 421 00:19:59,570 --> 00:20:00,250 What's next? 422 00:20:00,250 --> 00:20:02,590 Steps 12. 423 00:20:02,590 --> 00:20:04,161 Step 12. 424 00:20:04,161 --> 00:20:05,123 Yeah? 425 00:20:05,123 --> 00:20:14,262 >> AUDIENCE: Put one of the slices of bread gently on one of your hands. 426 00:20:14,262 --> 00:20:17,550 >> DAVID J. MALAN: One of your hands. 427 00:20:17,550 --> 00:20:20,760 And then, step 13. 428 00:20:20,760 --> 00:20:21,260 Yeah? 429 00:20:21,260 --> 00:20:22,220 >> AUDIENCE: [INAUDIBLE] 430 00:20:22,220 --> 00:20:25,580 431 00:20:25,580 --> 00:20:27,150 >> DAVID J. MALAN: --on slice of bread. 432 00:20:27,150 --> 00:20:29,950 Good. 433 00:20:29,950 --> 00:20:32,260 Pretty good. 434 00:20:32,260 --> 00:20:34,990 Step 14, yeah. 435 00:20:34,990 --> 00:20:38,126 >> AUDIENCE: Undo step 13. 436 00:20:38,126 --> 00:20:39,950 >> DAVID J. MALAN: Undo step 13. 437 00:20:39,950 --> 00:20:42,690 438 00:20:42,690 --> 00:20:44,770 Let's move on to jelly. 439 00:20:44,770 --> 00:20:47,900 It's a 100- step program, but we're were on step 15. 440 00:20:47,900 --> 00:20:49,210 Yeah. 441 00:20:49,210 --> 00:20:50,170 >> AUDIENCE: [INAUDIBLE] 442 00:20:50,170 --> 00:20:53,050 443 00:20:53,050 --> 00:20:59,570 >> DAVID J. MALAN: 7 through 13 using the jelly, because those went so well. 444 00:20:59,570 --> 00:21:02,530 Repeat steps 7 through 13, using the jelly. 445 00:21:02,530 --> 00:21:07,940 So grasp the lower half of the jelly jar with one hand on top. 446 00:21:07,940 --> 00:21:11,970 On the other hand of the other top, ignoring that part, 447 00:21:11,970 --> 00:21:15,430 grasp with opposing hands, the lid and the plastic jar 448 00:21:15,430 --> 00:21:18,300 at the bottom, and twist for two seconds. 449 00:21:18,300 --> 00:21:19,940 Then open the jelly jar. 450 00:21:19,940 --> 00:21:23,290 451 00:21:23,290 --> 00:21:26,580 And lastly, let's try to give us something edible. 452 00:21:26,580 --> 00:21:27,270 Step 16. 453 00:21:27,270 --> 00:21:35,820 454 00:21:35,820 --> 00:21:37,130 So why don't we leave it there. 455 00:21:37,130 --> 00:21:38,879 Thank you so much to our three volunteers. 456 00:21:38,879 --> 00:21:41,466 [APPLAUSE] 457 00:21:41,466 --> 00:21:45,920 458 00:21:45,920 --> 00:21:50,300 >> We have a little CS50 stress ball for you. 459 00:21:50,300 --> 00:21:54,540 It was going to be a sandwich but-- so what 460 00:21:54,540 --> 00:21:57,130 was the point, beyond having a bit of fun with the algorithm? 461 00:21:57,130 --> 00:22:00,140 But the reality is that even when you're programming a computer, 462 00:22:00,140 --> 00:22:02,050 you need to be super precise. 463 00:22:02,050 --> 00:22:04,030 As complex or intimidating as your own computer 464 00:22:04,030 --> 00:22:06,670 might very well be to you, at least when something goes wrong, 465 00:22:06,670 --> 00:22:10,150 the reality is it's a pretty dumb device that was invented by us humans, 466 00:22:10,150 --> 00:22:13,267 and can only do a subset of what we do-- sometimes certainly faster-- 467 00:22:13,267 --> 00:22:15,100 but it doesn't know how to make assumptions. 468 00:22:15,100 --> 00:22:18,070 It doesn't know how to be on the same wavelength as you. 469 00:22:18,070 --> 00:22:20,280 >> It will only do precisely what you tell it. 470 00:22:20,280 --> 00:22:22,070 And you'll be struck, perhaps, as we start 471 00:22:22,070 --> 00:22:24,770 writing actual code with the first problem sets and beyond, 472 00:22:24,770 --> 00:22:27,490 just how easy it is to make an assumption as a human, 473 00:22:27,490 --> 00:22:31,880 and not anticipate I need to handle that case, or that corner case, 474 00:22:31,880 --> 00:22:34,900 so to speak, that might very well arise if for instance Sam had the only 475 00:22:34,900 --> 00:22:38,711 squeezable jar of jelly, whereas everyone else had some glass jars as 476 00:22:38,711 --> 00:22:39,210 well. 477 00:22:39,210 --> 00:22:42,170 So before we turn our attention to some actual code, 478 00:22:42,170 --> 00:22:44,680 allow me to introduce the course's heads here at Yale. 479 00:22:44,680 --> 00:22:49,058 Our friends Scaz, Andy, and Jason to come up and say hello. 480 00:22:49,058 --> 00:22:52,544 >> [APPLAUSE] 481 00:22:52,544 --> 00:22:58,022 482 00:22:58,022 --> 00:23:01,060 >> SCAZ: We've lost Jason temporarily. 483 00:23:01,060 --> 00:23:02,440 Hi again, everyone. 484 00:23:02,440 --> 00:23:03,610 My name is Scaz. 485 00:23:03,610 --> 00:23:06,860 I've been teaching at Yale since 2001. 486 00:23:06,860 --> 00:23:10,820 And when I am not teaching, my research is in robotics 487 00:23:10,820 --> 00:23:12,620 and artificial intelligence. 488 00:23:12,620 --> 00:23:17,700 >> And the announcement that I have today is that starting in a couple of weeks, 489 00:23:17,700 --> 00:23:22,170 we're going to be bringing some supplementary material to CS50 to talk 490 00:23:22,170 --> 00:23:24,510 about intelligence software. 491 00:23:24,510 --> 00:23:28,230 We're going to talk about how places like Netflix and Hulu 492 00:23:28,230 --> 00:23:31,780 can recommend movies which you might want to watch. 493 00:23:31,780 --> 00:23:35,710 Where we'll talk about how driver-less cars actually work. 494 00:23:35,710 --> 00:23:39,020 And we'll be able to ground these things in the concepts 495 00:23:39,020 --> 00:23:41,730 that you're learning in this class today. 496 00:23:41,730 --> 00:23:45,410 >> Because all of these things are built upon the same foundation. 497 00:23:45,410 --> 00:23:47,396 And that's what this series will explore. 498 00:23:47,396 --> 00:23:49,520 So I'm really looking forward to seeing more of you 499 00:23:49,520 --> 00:23:53,260 all, and you're going to get to see more from all of us very soon. 500 00:23:53,260 --> 00:23:56,500 Let me then introduce Jason. 501 00:23:56,500 --> 00:23:57,950 >> JASON: Hi everyone. 502 00:23:57,950 --> 00:23:59,290 My name is Jason. 503 00:23:59,290 --> 00:24:03,540 I unfortunately went to Harvard as an undergrad. 504 00:24:03,540 --> 00:24:07,020 That's going to get cut out of the actual stream. 505 00:24:07,020 --> 00:24:09,870 >> And now I'm here as a lecturer in the computer science department. 506 00:24:09,870 --> 00:24:14,825 And I'm helping run the course with Scaz, David and Andy. 507 00:24:14,825 --> 00:24:17,140 >> ANDY: Hey guys. 508 00:24:17,140 --> 00:24:17,980 My name's Andy. 509 00:24:17,980 --> 00:24:21,992 I am actually the only Yale student on the stage right now. 510 00:24:21,992 --> 00:24:25,464 >> [APPLAUSE] 511 00:24:25,464 --> 00:24:29,440 512 00:24:29,440 --> 00:24:31,770 >> I'm in Berkeley College, originally from Solon, Ohio. 513 00:24:31,770 --> 00:24:35,240 514 00:24:35,240 --> 00:24:37,930 And I was one of those kids where, when I came to Yale, 515 00:24:37,930 --> 00:24:42,030 I really thought that I would never have to look at a number ever again. 516 00:24:42,030 --> 00:24:46,240 And then I realized that you needed both science and QR credits to graduate. 517 00:24:46,240 --> 00:24:51,340 And so my freshman spring, I took a class, a CS, intro CS class here 518 00:24:51,340 --> 00:24:52,230 at Yale. 519 00:24:52,230 --> 00:24:54,710 I was like, this is like actually pretty cool. 520 00:24:54,710 --> 00:25:01,330 >> And while I actually ended up declaring as a global affairs major, the skills 521 00:25:01,330 --> 00:25:04,910 I learned in CS and programming are so applicable to any field 522 00:25:04,910 --> 00:25:05,970 you choose to do. 523 00:25:05,970 --> 00:25:09,770 And the staff here at Yale, we've been so hard at work 524 00:25:09,770 --> 00:25:10,800 to prepare for you guys. 525 00:25:10,800 --> 00:25:13,410 And we look forward to seeing all in section and office hours. 526 00:25:13,410 --> 00:25:14,874 So yeah. 527 00:25:14,874 --> 00:25:18,178 >> [APPLAUSE] 528 00:25:18,178 --> 00:25:19,297 529 00:25:19,297 --> 00:25:20,380 DAVID J. MALAN: Thank you. 530 00:25:20,380 --> 00:25:22,940 So just before class began, we had an opportunity 531 00:25:22,940 --> 00:25:25,660 to walk around campus with a cellphone and take 532 00:25:25,660 --> 00:25:30,530 some selfies in video form of really my first tour of Yale's campus here. 533 00:25:30,530 --> 00:25:35,420 And so we thought we'd share a rough cut of exactly this as Scaz and Andy 534 00:25:35,420 --> 00:25:37,970 and Jason took me around campus. 535 00:25:37,970 --> 00:25:43,662 536 00:25:43,662 --> 00:25:44,328 [VIDEO PLAYBACK] 537 00:25:44,328 --> 00:25:47,322 [SIRENS] 538 00:25:47,322 --> 00:25:49,318 -David. 539 00:25:49,318 --> 00:25:50,132 -Welcome to Yale. 540 00:25:50,132 --> 00:25:50,840 -Good to see you. 541 00:25:50,840 --> 00:25:52,410 -Nice to see you. 542 00:25:52,410 --> 00:25:53,340 -Can we go on a tour? 543 00:25:53,340 --> 00:25:56,845 -Let's go on a tour. 544 00:25:56,845 --> 00:25:57,523 -Road tour. 545 00:25:57,523 --> 00:25:59,106 -This sign has been there for a while. 546 00:25:59,106 --> 00:26:00,200 -Whah, CS50. 547 00:26:00,200 --> 00:26:02,978 548 00:26:02,978 --> 00:26:05,293 >> -Hurry! 549 00:26:05,293 --> 00:26:08,970 Go, go, go, go. 550 00:26:08,970 --> 00:26:12,340 You should [INAUDIBLE] Harkness Tower. 551 00:26:12,340 --> 00:26:13,850 >> -And we saw that a couple times. 552 00:26:13,850 --> 00:26:16,760 553 00:26:16,760 --> 00:26:20,155 >> [APPLAUSE] 554 00:26:20,155 --> 00:26:21,130 555 00:26:21,130 --> 00:26:22,890 >> -Look out for the bike! 556 00:26:22,890 --> 00:26:24,500 Ahh! 557 00:26:24,500 --> 00:26:25,030 Hi Frank. 558 00:26:25,030 --> 00:26:26,314 >> -What's up, guys? 559 00:26:26,314 --> 00:26:26,855 -How are you? 560 00:26:26,855 --> 00:26:28,474 -Good to see you. 561 00:26:28,474 --> 00:26:29,390 -Welcome to the video. 562 00:26:29,390 --> 00:26:32,270 Don't act too excited. 563 00:26:32,270 --> 00:26:34,502 >> -I love Silliman. 564 00:26:34,502 --> 00:26:36,430 Ahh! 565 00:26:36,430 --> 00:26:39,780 >> -It's been about three hours since Jason had ice cream and Nutella. 566 00:26:39,780 --> 00:26:43,189 So we've got to stop back at Silliman for a little bit. 567 00:26:43,189 --> 00:26:45,137 >> -It's not even [INAUDIBLE] yet, just the fact 568 00:26:45,137 --> 00:26:47,270 that they have it here is so amazing. 569 00:26:47,270 --> 00:26:49,830 Dude, there's Nutella at every meal. 570 00:26:49,830 --> 00:26:51,830 >> -There was last year too. 571 00:26:51,830 --> 00:26:54,220 >> -Yeah. 572 00:26:54,220 --> 00:26:56,440 >> -tell much about Yale so far. 573 00:26:56,440 --> 00:26:58,485 But I do now that's TD over there. 574 00:26:58,485 --> 00:26:59,860 And that's considered off campus. 575 00:26:59,860 --> 00:27:03,659 >> -Here we have gothic architecture. 576 00:27:03,659 --> 00:27:04,200 World famous. 577 00:27:04,200 --> 00:27:06,758 We have some more gothic architecture. 578 00:27:06,758 --> 00:27:10,614 And construction, and more gothic architecture. 579 00:27:10,614 --> 00:27:11,114 Hi. 580 00:27:11,114 --> 00:27:15,470 This is where we're having office hours Tuesdays through Thursdays in Hogwarts, 581 00:27:15,470 --> 00:27:16,922 as [INAUDIBLE] . 582 00:27:16,922 --> 00:27:20,620 583 00:27:20,620 --> 00:27:21,120 -All right. 584 00:27:21,120 --> 00:27:22,078 That's it for the tour. 585 00:27:22,078 --> 00:27:24,030 We are at Yale University's Law School, where 586 00:27:24,030 --> 00:27:25,870 today's lecture is about to take place. 587 00:27:25,870 --> 00:27:29,220 Let's head in. 588 00:27:29,220 --> 00:27:30,375 >> [END PLAYBACK] 589 00:27:30,375 --> 00:27:32,370 >> DAVID J. MALAN: And that brings us here now. 590 00:27:32,370 --> 00:27:38,040 591 00:27:38,040 --> 00:27:40,770 So thus far, we've been focusing on pseudocode, 592 00:27:40,770 --> 00:27:42,430 which is this English-like syntax. 593 00:27:42,430 --> 00:27:45,030 It has no prescribed specification. 594 00:27:45,030 --> 00:27:47,030 It's just you use some intuitive language if you 595 00:27:47,030 --> 00:27:48,950 want to explain what you want to do. 596 00:27:48,950 --> 00:27:52,270 >> But let's begin now to transition to code, as most people would say. 597 00:27:52,270 --> 00:27:54,880 But more precisely, something known as source code. 598 00:27:54,880 --> 00:27:58,210 This is the language that humans write that computers ultimately-- 599 00:27:58,210 --> 00:28:00,780 possibly after some number of steps-- ultimately understands 600 00:28:00,780 --> 00:28:02,530 so as to know how to do something. 601 00:28:02,530 --> 00:28:05,120 That you saw a glimpse of this perhaps on Wednesday. 602 00:28:05,120 --> 00:28:07,780 >> This is an example that incredibly, underwhelming 603 00:28:07,780 --> 00:28:10,220 when run simply says "hello world." 604 00:28:10,220 --> 00:28:13,510 And it's written in a language called C, which is syntactically very similar 605 00:28:13,510 --> 00:28:15,676 to a lot of other languages that you might not know, 606 00:28:15,676 --> 00:28:18,409 but might have heard of like Java, and C++, and Python, and Ruby, 607 00:28:18,409 --> 00:28:21,200 and the like, and indeed, we'll spend much of the semester using C, 608 00:28:21,200 --> 00:28:23,530 and then toward the end of the semester, building upon it, 609 00:28:23,530 --> 00:28:25,446 and introducing any number of other languages. 610 00:28:25,446 --> 00:28:28,810 Among them PHP, and JavaScript, a database language called SQL. 611 00:28:28,810 --> 00:28:31,526 But with C, what we'll have this bottom-up understanding 612 00:28:31,526 --> 00:28:33,900 of exactly how computers work, what you can do with them, 613 00:28:33,900 --> 00:28:37,252 and how you can solve problems all the more effectively by this 614 00:28:37,252 --> 00:28:39,460 layering that we discussed on Wednesday, and standing 615 00:28:39,460 --> 00:28:40,870 on the shoulders of others. 616 00:28:40,870 --> 00:28:42,200 But more on that to come. 617 00:28:42,200 --> 00:28:46,650 >> Today we look at a simpler environment, but a fundamentally identical 618 00:28:46,650 --> 00:28:49,970 environment known as Scratch by our friends at MIT Media Lab. 619 00:28:49,970 --> 00:28:52,570 This is a graphical programming language, Scratch, 620 00:28:52,570 --> 00:28:54,330 whereby you can drag and drop things that 621 00:28:54,330 --> 00:28:57,430 look like puzzle pieces that only interlock if it makes 622 00:28:57,430 --> 00:28:59,872 logical or programmatic sense to do so. 623 00:28:59,872 --> 00:29:02,330 But it's going to allow us to have a conversation about all 624 00:29:02,330 --> 00:29:04,604 of the same programming fundamentals that some of you 625 00:29:04,604 --> 00:29:06,520 might know already, that many of you might not 626 00:29:06,520 --> 00:29:09,670 know anything of without having to get bogged down frankly, 627 00:29:09,670 --> 00:29:13,150 in the intellectually uninteresting syntax of semicolons, 628 00:29:13,150 --> 00:29:14,950 and parentheses, and quotes, and the like. 629 00:29:14,950 --> 00:29:16,910 All of which, early on, are a distraction 630 00:29:16,910 --> 00:29:20,322 to what are interesting and genuinely useful ideas. 631 00:29:20,322 --> 00:29:22,280 So let's take a quick glance at the environment 632 00:29:22,280 --> 00:29:24,180 here, so that you know what awaits. 633 00:29:24,180 --> 00:29:28,060 And in fact, among the games we can play are a few programs written 634 00:29:28,060 --> 00:29:30,810 by CS50's own former students. 635 00:29:30,810 --> 00:29:36,200 One of them, myself, I'll be this one written in graduate school for me. 636 00:29:36,200 --> 00:29:39,030 >> If I could take one volunteer who's willing to play 637 00:29:39,030 --> 00:29:40,420 a game for the very first time. 638 00:29:40,420 --> 00:29:40,920 Sure. 639 00:29:40,920 --> 00:29:41,690 Come on up. 640 00:29:41,690 --> 00:29:42,565 What's your name? 641 00:29:42,565 --> 00:29:43,372 >> AUDIENCE: Angela. 642 00:29:43,372 --> 00:29:44,830 DAVID J. MALAN: Angela, come on up. 643 00:29:44,830 --> 00:29:47,220 So Scratch has been out for a few years. 644 00:29:47,220 --> 00:29:49,960 And when I was in graduate school, I was cross registered at MIT, 645 00:29:49,960 --> 00:29:53,392 taking professor Mitchel Resnick's course on educational technologies. 646 00:29:53,392 --> 00:29:56,350 And we were among the very first students in the world to actually beta 647 00:29:56,350 --> 00:29:57,120 test Scratch. 648 00:29:57,120 --> 00:30:00,090 And my project was what Angela has now graciously volunteered 649 00:30:00,090 --> 00:30:02,060 to play called Oscartime. 650 00:30:02,060 --> 00:30:04,507 >> So I'm going to go ahead and double click the icon here. 651 00:30:04,507 --> 00:30:07,590 It's going to open up a programming environment that we'll soon dive into. 652 00:30:07,590 --> 00:30:09,720 I'm going to full-screen it for Angela, here. 653 00:30:09,720 --> 00:30:12,490 I'm going to hit the green flag in just a moment. 654 00:30:12,490 --> 00:30:15,130 And then a whole lot of trash is going to fall from the sky. 655 00:30:15,130 --> 00:30:17,830 And you're going to use the mouse here to actually drag and drop 656 00:30:17,830 --> 00:30:20,169 the trash into Oscar's trash cans. 657 00:30:20,169 --> 00:30:23,210 So if you want to go ahead and click the green flag, the game will begin. 658 00:30:23,210 --> 00:30:26,890 >> [MUSIC PLAYING] 659 00:30:26,890 --> 00:30:29,980 >> Oh, I love trash. 660 00:30:29,980 --> 00:30:34,840 Anything dirty or dingy or dusty. 661 00:30:34,840 --> 00:30:39,300 Anything ragged or rotten, or rusty. 662 00:30:39,300 --> 00:30:43,155 Yes, I love trash. 663 00:30:43,155 --> 00:30:45,530 If you really want to see something trashy, look at this. 664 00:30:45,530 --> 00:30:49,570 I have here a sneaker that's tattered and worn. 665 00:30:49,570 --> 00:30:53,750 It's all full of holes holds and the laces are torn. 666 00:30:53,750 --> 00:30:57,590 A gift from my mother the day I was born. 667 00:30:57,590 --> 00:30:59,434 I love it because it's-- 668 00:30:59,434 --> 00:31:02,600 DAVID J. MALAN: --green these days just be throwing everything in the trash. 669 00:31:02,600 --> 00:31:04,312 And so what one of CS50's own staff did-- 670 00:31:04,312 --> 00:31:06,270 Jordan, who you might meet today-- has actually 671 00:31:06,270 --> 00:31:08,030 updated this for today's times. 672 00:31:08,030 --> 00:31:10,800 And so allow me to open up a remix instead for Angela. 673 00:31:10,800 --> 00:31:13,600 And we'll play this instead for a few moments where now you're 674 00:31:13,600 --> 00:31:16,600 going to have to decide between whether to throw something in the trash, 675 00:31:16,600 --> 00:31:19,050 or recycle it or compost it. 676 00:31:19,050 --> 00:31:21,280 So there's a bit of pressure on you to get 677 00:31:21,280 --> 00:31:28,040 this right in front of your 392 to 497 classmates here in the hall, 678 00:31:28,040 --> 00:31:28,724 if you would. 679 00:31:28,724 --> 00:31:29,390 [VIDEO PLAYBACK] 680 00:31:29,390 --> 00:31:32,540 [MUSIC PLAYING] 681 00:31:32,540 --> 00:31:36,280 -Oh I love trash. 682 00:31:36,280 --> 00:31:40,840 Anything dirty or dingy or dusty. 683 00:31:40,840 --> 00:31:44,910 Anything ragged or rotten or rusty. 684 00:31:44,910 --> 00:31:48,830 Yes, I love trash. 685 00:31:48,830 --> 00:31:51,480 >> If you really want to see something trashy, look at this. 686 00:31:51,480 --> 00:31:55,540 I have here a sneaker that's tattered and worn. 687 00:31:55,540 --> 00:31:59,440 It's all full of holes and the laces are torn. 688 00:31:59,440 --> 00:32:03,762 A gift from my mother the day I was born. 689 00:32:03,762 --> 00:32:07,630 I love it because it's trash. 690 00:32:07,630 --> 00:32:11,570 >> Oh, I love trash. 691 00:32:11,570 --> 00:32:15,512 Anything dirty, or dingy, or dusty. 692 00:32:15,512 --> 00:32:20,200 Anything ragged or rotten or rusty. 693 00:32:20,200 --> 00:32:23,856 Yes, I love trash. 694 00:32:23,856 --> 00:32:26,246 Here's some more rotten stuff. 695 00:32:26,246 --> 00:32:28,240 I have here some newspaper-- 696 00:32:28,240 --> 00:32:28,889 >> [END PLAYBACK] 697 00:32:28,889 --> 00:32:30,680 DAVID J. MALAN: --are actually compostable. 698 00:32:30,680 --> 00:32:32,790 But thank you to our volunteer, Angela. 699 00:32:32,790 --> 00:32:37,920 We have a stress ball for you here as well. 700 00:32:37,920 --> 00:32:38,790 So thank you. 701 00:32:38,790 --> 00:32:40,250 >> So this one was written by me. 702 00:32:40,250 --> 00:32:44,324 But now one by an actual former student who implemented this, which is a game. 703 00:32:44,324 --> 00:32:46,490 All in this language called Scratch, that we'll soon 704 00:32:46,490 --> 00:32:47,850 peel back the layers of. 705 00:32:47,850 --> 00:32:49,940 But if we'd like-- how about another volunteer? 706 00:32:49,940 --> 00:32:50,440 Right. 707 00:32:50,440 --> 00:32:50,970 >> Come on up. 708 00:32:50,970 --> 00:32:52,070 What's your name? 709 00:32:52,070 --> 00:32:52,570 Glance? 710 00:32:52,570 --> 00:32:53,280 Lance. 711 00:32:53,280 --> 00:32:54,082 Lance, come on up. 712 00:32:54,082 --> 00:32:54,790 Nice to meet you. 713 00:32:54,790 --> 00:32:56,170 Come on this way. 714 00:32:56,170 --> 00:32:59,940 So this one might have a theme familiar to some of you. 715 00:32:59,940 --> 00:33:02,180 But you'll see too that there can be interactivity, 716 00:33:02,180 --> 00:33:05,242 whereby you could actually be the role of the character moving around. 717 00:33:05,242 --> 00:33:05,950 Nice to meet you. 718 00:33:05,950 --> 00:33:06,470 David. 719 00:33:06,470 --> 00:33:10,464 >> I give you, Pikachu. 720 00:33:10,464 --> 00:33:12,380 Instructions will about to come on the screen. 721 00:33:12,380 --> 00:33:16,070 But in short, you're going to want to catch the tasty stuff, 722 00:33:16,070 --> 00:33:18,827 and avoid the bombs and other things. 723 00:33:18,827 --> 00:33:19,910 With the cursors entirely. 724 00:33:19,910 --> 00:33:21,320 So hit the space bar. 725 00:33:21,320 --> 00:33:21,820 -Pikachu. 726 00:33:21,820 --> 00:33:23,480 DAVID J. MALAN: Catch the stuff on the left, 727 00:33:23,480 --> 00:33:24,938 don't catch the stuff on the right. 728 00:33:24,938 --> 00:33:27,576 729 00:33:27,576 --> 00:34:44,540 >> [MUSIC PLAYING] 730 00:34:44,540 --> 00:34:46,332 >> So one last one here. 731 00:34:46,332 --> 00:34:48,040 If we could have one more volunteer here. 732 00:34:48,040 --> 00:34:50,760 We thought we'd recreate something from-- in the yellow shirt-- 733 00:34:50,760 --> 00:34:53,110 from Wednesday. 734 00:34:53,110 --> 00:34:54,540 What is your name? 735 00:34:54,540 --> 00:34:57,090 Mary, come on up Mary. 736 00:34:57,090 --> 00:35:01,340 >> And recall on Wednesday we introduced the notion of binary, and binary bulbs. 737 00:35:01,340 --> 00:35:03,930 This is actually now an implementation of that same interface 738 00:35:03,930 --> 00:35:07,360 that we had on the iPad with the light bulbs, but here digitally rendered. 739 00:35:07,360 --> 00:35:11,220 And rather than do a stress ball-- nice to meet you, David. 740 00:35:11,220 --> 00:35:14,600 We brought a few light bulbs from Cambridge. 741 00:35:14,600 --> 00:35:18,650 >> If you can, clicking on those bulbs to turn them on and off, 742 00:35:18,650 --> 00:35:29,510 come up with the binary representation of say 256. 743 00:35:29,510 --> 00:35:32,500 And you'll see in the middle, the current tally. 744 00:35:32,500 --> 00:35:33,690 So that one's on. 745 00:35:33,690 --> 00:35:34,810 So the leftmost bit is on. 746 00:35:34,810 --> 00:35:36,016 >> MARY: Yeah, [INAUDIBLE] 747 00:35:36,016 --> 00:35:39,292 748 00:35:39,292 --> 00:35:41,280 >> DAVID J. MALAN: Well, so we have just-- oh. 749 00:35:41,280 --> 00:35:42,780 So this is the 128 column. 750 00:35:42,780 --> 00:35:44,460 So we're up to 128. 751 00:35:44,460 --> 00:35:46,769 We got to get to 256. 752 00:35:46,769 --> 00:35:48,560 And you can tinker on and off, no big deal. 753 00:35:48,560 --> 00:35:53,700 Or you can hit that 128 more times if you want. 754 00:35:53,700 --> 00:35:56,310 >> All right, good. 755 00:35:56,310 --> 00:35:58,090 24. 756 00:35:58,090 --> 00:35:59,790 Yeah, getting closer. 757 00:35:59,790 --> 00:36:02,105 Closer! 758 00:36:02,105 --> 00:36:05,980 Oh, what's the problem then? 759 00:36:05,980 --> 00:36:07,510 So what's the issue? 760 00:36:07,510 --> 00:36:10,040 >> So what do we need to solve this problem? 761 00:36:10,040 --> 00:36:11,060 So we need another bit. 762 00:36:11,060 --> 00:36:12,770 And this is perfectly reasonable in reality, right? 763 00:36:12,770 --> 00:36:15,800 If you want to count from the number 1 to 2 to 3 to 4 to 5, 6, 7, 8, 9 764 00:36:15,800 --> 00:36:18,880 to actually roll over to 10, you're going to need an additional bit. 765 00:36:18,880 --> 00:36:21,240 So let's actually rewind here, and come up 766 00:36:21,240 --> 00:36:23,790 with-- that was obviously meant to be a set up. 767 00:36:23,790 --> 00:36:25,590 >> You can't do 256 with just a bulb. 768 00:36:25,590 --> 00:36:29,290 So how about simply the number 50? 769 00:36:29,290 --> 00:36:29,977 Number 50. 770 00:36:29,977 --> 00:36:34,550 771 00:36:34,550 --> 00:36:35,100 Excellent. 772 00:36:35,100 --> 00:36:39,050 A big round of applause for Mary and hers as well. 773 00:36:39,050 --> 00:36:41,840 Thank you. 774 00:36:41,840 --> 00:36:45,570 >> So this topic-- intentional as that was-- will actually recur. 775 00:36:45,570 --> 00:36:50,020 The largest value that you can represent with eight bits, or one byte, 776 00:36:50,020 --> 00:36:51,750 is indeed 256. 777 00:36:51,750 --> 00:36:55,770 But not if you start counting from 0, as we 778 00:36:55,770 --> 00:36:58,060 seem to keep doing by having all of those bits off. 779 00:36:58,060 --> 00:37:01,530 But now let's dive into the underlying implementation of this environment, 780 00:37:01,530 --> 00:37:03,200 and tease apart some of these ideas. 781 00:37:03,200 --> 00:37:06,350 >> So in a moment we're about to see a few different programming fundamentals. 782 00:37:06,350 --> 00:37:08,080 The first of which we'll call statement. 783 00:37:08,080 --> 00:37:09,360 Sort of verbs, if you will. 784 00:37:09,360 --> 00:37:09,960 Actions. 785 00:37:09,960 --> 00:37:11,180 Things that should be done. 786 00:37:11,180 --> 00:37:13,430 >> And in a moment you'll see blocks that look like this. 787 00:37:13,430 --> 00:37:14,940 Say "hello world," for instance. 788 00:37:14,940 --> 00:37:16,330 Or wait one second. 789 00:37:16,330 --> 00:37:17,834 Or play sound meow. 790 00:37:17,834 --> 00:37:20,500 And indeed the environment in which we're going to be doing this 791 00:37:20,500 --> 00:37:21,610 is called Scratch. 792 00:37:21,610 --> 00:37:25,060 >> And if I pull up Scratch without preloading any actual code, 793 00:37:25,060 --> 00:37:27,830 let's take a quick look at this user interface, so to speak. 794 00:37:27,830 --> 00:37:29,730 The controls with which we interact. 795 00:37:29,730 --> 00:37:32,840 On the top left here of the screen, below the menus, 796 00:37:32,840 --> 00:37:34,650 we have the stage, so to speak. 797 00:37:34,650 --> 00:37:36,550 So Scratch is what we'll call Sprite. 798 00:37:36,550 --> 00:37:37,520 It's a character. 799 00:37:37,520 --> 00:37:40,660 >> And he can be controlled by writing programs against him. 800 00:37:40,660 --> 00:37:43,950 And he'll be able to move up and down and left and right in this environment, 801 00:37:43,950 --> 00:37:46,075 not just by moving the mouse, but programmatically. 802 00:37:46,075 --> 00:37:48,930 I can tell him walk right, walk left, up, down or the like. 803 00:37:48,930 --> 00:37:51,440 And I can introduce other sprites or characters as well. 804 00:37:51,440 --> 00:37:54,616 >> Indeed, on the bottom here is where you'll see your list of sprites. 805 00:37:54,616 --> 00:37:56,865 At the moment, I just have one, but I can create more, 806 00:37:56,865 --> 00:37:58,880 and they'll appear exactly down there. 807 00:37:58,880 --> 00:38:02,630 So if you rewind for a moment, like Oscartime-- for instance, Oscar, 808 00:38:02,630 --> 00:38:04,590 on the left, the trash can, was a sprite. 809 00:38:04,590 --> 00:38:07,450 And the thing in the middle, the recycling bin, was another sprite. 810 00:38:07,450 --> 00:38:09,300 And the compost bin was another sprite. 811 00:38:09,300 --> 00:38:11,790 And every piece of garbage or recyclables 812 00:38:11,790 --> 00:38:14,590 that was falling from the sky is also a sprite, each of which 813 00:38:14,590 --> 00:38:16,150 was programmed individually. 814 00:38:16,150 --> 00:38:17,040 >> How do you program? 815 00:38:17,040 --> 00:38:20,180 Well, over here on the right hand side is the scripts area. 816 00:38:20,180 --> 00:38:22,930 And this is where we can drag and drop puzzle pieces. 817 00:38:22,930 --> 00:38:26,066 In a week, it's going to be where we equivalently write code 818 00:38:26,066 --> 00:38:28,940 with more of a keyboard, but for today it'll be dragging and dropping 819 00:38:28,940 --> 00:38:31,680 puzzle pieces, the palettes for which can all 820 00:38:31,680 --> 00:38:33,190 be found here right in the middle. 821 00:38:33,190 --> 00:38:35,190 Indeed, in the middle here there's a whole bunch 822 00:38:35,190 --> 00:38:37,910 of categories of puzzle pieces or blocks. 823 00:38:37,910 --> 00:38:42,500 One's related to motion, look, sound, a pen going up and down, 824 00:38:42,500 --> 00:38:43,860 data, events control. 825 00:38:43,860 --> 00:38:45,654 Not quite sure yet what all of these mean, 826 00:38:45,654 --> 00:38:47,820 but you'll see that they've been nicely categorized. 827 00:38:47,820 --> 00:38:50,680 And to write a program in Scratch, let's do exactly that. 828 00:38:50,680 --> 00:38:53,480 >> I'm going to start off under Events, and drag this one here. 829 00:38:53,480 --> 00:38:55,470 When green flag clicked. 830 00:38:55,470 --> 00:38:56,704 Now why that one? 831 00:38:56,704 --> 00:38:59,120 Well recall that our volunteers came up, the first thing I 832 00:38:59,120 --> 00:39:02,017 or they did was click that green flag in the top right hand corner. 833 00:39:02,017 --> 00:39:03,600 And that just means start the program. 834 00:39:03,600 --> 00:39:06,560 >> So when that event happens, what do I want to do? 835 00:39:06,560 --> 00:39:10,070 I'm going to go under Looks, and I'm going to do "say hello." 836 00:39:10,070 --> 00:39:14,000 And I'm going to change this and say something like "hello Yale." 837 00:39:14,000 --> 00:39:16,970 And now I'm going to zoom out, click the green flag, 838 00:39:16,970 --> 00:39:19,050 and voila, I've written a program. 839 00:39:19,050 --> 00:39:20,990 It's not all that exciting just yet, but this 840 00:39:20,990 --> 00:39:23,195 is exactly where each of those author started, 841 00:39:23,195 --> 00:39:25,740 both with Pikachu, and the binary bulbs, and Oscartime, 842 00:39:25,740 --> 00:39:26,890 and so many more examples. 843 00:39:26,890 --> 00:39:29,150 >> You start super simple, and then you start to layer, 844 00:39:29,150 --> 00:39:31,046 and add on features and functionality. 845 00:39:31,046 --> 00:39:32,920 So what are these layers going to consist of? 846 00:39:32,920 --> 00:39:36,086 Well, beyond statements, we'll also have things that are little more fancily 847 00:39:36,086 --> 00:39:38,910 called Boolean Expressions, after someone named Bool. 848 00:39:38,910 --> 00:39:42,820 And a Boolean expression is simply an expression that's either true or false, 849 00:39:42,820 --> 00:39:45,740 yes or no, 1 or 0. 850 00:39:45,740 --> 00:39:47,480 >> Any polar opposites like that. 851 00:39:47,480 --> 00:39:48,902 It's either true or not. 852 00:39:48,902 --> 00:39:51,360 But we're also going to see ones that might look like this. 853 00:39:51,360 --> 00:39:52,925 So for instance, is the mouse down? 854 00:39:52,925 --> 00:39:54,550 They're sort of questions, if you will. 855 00:39:54,550 --> 00:39:57,650 >> The mouse is either down, true or it's not, false. 856 00:39:57,650 --> 00:39:59,990 1 or 0, if you will, tends to be the mapping. 857 00:39:59,990 --> 00:40:01,740 True is 1, false is 0. 858 00:40:01,740 --> 00:40:03,740 Well what about less than this? 859 00:40:03,740 --> 00:40:05,400 Or so, is this less than this? 860 00:40:05,400 --> 00:40:06,650 That's a question of sorts. 861 00:40:06,650 --> 00:40:09,140 >> And if you put two numbers in there, either x 862 00:40:09,140 --> 00:40:12,010 is going to be less than y or equal to y, or greater than y, 863 00:40:12,010 --> 00:40:14,635 but this block we'll see, is just going to answer the question, 864 00:40:14,635 --> 00:40:15,810 is this less than that? 865 00:40:15,810 --> 00:40:17,650 We might also see something like this. 866 00:40:17,650 --> 00:40:18,790 Touching mouse pointers. 867 00:40:18,790 --> 00:40:21,610 So in Scratch, you can ask the question, is the Sprite 868 00:40:21,610 --> 00:40:22,800 touching the mouse pointer? 869 00:40:22,800 --> 00:40:26,040 Other words, is the cursor hovering over the cap, or the equivalent? 870 00:40:26,040 --> 00:40:28,100 >> We'll see anding things together. 871 00:40:28,100 --> 00:40:30,970 You can ask two questions, and make sure that both of them 872 00:40:30,970 --> 00:40:34,920 give you yes or true answers before making a decision to do something. 873 00:40:34,920 --> 00:40:36,709 But then how do you make decisions? 874 00:40:36,709 --> 00:40:38,000 Well, we have these conditions. 875 00:40:38,000 --> 00:40:40,041 >> And we saw this in our example of the phone book. 876 00:40:40,041 --> 00:40:41,900 Looking to the left or right for Mike Smith. 877 00:40:41,900 --> 00:40:45,140 And in the condition, you do something potentially, 878 00:40:45,140 --> 00:40:47,240 if a Boolean expression is true. 879 00:40:47,240 --> 00:40:48,720 >> And indeed, notice the shapes now. 880 00:40:48,720 --> 00:40:52,250 There's this placeholder right now on the overhead where we can fit-- 881 00:40:52,250 --> 00:40:54,532 if I rewind one slide-- that shape. 882 00:40:54,532 --> 00:40:55,740 It's not quite the same size. 883 00:40:55,740 --> 00:40:58,400 And indeed, you'll see that Scratch resizes things dynamically 884 00:40:58,400 --> 00:41:01,479 to fit puzzle pieces, but the shape is what's important. 885 00:41:01,479 --> 00:41:03,270 This thing looks like that, and indeed it's 886 00:41:03,270 --> 00:41:05,410 roughly the same shape that should fit in there. 887 00:41:05,410 --> 00:41:09,520 And if we want to do something this way or that way, if or else, 888 00:41:09,520 --> 00:41:12,080 we have this puzzle piece in Scratch as well. 889 00:41:12,080 --> 00:41:17,450 >> Now suppose you wanted to do if, else if, or else. 890 00:41:17,450 --> 00:41:20,120 In other words, a three-way fork in the road. 891 00:41:20,120 --> 00:41:22,656 Well what can you do just by glancing at this? 892 00:41:22,656 --> 00:41:25,030 I can take this puzzle piece, and it doesn't seem to fit, 893 00:41:25,030 --> 00:41:27,670 but again, Scratch is going to re-size nicely for us. 894 00:41:27,670 --> 00:41:29,940 I could start to layer these things together. 895 00:41:29,940 --> 00:41:32,900 >> So now I have a three-way fork if this is true, do this. 896 00:41:32,900 --> 00:41:36,560 Else if this other thing is true, go this way, else go this other way. 897 00:41:36,560 --> 00:41:39,200 And in The Muppet Movie, the fork in the road, so to speak, 898 00:41:39,200 --> 00:41:42,610 between Yale or Stanford, was exactly that, just two conditions. 899 00:41:42,610 --> 00:41:45,190 Either go this way, else go that way. 900 00:41:45,190 --> 00:41:46,940 >> Well, loops also exist in programming. 901 00:41:46,940 --> 00:41:49,100 And we've used these already in class and in pseudocode code, 902 00:41:49,100 --> 00:41:51,060 and surely in those Scratch programs forever. 903 00:41:51,060 --> 00:41:53,730 Scratch has this puzzle piece that will just let you do something forever. 904 00:41:53,730 --> 00:41:55,688 And sometimes you want to do something forever. 905 00:41:55,688 --> 00:41:58,810 It's not necessarily a bug, it's because you want a clock to keep going, 906 00:41:58,810 --> 00:42:00,730 or a game to keep playing. 907 00:42:00,730 --> 00:42:04,800 Or you can specify a finite number of steps, as with this repeat block here, 908 00:42:04,800 --> 00:42:06,550 which will repeat something 10 times. 909 00:42:06,550 --> 00:42:08,560 We can set variables, we'll soon see. 910 00:42:08,560 --> 00:42:12,300 And with variables, similar in spirit to algebra, like x, or y, or z. 911 00:42:12,300 --> 00:42:16,390 It's something symbolic that can store some value, some piece of information, 912 00:42:16,390 --> 00:42:18,320 that you might want to remember for later. 913 00:42:18,320 --> 00:42:21,080 >> Best example of this might be a game where you have a score, 914 00:42:21,080 --> 00:42:22,080 like in Pikachu. 915 00:42:22,080 --> 00:42:25,180 How many pieces of cake and whatnot did you catch? 916 00:42:25,180 --> 00:42:29,340 Well, that might be a variable called score that starts at 0. 917 00:42:29,340 --> 00:42:32,400 And then every time we caught a piece of cake or candy, or the like, 918 00:42:32,400 --> 00:42:33,720 it gets incremented. 919 00:42:33,720 --> 00:42:35,990 It gets added to one at a time. 920 00:42:35,990 --> 00:42:38,450 And so a variable stores a piece of information like that. 921 00:42:38,450 --> 00:42:41,450 Then there's arrays, and we'll come back to these in a week or two time, 922 00:42:41,450 --> 00:42:44,900 but an array is kind of like an inventory or a satchel, inside 923 00:42:44,900 --> 00:42:46,940 of which you can put virtual things. 924 00:42:46,940 --> 00:42:49,852 It allows you to store more than one piece of information. 925 00:42:49,852 --> 00:42:51,810 And that might be useful if in the game, you're 926 00:42:51,810 --> 00:42:53,630 sort of walking around picking things up. 927 00:42:53,630 --> 00:42:55,879 And maybe you want to keep all of those pieces of cake 928 00:42:55,879 --> 00:42:58,260 around, and not just eat them one after another. 929 00:42:58,260 --> 00:43:00,010 And then there's a fancier construct we'll 930 00:43:00,010 --> 00:43:02,932 come to called functions or procedures. 931 00:43:02,932 --> 00:43:04,640 And though we're going faster here, we'll 932 00:43:04,640 --> 00:43:07,345 see that these are a very natural solution to problems 933 00:43:07,345 --> 00:43:08,470 that we're going encounter. 934 00:43:08,470 --> 00:43:10,220 As our programs start getting bigger we'll 935 00:43:10,220 --> 00:43:12,640 start to notice patterns in the code that we're writing, 936 00:43:12,640 --> 00:43:14,556 the puzzle pieces we're dragging and dropping. 937 00:43:14,556 --> 00:43:18,240 And as soon as you notice yourself doing something again and again, or worse yet 938 00:43:18,240 --> 00:43:21,400 copying and pasting programming code that you've written, 939 00:43:21,400 --> 00:43:23,612 that's probably an opportunity to factor out 940 00:43:23,612 --> 00:43:25,820 whatever you keep copying and pasting, and putting it 941 00:43:25,820 --> 00:43:27,430 in something called a "function." 942 00:43:27,430 --> 00:43:29,690 But more on those in much more detail before long. 943 00:43:29,690 --> 00:43:31,314 >> And then there's even fancier features. 944 00:43:31,314 --> 00:43:34,100 For those of you more comfortable, or taking APCS or equivalent, 945 00:43:34,100 --> 00:43:37,600 Scratch actually supports things like threads and events and more. 946 00:43:37,600 --> 00:43:39,840 So realize that it has a fairly high ceiling, 947 00:43:39,840 --> 00:43:42,540 even though it's also very broadly accessible to folks 948 00:43:42,540 --> 00:43:44,460 who have never programmed before. 949 00:43:44,460 --> 00:43:47,130 So indeed, let's take a look at a simple program or two. 950 00:43:47,130 --> 00:43:49,920 >> We already looked at how we might say hello with Scratch. 951 00:43:49,920 --> 00:43:52,800 Let me go ahead and open up a little more interesting program 952 00:43:52,800 --> 00:43:54,100 that I wrote in advance. 953 00:43:54,100 --> 00:43:56,430 And this one's called Pet the Cat. 954 00:43:56,430 --> 00:43:58,954 All of these programs will be available on CS50's website. 955 00:43:58,954 --> 00:43:59,870 Indeed, already there. 956 00:43:59,870 --> 00:44:01,190 >> So you can download them, and play with them, 957 00:44:01,190 --> 00:44:03,850 and with Problem Set 0, which is also on the course's website, 958 00:44:03,850 --> 00:44:05,516 you're encouraged to walk through these. 959 00:44:05,516 --> 00:44:07,820 And moreover, we have a number of walk-through videos 960 00:44:07,820 --> 00:44:10,951 online in which I and CS50's team truly walk 961 00:44:10,951 --> 00:44:14,200 through each of these examples at a much slower pace, a very fast forwardable, 962 00:44:14,200 --> 00:44:18,530 or rewindable pace, so that you can walk through these at your leisure as well. 963 00:44:18,530 --> 00:44:20,330 So here's Scratch on the left. 964 00:44:20,330 --> 00:44:22,920 Here's a program at the right that I've already pre-made. 965 00:44:22,920 --> 00:44:24,880 So let me zoom in on this. 966 00:44:24,880 --> 00:44:28,780 And could someone in English, knowing what you know, just from now as 967 00:44:28,780 --> 00:44:31,650 to how Scratch works, sort of say in an English phrase or sentence, 968 00:44:31,650 --> 00:44:35,450 what does this program apparently do? 969 00:44:35,450 --> 00:44:36,836 >> Yeah, in orange shirt. 970 00:44:36,836 --> 00:44:40,804 >> AUDIENCE: [INAUDIBLE] 971 00:44:40,804 --> 00:44:41,796 972 00:44:41,796 --> 00:44:44,980 >> DAVID J. MALAN: Yeah, if your cursor is on Scratch the cat, 973 00:44:44,980 --> 00:44:46,220 play a meowing sound. 974 00:44:46,220 --> 00:44:47,870 But notice how we express that. 975 00:44:47,870 --> 00:44:49,980 There's apparently a loop there, forever. 976 00:44:49,980 --> 00:44:53,000 And then there's a condition, the if expression. 977 00:44:53,000 --> 00:44:55,090 And collectively, what do those mean? 978 00:44:55,090 --> 00:44:57,210 It means this program is just always running, 979 00:44:57,210 --> 00:44:59,510 and it's just always waiting and watching and listening 980 00:44:59,510 --> 00:45:01,730 for me to move my mouse over the cat. 981 00:45:01,730 --> 00:45:04,810 >> Because each time I do that, as you propose, it's going to do this. 982 00:45:04,810 --> 00:45:06,475 Let me start the program. 983 00:45:06,475 --> 00:45:08,350 Nothing seems to be happening, but notice how 984 00:45:08,350 --> 00:45:10,152 it's highlighted now in a yellow line. 985 00:45:10,152 --> 00:45:11,360 That just means it's running. 986 00:45:11,360 --> 00:45:13,770 And because there's a forever loop, it's still running. 987 00:45:13,770 --> 00:45:19,610 >> So let me move my cursor over Scratch. [MEOW] [MEOW] And if I move it off, 988 00:45:19,610 --> 00:45:25,444 [MEOW] now it stops, but the program's still running. [MEOW] And so, adorable. 989 00:45:25,444 --> 00:45:28,550 [MEOW] So let's open up slightly more advanced 990 00:45:28,550 --> 00:45:32,620 example called Don't Pet the Cat. 991 00:45:32,620 --> 00:45:35,805 >> And now let's see what happens here. [MEOW] Meowing. 992 00:45:35,805 --> 00:45:39,297 So it's a little on auto pilot, if you will. 993 00:45:39,297 --> 00:45:39,880 --pet the cat. 994 00:45:39,880 --> 00:45:42,820 I wonder why. 995 00:45:42,820 --> 00:45:45,389 [ROAR] [MEOW] So how did this work? 996 00:45:45,389 --> 00:45:47,930 Well, you can kind of reason through it intuitively, perhaps. 997 00:45:47,930 --> 00:45:49,346 >> But let's look at the actual code. 998 00:45:49,346 --> 00:45:51,819 So again, when the green flag is clicked, do this forever. 999 00:45:51,819 --> 00:45:53,110 What do you want to do forever? 1000 00:45:53,110 --> 00:45:56,150 Well, if touching mouse pointer, then play 1001 00:45:56,150 --> 00:46:00,270 a sound that's apparently called Lion 5, that's inside of this project, else 1002 00:46:00,270 --> 00:46:03,010 play sound meow, and then wait two seconds, so 1003 00:46:03,010 --> 00:46:04,510 that it's not meowing incessantly. 1004 00:46:04,510 --> 00:46:07,650 In fact, you can very quickly start to annoy yourself and your roommates. 1005 00:46:07,650 --> 00:46:08,690 >> Let's remove this block. 1006 00:46:08,690 --> 00:46:10,580 And notice what's nice about Scratch. 1007 00:46:10,580 --> 00:46:13,070 Things just kind of drag and drop and interlock. 1008 00:46:13,070 --> 00:46:14,980 So again, it grows to fill what you want. 1009 00:46:14,980 --> 00:46:20,118 But if I remove this, and then hit play, [COMPUTER BLIP SOUND] 1010 00:46:20,118 --> 00:46:22,904 >> --it's kind of tripping over itself, because it's literally 1011 00:46:22,904 --> 00:46:23,820 doing what I'm saying. 1012 00:46:23,820 --> 00:46:27,080 It's saying forever play this sound, but I'm not giving it a chance to finish. 1013 00:46:27,080 --> 00:46:28,205 And so that would be a bug. 1014 00:46:28,205 --> 00:46:30,700 And that's why we had this thing in here now. 1015 00:46:30,700 --> 00:46:34,030 So let's actually start from scratch-- sort of pun slightly intended-- 1016 00:46:34,030 --> 00:46:36,450 in which we now have the cat move. 1017 00:46:36,450 --> 00:46:38,130 >> So I'm going to do this on the fly. 1018 00:46:38,130 --> 00:46:40,910 I'm going to zoom in here, just to get me started on Events. 1019 00:46:40,910 --> 00:46:42,000 And green flag clicked. 1020 00:46:42,000 --> 00:46:43,410 And there's other ways to start the scripts. 1021 00:46:43,410 --> 00:46:44,920 We're going to keep it simple here. 1022 00:46:44,920 --> 00:46:48,049 >> And now I'm going to go ahead and go under Control. 1023 00:46:48,049 --> 00:46:50,590 And again, if you forget where things are, just click around, 1024 00:46:50,590 --> 00:46:52,048 and eventually you find them again. 1025 00:46:52,048 --> 00:46:53,680 So I want to forever do what? 1026 00:46:53,680 --> 00:46:58,650 I want to use the motion block that I know exists, move 10 steps. 1027 00:46:58,650 --> 00:47:02,016 >> So let's see what happens here if I play this game. 1028 00:47:02,016 --> 00:47:03,390 Thankfully it doesn't go too far. 1029 00:47:03,390 --> 00:47:05,190 I can still kind of grab him by the tail and pull him back. 1030 00:47:05,190 --> 00:47:07,860 But the program's still running, so he's kind of fighting me. 1031 00:47:07,860 --> 00:47:10,870 But it'd be kind of nice if I conditionally fix this in code. 1032 00:47:10,870 --> 00:47:12,800 >> Because this is not-- actually this is really 1033 00:47:12,800 --> 00:47:15,770 not a fun game for anyone of any age. 1034 00:47:15,770 --> 00:47:18,915 So let's try to fix this by having some kind of conditions. 1035 00:47:18,915 --> 00:47:21,670 So I'm going to go under Control, and then if. 1036 00:47:21,670 --> 00:47:22,660 I like this idea. 1037 00:47:22,660 --> 00:47:27,470 So after moving 10 steps, if-- let me sense where I am. 1038 00:47:27,470 --> 00:47:30,799 I'm going to go under Sensing, and then it looks I can go here. 1039 00:47:30,799 --> 00:47:31,840 row to the shape matches. 1040 00:47:31,840 --> 00:47:34,380 >> Size doesn't, but it's going to grow to fill. 1041 00:47:34,380 --> 00:47:35,984 And now this is a little menu. 1042 00:47:35,984 --> 00:47:38,650 And now mouse pointer-- I don't want the mouse, I want the edge. 1043 00:47:38,650 --> 00:47:41,700 So Scratch is smart enough to know when a sprite is touching the edge. 1044 00:47:41,700 --> 00:47:44,360 What do I want him to actually do? 1045 00:47:44,360 --> 00:47:46,025 >> Let me go ahead and change motion. 1046 00:47:46,025 --> 00:47:46,940 You know what? 1047 00:47:46,940 --> 00:47:49,242 I'm going to have him turn around. 1048 00:47:49,242 --> 00:47:51,200 So at 15 degrees isn't really going to help me. 1049 00:47:51,200 --> 00:47:53,990 I want him to turn around and go the other way. 1050 00:47:53,990 --> 00:47:57,740 >> So let's see what happens here, if I hit Play now. 1051 00:47:57,740 --> 00:48:01,520 OK, kind of stupid looking, but it's doing exactly what I said. 1052 00:48:01,520 --> 00:48:03,540 And it's rotating the whole sprite. 1053 00:48:03,540 --> 00:48:04,900 Now it turns out I can fix this. 1054 00:48:04,900 --> 00:48:06,691 And I didn't know how to fix this at first. 1055 00:48:06,691 --> 00:48:09,190 I kind had to futz around and see the best way to do this. 1056 00:48:09,190 --> 00:48:12,630 But if I go to-- let's see, motion. 1057 00:48:12,630 --> 00:48:14,050 Oh, I found this. 1058 00:48:14,050 --> 00:48:15,660 Actually, Set Rotation Style. 1059 00:48:15,660 --> 00:48:18,431 Left, right, or don't rotate, or all around. 1060 00:48:18,431 --> 00:48:19,930 And it turns out that's what I want. 1061 00:48:19,930 --> 00:48:22,920 And I'm going to put this is not my loop, because I don't need to set 1062 00:48:22,920 --> 00:48:24,487 the rotation style multiple times. 1063 00:48:24,487 --> 00:48:27,570 I'm going put it at the very top of this program so that it gets set once, 1064 00:48:27,570 --> 00:48:28,670 and then remembers. 1065 00:48:28,670 --> 00:48:30,340 And now I'm going to try this again. 1066 00:48:30,340 --> 00:48:32,520 Let me stop the program. 1067 00:48:32,520 --> 00:48:34,050 >> And now that fixed that bug. 1068 00:48:34,050 --> 00:48:35,700 So I'm iteratively improving upon this. 1069 00:48:35,700 --> 00:48:37,900 The program is getting a little more complex and bigger, 1070 00:48:37,900 --> 00:48:40,810 but I'm taking baby steps so to speak, and small bites out of the problem 1071 00:48:40,810 --> 00:48:42,010 to get it better and better. 1072 00:48:42,010 --> 00:48:43,260 But this too, is kind of lame. 1073 00:48:43,260 --> 00:48:43,900 >> You know what? 1074 00:48:43,900 --> 00:48:49,860 Would ask someone with a really good, frightful voice like to come up? 1075 00:48:49,860 --> 00:48:51,210 Someone with a voice. 1076 00:48:51,210 --> 00:48:54,070 1077 00:48:54,070 --> 00:48:54,570 Uh, yeah. 1078 00:48:54,570 --> 00:48:55,550 Come on up. 1079 00:48:55,550 --> 00:48:57,990 In the green shirt. 1080 00:48:57,990 --> 00:49:01,530 >> So it turns out there's some other fun things, aesthetics and sounds alike. 1081 00:49:01,530 --> 00:49:02,290 Here's the meow. 1082 00:49:02,290 --> 00:49:04,000 I click on the Sounds tab. 1083 00:49:04,000 --> 00:49:08,730 [MEOW] There's the meow. [MEOW] [MEOW] [MEOW] --actually record something 1084 00:49:08,730 --> 00:49:10,310 of our own here. 1085 00:49:10,310 --> 00:49:13,120 >> So let's do exactly that. 1086 00:49:13,120 --> 00:49:17,670 Instead of using this cat sound, let's go ahead here, and what's your name? 1087 00:49:17,670 --> 00:49:18,850 Nick, nice to meet you. 1088 00:49:18,850 --> 00:49:19,350 It's David. 1089 00:49:19,350 --> 00:49:21,474 So in a moment, I'm going to hit the Record button. 1090 00:49:21,474 --> 00:49:23,240 And if you can just yell into the laptop, 1091 00:49:23,240 --> 00:49:26,140 "ouch," as though you just walked into the wall, 1092 00:49:26,140 --> 00:49:28,180 that will be much appreciated. 1093 00:49:28,180 --> 00:49:29,660 1, 2. 1094 00:49:29,660 --> 00:49:31,470 >> NICK: Ouch! 1095 00:49:31,470 --> 00:49:32,470 DAVID J. MALAN: Awesome. 1096 00:49:32,470 --> 00:49:34,410 And now can do a little editing here. 1097 00:49:34,410 --> 00:49:35,910 Going to get rid of the quiet parts. 1098 00:49:35,910 --> 00:49:37,000 And I think that's good. 1099 00:49:37,000 --> 00:49:37,690 Thank you very much. 1100 00:49:37,690 --> 00:49:38,315 >> NICK: Pleasure. 1101 00:49:38,315 --> 00:49:43,277 1102 00:49:43,277 --> 00:49:45,110 DAVID J. MALAN: I've just renamed it "ouch," 1103 00:49:45,110 --> 00:49:46,901 but now I'm going to go back to my scripts. 1104 00:49:46,901 --> 00:49:49,810 And notice there is indeed sound here. 1105 00:49:49,810 --> 00:49:53,520 And I'm going to go ahead and play the sound ouch, 1106 00:49:53,520 --> 00:49:56,991 and I'm going to do that if it's touching the edges only. 1107 00:49:56,991 --> 00:49:58,740 And then I'm going to have it turn around. 1108 00:49:58,740 --> 00:50:00,250 So let's see what happens here. 1109 00:50:00,250 --> 00:50:01,728 Let's go full screen. 1110 00:50:01,728 --> 00:50:02,394 [VIDEO PLAYBACK] 1111 00:50:02,394 --> 00:50:03,790 -Ouch! 1112 00:50:03,790 --> 00:50:05,290 Ouch! 1113 00:50:05,290 --> 00:50:06,790 Ouch! 1114 00:50:06,790 --> 00:50:07,790 Ouch! 1115 00:50:07,790 --> 00:50:09,160 Ouch! 1116 00:50:09,160 --> 00:50:10,780 Ouch! 1117 00:50:10,780 --> 00:50:11,587 Ouch! 1118 00:50:11,587 --> 00:50:12,086 Ouch! 1119 00:50:12,086 --> 00:50:12,492 >> [END PLAYBACK] 1120 00:50:12,492 --> 00:50:14,490 >> DAVID J. MALAN: So you realize that we're getting a little lucky. 1121 00:50:14,490 --> 00:50:17,110 I'm going to have him move like 100 steps at a time. 1122 00:50:17,110 --> 00:50:21,790 The effect of which now is going to be-- [COMPUTER GLITCH SOUND] So 1123 00:50:21,790 --> 00:50:22,490 within reason. 1124 00:50:22,490 --> 00:50:25,470 So an opportunity to refine that further if we really want to. 1125 00:50:25,470 --> 00:50:27,340 >> So now let's introduce another concept. 1126 00:50:27,340 --> 00:50:30,660 To let me go into one called Counting Sheep and use something 1127 00:50:30,660 --> 00:50:31,610 called a variable. 1128 00:50:31,610 --> 00:50:34,700 This is an adorable little sheep, and I changed his costume so to speak. 1129 00:50:34,700 --> 00:50:37,450 So even though the default is a cat, you can upload, you can draw, 1130 00:50:37,450 --> 00:50:40,020 you can do any number of characters on your sprite. 1131 00:50:40,020 --> 00:50:43,740 Here's a program that's going to do what in English? 1132 00:50:43,740 --> 00:50:47,110 >> Based again on just what you know now. 1133 00:50:47,110 --> 00:50:48,230 What's this program do? 1134 00:50:48,230 --> 00:50:50,740 1135 00:50:50,740 --> 00:50:53,500 Yeah, it's going to count. 1136 00:50:53,500 --> 00:50:55,842 One number at a time. 1137 00:50:55,842 --> 00:50:57,550 We have apparently have this set counter. 1138 00:50:57,550 --> 00:50:59,380 >> I don't know what that is, but maybe it's a variable. 1139 00:50:59,380 --> 00:51:00,740 It's just a container, x or y. 1140 00:51:00,740 --> 00:51:04,290 But the word counter is more descriptive than mathematician's x or y. 1141 00:51:04,290 --> 00:51:06,560 So we can use English words for things. 1142 00:51:06,560 --> 00:51:08,490 Forever, just means keep doing this. 1143 00:51:08,490 --> 00:51:10,020 >> Say counter. 1144 00:51:10,020 --> 00:51:11,270 Now where did this come from? 1145 00:51:11,270 --> 00:51:13,240 Well, it turns out that counter is a variable. 1146 00:51:13,240 --> 00:51:15,645 So it's just another puzzle piece I created in advance. 1147 00:51:15,645 --> 00:51:18,020 And even though it happens not to be the same shape here, 1148 00:51:18,020 --> 00:51:20,540 normally you would say something like hello here. 1149 00:51:20,540 --> 00:51:23,610 >> You can also drag a variable so that that's what's get said. 1150 00:51:23,610 --> 00:51:26,170 Then I wait for a second, I change the counter by one, 1151 00:51:26,170 --> 00:51:27,940 incrementing it by adding one. 1152 00:51:27,940 --> 00:51:32,407 So that the net effect is this adorable counting sheep. 1153 00:51:32,407 --> 00:51:33,615 Though he's counting himself. 1154 00:51:33,615 --> 00:51:36,642 1155 00:51:36,642 --> 00:51:38,350 Now it's very quickly going to get boring 1156 00:51:38,350 --> 00:51:40,900 because he's going to do this truly forever, 1157 00:51:40,900 --> 00:51:44,240 but that's exactly what the program's design prescribes. 1158 00:51:44,240 --> 00:51:48,090 Lets now try another example that leverages a variable. 1159 00:51:48,090 --> 00:51:51,140 This one called Hi Hi Hi, that does get annoying quickly. 1160 00:51:51,140 --> 00:51:52,987 Now this one has two scripts. 1161 00:51:52,987 --> 00:51:54,570 And so again, we're taking baby steps. 1162 00:51:54,570 --> 00:51:57,236 >> We started with something super small, added to it, added to it. 1163 00:51:57,236 --> 00:51:59,750 Now I want to do something even more dynamic, 1164 00:51:59,750 --> 00:52:02,950 so I want to be listening for two different things at a time. 1165 00:52:02,950 --> 00:52:05,420 So on the left, when green flag is clicked, 1166 00:52:05,420 --> 00:52:08,100 I set a variable that I wrote in advance called Muted. 1167 00:52:08,100 --> 00:52:09,700 And I arbitrarily set it to 0. 1168 00:52:09,700 --> 00:52:13,290 So Scratch doesn't have true and false, but it does have 0 and 1. 1169 00:52:13,290 --> 00:52:15,270 >> So I can approximate that same idea. 1170 00:52:15,270 --> 00:52:21,110 And then forever, if the space bar is pressed, then set the variable to 0. 1171 00:52:21,110 --> 00:52:21,810 Or sorry. 1172 00:52:21,810 --> 00:52:25,920 If the Space is pressed, and if muted, the variable, is 0, 1173 00:52:25,920 --> 00:52:29,950 then set muted to 1, else set muted to 0. 1174 00:52:29,950 --> 00:52:32,370 This seems sort of like we're just doing and undoing work. 1175 00:52:32,370 --> 00:52:33,130 >> But what's the effect? 1176 00:52:33,130 --> 00:52:35,588 Every time I hit the space bar, what happens to my variable 1177 00:52:35,588 --> 00:52:38,150 called muted, logically? 1178 00:52:38,150 --> 00:52:39,100 Sort of gets flipped. 1179 00:52:39,100 --> 00:52:41,035 It changes from 0 to 1, or 1 to 0. 1180 00:52:41,035 --> 00:52:43,035 So it took a few blocks to express that, but all 1181 00:52:43,035 --> 00:52:47,280 I'm doing is toggling the state of this variable to 0 or 1, or 0 or 1 1182 00:52:47,280 --> 00:52:48,530 each time I hit the space bar. 1183 00:52:48,530 --> 00:52:49,905 Now over here, what's this doing? 1184 00:52:49,905 --> 00:52:53,400 Forever, if muted is 0, so if muted is false. 1185 00:52:53,400 --> 00:52:57,910 So if it's not muted, is the semantics there, play sound sea lion, 1186 00:52:57,910 --> 00:53:00,810 and think Hi Hi Hi for two seconds, wait two seconds. 1187 00:53:00,810 --> 00:53:02,710 So notice now these scripts are effectively 1188 00:53:02,710 --> 00:53:07,100 going to run in parallel so that one can be listening for one action, the other 1189 00:53:07,100 --> 00:53:09,010 to make a decision based on that action. 1190 00:53:09,010 --> 00:53:10,655 And it can do this forever. 1191 00:53:10,655 --> 00:53:12,638 >> [SEA LION BARKING] 1192 00:53:12,638 --> 00:53:14,852 >> [SEA LION BARKING] 1193 00:53:14,852 --> 00:53:20,050 >> It's going to do this forever and [SEA LION BARKING] as I've just done. 1194 00:53:20,050 --> 00:53:23,010 And now it's still running but I've "muted" the game. 1195 00:53:23,010 --> 00:53:27,260 [SEA LION BARKING] And that's all this guy does now too. 1196 00:53:27,260 --> 00:53:28,660 >> Let's open another example here. 1197 00:53:28,660 --> 00:53:31,840 Let me go into Events, and now this adorable too. 1198 00:53:31,840 --> 00:53:34,130 But notice it has two sprites. 1199 00:53:34,130 --> 00:53:37,520 So not just two scripts with one sprite, but two sprites. 1200 00:53:37,520 --> 00:53:40,750 And if I click on the blue guy as I already have, I see he as one program 1201 00:53:40,750 --> 00:53:43,790 up here that literally just says this, when I receive an event, 1202 00:53:43,790 --> 00:53:45,620 say "Polo" for two seconds. 1203 00:53:45,620 --> 00:53:48,460 >> So if you've ever played in a pool, the game Marco Polo, 1204 00:53:48,460 --> 00:53:52,500 if the orange guy script is any indication, apparently 1205 00:53:52,500 --> 00:53:57,380 every time I hit the space bar, what's the orange guy going to do? 1206 00:53:57,380 --> 00:53:58,642 He's going to say "Marco." 1207 00:53:58,642 --> 00:53:59,850 And then this is a new block. 1208 00:53:59,850 --> 00:54:02,409 We've not seen this before, but broadcast an event. 1209 00:54:02,409 --> 00:54:04,200 And I could call it event anything we want. 1210 00:54:04,200 --> 00:54:06,033 >> We'll come back to this perhaps before long. 1211 00:54:06,033 --> 00:54:08,410 But broadcasting an event is a way for one sprite 1212 00:54:08,410 --> 00:54:11,836 to talk to another by essentially passing it a message. 1213 00:54:11,836 --> 00:54:12,960 It's not a message you see. 1214 00:54:12,960 --> 00:54:14,130 It's not something visual. 1215 00:54:14,130 --> 00:54:17,370 It's sort of a computer message that the other guy is listening for. 1216 00:54:17,370 --> 00:54:21,210 Because indeed, the blue guy, recall doesn't have when green flag clicked. 1217 00:54:21,210 --> 00:54:23,290 >> He instead has, when I receive an event. 1218 00:54:23,290 --> 00:54:26,850 When he gets handed this note in class, so to speak, he should say "Polo." 1219 00:54:26,850 --> 00:54:30,200 And so the net effect is that when I hit the green flag, nothing happens. 1220 00:54:30,200 --> 00:54:34,940 But when I hit the space bar, he says "Marco," he responds with "Polo." 1221 00:54:34,940 --> 00:54:38,350 But the only sprite I'm interacting with is the orange one. 1222 00:54:38,350 --> 00:54:40,980 So this is a way of kind of passing messages between sprites 1223 00:54:40,980 --> 00:54:43,210 and having them communicate with one another. 1224 00:54:43,210 --> 00:54:46,280 >> Now let's look at one last one here called Threads. 1225 00:54:46,280 --> 00:54:49,370 And notice this by playing it. 1226 00:54:49,370 --> 00:54:51,184 So these are two sprites. 1227 00:54:51,184 --> 00:54:52,600 The bird is kind of flying around. 1228 00:54:52,600 --> 00:54:53,310 He's bouncing. 1229 00:54:53,310 --> 00:54:55,890 There's no "ouch," but same idea. 1230 00:54:55,890 --> 00:54:58,230 >> But the cat seems pretty smart. 1231 00:54:58,230 --> 00:55:01,010 What is the cat apparently doing? 1232 00:55:01,010 --> 00:55:03,430 And wait for it. 1233 00:55:03,430 --> 00:55:05,010 What is the cat apparently doing? 1234 00:55:05,010 --> 00:55:07,740 It's not just bouncing. 1235 00:55:07,740 --> 00:55:09,860 >> He's following the bird. 1236 00:55:09,860 --> 00:55:13,920 And so apparently, there's a way with a combination of blocks here-- 1237 00:55:13,920 --> 00:55:15,760 and let's look at the cat real fast. 1238 00:55:15,760 --> 00:55:20,270 Forever, if touching bird, then play the sound Lion 4, whatever that is. 1239 00:55:20,270 --> 00:55:21,360 We heard it once. 1240 00:55:21,360 --> 00:55:25,431 Otherwise, point towards bird, and move one step. 1241 00:55:25,431 --> 00:55:27,680 Now the fact that it's one step is what gives the bird 1242 00:55:27,680 --> 00:55:29,850 a bit of an advantage initially, but if we instead 1243 00:55:29,850 --> 00:55:32,980 make this 10, for instance, so that every iteration of loop he's 1244 00:55:32,980 --> 00:55:34,100 moving 10 steps of time. 1245 00:55:34,100 --> 00:55:35,280 So more space. 1246 00:55:35,280 --> 00:55:36,650 Let's see what happens then. 1247 00:55:36,650 --> 00:55:38,740 [LION ROAR] Not all that much better. 1248 00:55:38,740 --> 00:55:41,460 So now let's try to improve upon these a little iteratively, 1249 00:55:41,460 --> 00:55:43,330 and come back to that notion of a function. 1250 00:55:43,330 --> 00:55:46,580 >> And indeed one of the fundamental takeaways of the class design. 1251 00:55:46,580 --> 00:55:49,560 Not just writing programs that work and that are correct, but are well 1252 00:55:49,560 --> 00:55:50,080 designed. 1253 00:55:50,080 --> 00:55:54,349 And design is much more subjective, and you'll get better at it over time. 1254 00:55:54,349 --> 00:55:57,390 But let's take some baby steps toward starting with a program that works, 1255 00:55:57,390 --> 00:55:59,310 absolutely, but it's not very good. 1256 00:55:59,310 --> 00:56:00,650 It's not very well written. 1257 00:56:00,650 --> 00:56:03,830 >> So here's a program that does this. 1258 00:56:03,830 --> 00:56:08,060 Cough, cough, cough. 1259 00:56:08,060 --> 00:56:09,880 What does the program look like? 1260 00:56:09,880 --> 00:56:11,330 Looks correct to me. 1261 00:56:11,330 --> 00:56:13,370 It's saying couch for a second, then it waits. 1262 00:56:13,370 --> 00:56:14,515 >> Then it says it again, then it waits. 1263 00:56:14,515 --> 00:56:16,056 Then it says it again, then it waits. 1264 00:56:16,056 --> 00:56:18,770 And then the program implicitly ends, because there's no loop. 1265 00:56:18,770 --> 00:56:21,325 But why is this a badly written program? 1266 00:56:21,325 --> 00:56:22,950 Even if you've never programmed before? 1267 00:56:22,950 --> 00:56:25,240 Like, what rubs the wrong way, perhaps here? 1268 00:56:25,240 --> 00:56:26,016 Yeah? 1269 00:56:26,016 --> 00:56:29,278 >> AUDIENCE: [INAUDIBLE] 1270 00:56:29,278 --> 00:56:29,950 1271 00:56:29,950 --> 00:56:30,950 DAVID J. MALAN: Exactly. 1272 00:56:30,950 --> 00:56:32,700 You're repeating yourself again and again. 1273 00:56:32,700 --> 00:56:36,190 And literally, I copied and pasted two of those blocks again and again. 1274 00:56:36,190 --> 00:56:39,237 And that's exactly the sort of sanity check that you should be making. 1275 00:56:39,237 --> 00:56:39,820 Wait a minute. 1276 00:56:39,820 --> 00:56:41,070 Should I really be doing this? 1277 00:56:41,070 --> 00:56:43,610 So what's this what's the obvious solution perhaps? 1278 00:56:43,610 --> 00:56:44,680 Have some kind of loop. 1279 00:56:44,680 --> 00:56:46,860 And I don't quite recall what the puzzle piece is, 1280 00:56:46,860 --> 00:56:48,810 but if I look at the next iteration here, 1281 00:56:48,810 --> 00:56:50,560 indeed, there's not just the forever loop, 1282 00:56:50,560 --> 00:56:52,560 there's repeat some number of times. 1283 00:56:52,560 --> 00:56:54,080 And so I've specified three. 1284 00:56:54,080 --> 00:56:57,839 And now notice how much tighter, how much more succinct this program is. 1285 00:56:57,839 --> 00:56:59,630 And in a sense, how much more maintainable. 1286 00:56:59,630 --> 00:57:02,840 If I want to change the word from cough to something else, 1287 00:57:02,840 --> 00:57:07,530 like achoo, like he's sneezing. 1288 00:57:07,530 --> 00:57:09,770 Then I change it in one place, and not three. 1289 00:57:09,770 --> 00:57:12,050 So this already feels like slightly better design. 1290 00:57:12,050 --> 00:57:14,610 Let me instead open cough 2, our third example. 1291 00:57:14,610 --> 00:57:17,670 >> Notice as a computer scientist, I start counting at 0, typically. 1292 00:57:17,670 --> 00:57:20,950 Now this looks a little scarier at first, but the effect is the same. 1293 00:57:20,950 --> 00:57:22,590 Cough, cough, cough. 1294 00:57:22,590 --> 00:57:26,920 But what seems to be fundamentally new in the top part of the program? 1295 00:57:26,920 --> 00:57:28,670 I've removed the say. 1296 00:57:28,670 --> 00:57:29,830 >> I've removed the wait. 1297 00:57:29,830 --> 00:57:32,370 And what have I plugged in instead? 1298 00:57:32,370 --> 00:57:32,890 A function. 1299 00:57:32,890 --> 00:57:33,670 A cough block. 1300 00:57:33,670 --> 00:57:35,410 I mean, frankly, I seem kind of an idiot if I didn't just 1301 00:57:35,410 --> 00:57:37,285 start with the block that's apparently called 1302 00:57:37,285 --> 00:57:38,894 "cough," if that's all I want him do. 1303 00:57:38,894 --> 00:57:40,310 But that doesn't exist in Scratch. 1304 00:57:40,310 --> 00:57:43,396 Rather I went to one in the palette called More Blocks here, 1305 00:57:43,396 --> 00:57:46,270 and I drag this big purple thing here that lets me define a function. 1306 00:57:46,270 --> 00:57:48,240 It essentially lets me create my own puzzle 1307 00:57:48,240 --> 00:57:51,280 piece that can be called anything I want, that can do anything I want, 1308 00:57:51,280 --> 00:57:52,360 but it gives it a name. 1309 00:57:52,360 --> 00:57:57,050 It gives me a new, purple puzzle piece that now does whatever I tell it to do. 1310 00:57:57,050 --> 00:58:01,060 So this purple piece here corresponds to this one here. 1311 00:58:01,060 --> 00:58:01,960 >> And what does it do? 1312 00:58:01,960 --> 00:58:03,930 It says cough for a second, and then it waits. 1313 00:58:03,930 --> 00:58:07,330 And now I've sort of created my own custom puzzle piece, 1314 00:58:07,330 --> 00:58:10,040 so that it behaves exactly that same way. 1315 00:58:10,040 --> 00:58:11,130 So I can keep doing this. 1316 00:58:11,130 --> 00:58:14,421 And indeed, there's going to be more and more opportunities for modularization, 1317 00:58:14,421 --> 00:58:16,630 and for layering, complexity on top of one another. 1318 00:58:16,630 --> 00:58:18,547 But this basic idea, indeed in problem said 0. 1319 00:58:18,547 --> 00:58:20,338 What you're going to be challenged to do is 1320 00:58:20,338 --> 00:58:23,810 to download Scratch, or just use it on the web, and just have fun with it. 1321 00:58:23,810 --> 00:58:26,056 We'll give you a set of requirements, having a sound, 1322 00:58:26,056 --> 00:58:27,430 and some number of puzzle pieces. 1323 00:58:27,430 --> 00:58:28,480 But you'll do exactly this. 1324 00:58:28,480 --> 00:58:31,771 And you'll realize that you're going to want to take some baby steps initially, 1325 00:58:31,771 --> 00:58:33,690 until your program gets more and more complex. 1326 00:58:33,690 --> 00:58:36,010 But considering is this the best way I could do this? 1327 00:58:36,010 --> 00:58:39,210 Can I avoid this instinct perhaps, to copy and paste? 1328 00:58:39,210 --> 00:58:41,850 >> But before Problem Set 0, and before we adjourn, 1329 00:58:41,850 --> 00:58:44,980 thought we'd take up one more volunteer if we could, 1330 00:58:44,980 --> 00:58:46,820 for a final program that's perhaps the most 1331 00:58:46,820 --> 00:58:49,150 fitting at all, given today's venue. 1332 00:58:49,150 --> 00:58:50,298 Come on down. 1333 00:58:50,298 --> 00:58:51,234 Yeah. 1334 00:58:51,234 --> 00:58:52,170 Yes. 1335 00:58:52,170 --> 00:58:53,431 What's your name? 1336 00:58:53,431 --> 00:58:53,930 Uh-oh. 1337 00:58:53,930 --> 00:58:57,820 1338 00:58:57,820 --> 00:58:59,010 That's OK. 1339 00:58:59,010 --> 00:59:01,230 Both come down. 1340 00:59:01,230 --> 00:59:05,520 And I've will deal with this somehow within that next ten seconds. 1341 00:59:05,520 --> 00:59:06,550 So come on down. 1342 00:59:06,550 --> 00:59:08,370 Come on down. 1343 00:59:08,370 --> 00:59:13,250 >> Let me come on up here. 1344 00:59:13,250 --> 00:59:16,050 Come on. 1345 00:59:16,050 --> 00:59:16,685 All right. 1346 00:59:16,685 --> 00:59:21,360 1347 00:59:21,360 --> 00:59:22,360 Let's see here. 1348 00:59:22,360 --> 00:59:25,735 So notice real fast here, if you'd like to come on up. 1349 00:59:25,735 --> 00:59:28,650 1350 00:59:28,650 --> 00:59:29,926 >> We'll do two rounds of this. 1351 00:59:29,926 --> 00:59:30,800 And what's your name? 1352 00:59:30,800 --> 00:59:31,270 >> SABRINA: Sabrina. 1353 00:59:31,270 --> 00:59:32,060 >> DAVID J. MALAN: Sabrina and? 1354 00:59:32,060 --> 00:59:32,622 >> YING GEE: Ying Gee. 1355 00:59:32,622 --> 00:59:33,360 >> DAVID J. MALAN: Ying Gee. 1356 00:59:33,360 --> 00:59:34,276 Nice to meet you both. 1357 00:59:34,276 --> 00:59:34,970 David. 1358 00:59:34,970 --> 00:59:38,785 So our final example here is called Ivy's Hardest Game. 1359 00:59:38,785 --> 00:59:41,160 And why don't we have you do Level 1, and you do Level 2. 1360 00:59:41,160 --> 00:59:43,350 >> And we'll see how far beyond that we actually go. 1361 00:59:43,350 --> 00:59:45,855 Written by a student last year, remixed by me 1362 00:59:45,855 --> 00:59:48,840 so that this would go over well in New Haven. 1363 00:59:48,840 --> 00:59:53,180 And I give you a game that's going to involve moving the arrows up and down, 1364 00:59:53,180 --> 00:59:55,771 and getting Yale to the finish line. 1365 00:59:55,771 --> 00:59:56,270 Here we go. 1366 00:59:56,270 --> 00:59:56,759 >> [VIDEO PLAYBACK] 1367 00:59:56,759 --> 00:59:58,092 >> [MUSIC -- NFL ON FOX THEME SONG] 1368 00:59:58,092 --> 00:59:59,369 1369 00:59:59,369 --> 01:00:01,160 [MUSIC -- MC HAMMER, "U CAN'T TOUCH THIS"] 1370 01:00:01,160 --> 01:00:04,590 1371 01:00:04,590 --> 01:00:07,900 >> -U can't touch this. 1372 01:00:07,900 --> 01:00:11,634 U can't touch this. 1373 01:00:11,634 --> 01:00:14,252 Can't touch this. 1374 01:00:14,252 --> 01:00:19,490 My, my, my, my music hits me so hard, makes me say, oh, my lord. 1375 01:00:19,490 --> 01:00:22,927 Thank you for blessing me with a mind to rhyme and two hype feet. 1376 01:00:22,927 --> 01:00:24,891 >> That's good when you know you're down. 1377 01:00:24,891 --> 01:00:26,855 A super dope homeboy from the Oaktown. 1378 01:00:26,855 --> 01:00:31,274 And I'm known as such and this a beat uh, you can't touch. 1379 01:00:31,274 --> 01:00:34,672 I told you homeboy U can't touch this. 1380 01:00:34,672 --> 01:00:38,656 Yeah, that's how we're living and you know U can't touch this. 1381 01:00:38,656 --> 01:00:40,135 >> Look in my eyes, man. 1382 01:00:40,135 --> 01:00:43,093 U can't touch this. 1383 01:00:43,093 --> 01:00:44,572 Yo, let me bust the funky lyrics. 1384 01:00:44,572 --> 01:00:45,363 U can't touch this. 1385 01:00:45,363 --> 01:00:46,544 Fresh new kicks and pants. 1386 01:00:46,544 --> 01:00:48,627 >> You got it like that and you know you wanna dance. 1387 01:00:48,627 --> 01:00:51,967 So move out of your seat and get a fly girl and catch this beat. 1388 01:00:51,967 --> 01:00:55,911 While it's rolling hold on pump a little bit and let them know what's going on. 1389 01:00:55,911 --> 01:00:56,890 Like that. 1390 01:00:56,890 --> 01:00:57,390 Like that. 1391 01:00:57,390 --> 01:00:59,362 >> Cold on a mission so pull on back. 1392 01:00:59,362 --> 01:01:04,785 Let them know that you're too much and this is a move uh you can't touch. 1393 01:01:04,785 --> 01:01:07,743 Yo, I told you U can't touch this. 1394 01:01:07,743 --> 01:01:09,222 Why you standing there man? 1395 01:01:09,222 --> 01:01:10,208 U can't touch this. 1396 01:01:10,208 --> 01:01:13,200 >> Yo, sound the bell school's in, sucker. 1397 01:01:13,200 --> 01:01:14,005 U can't touch this. 1398 01:01:14,005 --> 01:01:18,326 Give me a song, a rhythm making them sweat that's what I'm giving them now. 1399 01:01:18,326 --> 01:01:21,805 They know when you talk about the Hammer you talk about a show that's hyped. 1400 01:01:21,805 --> 01:01:24,290 And tight singers are sweating so pass them a mic. 1401 01:01:24,290 --> 01:01:27,272 >> Or a tape to learn what it's going to take and now 1402 01:01:27,272 --> 01:01:29,260 he's going to burn the charts. 1403 01:01:29,260 --> 01:01:32,739 Legit either work hard or you might as well quit. 1404 01:01:32,739 --> 01:01:37,709 Because you know U can't touch this. 1405 01:01:37,709 --> 01:01:41,599 U can't touch this. 1406 01:01:41,599 --> 01:01:42,182 Break it down. 1407 01:01:42,182 --> 01:01:56,095 1408 01:01:56,095 --> 01:01:56,595 Stop. 1409 01:01:56,595 --> 01:01:57,095 Hammer time. 1410 01:01:57,095 --> 01:01:59,577 Go with the flow in a spin if you can't move to this 1411 01:01:59,577 --> 01:02:01,068 then you probably are dead. 1412 01:02:01,068 --> 01:02:04,547 So wave your hands in the air [INAUDIBLE] 1413 01:02:04,547 --> 01:02:08,026 >> This is it for a winner dance to this and you're going to get thinner. 1414 01:02:08,026 --> 01:02:12,996 Move slide your rump just for a minute let's all do the bump. 1415 01:02:12,996 --> 01:02:13,990 Yeah. 1416 01:02:13,990 --> 01:02:14,984 U can't touch this. 1417 01:02:14,984 --> 01:02:17,966 1418 01:02:17,966 --> 01:02:19,457 >> U can't touch this. 1419 01:02:19,457 --> 01:02:23,433 You better get hyped boy U can't touch this. 1420 01:02:23,433 --> 01:02:24,924 Ring the bell school's back in. 1421 01:02:24,924 --> 01:02:25,918 Break it down. 1422 01:02:25,918 --> 01:02:38,837 1423 01:02:38,837 --> 01:02:39,337 Stop. 1424 01:02:39,337 --> 01:02:40,828 Hammer time 1425 01:02:40,828 --> 01:02:42,816 >> DAVID J. MALAN: That's it for CS50! 1426 01:02:42,816 --> 01:02:45,301 Thanks so much for joining us! 1427 01:02:45,301 --> 01:02:47,786 See you outside. 1428 01:02:47,786 --> 01:02:48,611 >> [END PLAYBACK] 1429 01:02:48,611 --> 01:02:49,277 [VIDEO PLAYBACK] 1430 01:02:49,277 --> 01:02:52,259 [MUSIC -- "SEINFELD" THEME SONG] 1431 01:02:52,259 --> 01:02:53,860 -Hey David. 1432 01:02:53,860 --> 01:02:54,500 -Hey, David. 1433 01:02:54,500 --> 01:02:55,912 How's it going? 1434 01:02:55,912 --> 01:02:58,078 >> -Good job, today. 1435 01:02:58,078 --> 01:03:00,952 -So have you thought about what you're going to do for the out jokes? 1436 01:03:00,952 --> 01:03:03,207 -No, I got nothing. 1437 01:03:03,207 --> 01:03:07,550 -What if-- what if this is the out joke? 1438 01:03:07,550 --> 01:03:08,970 -Like, unpacking carts? 1439 01:03:08,970 --> 01:03:11,430 -Uh-huh. 1440 01:03:11,430 --> 01:03:13,890 You know, it's about nothing. 1441 01:03:13,890 --> 01:03:17,559 >> -So like, no story, no conflict, no resolution. 1442 01:03:17,559 --> 01:03:18,350 I don't understand. 1443 01:03:18,350 --> 01:03:20,542 What's it about then? 1444 01:03:20,542 --> 01:03:23,510 >> -Nothing. 1445 01:03:23,510 --> 01:03:27,427 >> -So we have out joke is about nothing, and we have no actors. 1446 01:03:27,427 --> 01:03:28,510 Who's going to be in this? 1447 01:03:28,510 --> 01:03:29,010 >> -No, no, no. 1448 01:03:29,010 --> 01:03:31,310 I mean, I'll be in it. 1449 01:03:31,310 --> 01:03:32,109 >> -You'll be in it? 1450 01:03:32,109 --> 01:03:32,608 -Yeah! 1451 01:03:32,608 --> 01:03:34,903 People are always telling me I'm a character. 1452 01:03:34,903 --> 01:03:36,029 >> -Well, I mean, it's true. 1453 01:03:36,029 --> 01:03:37,445 But who else is going to be in it? 1454 01:03:37,445 --> 01:03:38,660 It can't just be you. 1455 01:03:38,660 --> 01:03:47,240 >> -You will be in it, Gavin, Dan, Dan, Colton, Z'Myla, Alysse, Doug, 1456 01:03:47,240 --> 01:03:51,120 David, everybody. 1457 01:03:51,120 --> 01:03:53,630 >> -So it's about nothing, and everybody's in it? 1458 01:03:53,630 --> 01:03:54,530 >> -Absolutely nothing. 1459 01:03:54,530 --> 01:03:58,730 1460 01:03:58,730 --> 01:04:00,580 >> -This is ridiculous.