1 00:00:00,506 --> 00:00:09,476 [ Silence ] 2 00:00:09,976 --> 00:00:14,526 >> This is CS50, Friday of Week 0. 3 00:00:14,526 --> 00:00:17,306 Welcome back for those returning, welcome to CS50 4 00:00:17,396 --> 00:00:18,986 for those joining us for the first time. 5 00:00:18,986 --> 00:00:21,656 Typically, we will not in fact have classes on Fridays, 6 00:00:21,656 --> 00:00:24,536 just this week and next for shopping week and Labor Day. 7 00:00:24,536 --> 00:00:27,696 But thereafter we will indeed be Monday, Wednesday. 8 00:00:27,696 --> 00:00:31,056 So, one of the side effects perhaps of a course like this is 9 00:00:31,056 --> 00:00:33,936 that it begins to open your eyes to all sorts 10 00:00:33,936 --> 00:00:36,966 of technical curiosities in society 11 00:00:36,966 --> 00:00:39,566 and technical inaccuracies in society. 12 00:00:39,566 --> 00:00:41,116 And so what I did this morning, 13 00:00:41,116 --> 00:00:43,776 this is literally how I spent my morning, well, it was troll 14 00:00:43,776 --> 00:00:47,966 around YouTube looking for nice incarnations of things 15 00:00:47,966 --> 00:00:51,156 that perhaps yesterday you might not have blinked that 16 00:00:51,346 --> 00:00:54,506 but 10 weeks from now you should absolutely poke fun 17 00:00:54,666 --> 00:00:56,186 at these people. 18 00:00:56,276 --> 00:01:01,486 So with that said, I give you a little something from YouTube. 19 00:01:02,446 --> 00:01:04,716 >> For weeks I've been investigating the [inaudible] 20 00:01:05,026 --> 00:01:07,336 murders with a certain morbid fascination. 21 00:01:07,716 --> 00:01:08,716 >> This isn't real-time. 22 00:01:09,276 --> 00:01:11,336 >> I'll create a GUI interface using Visual Basic, 23 00:01:11,336 --> 00:01:13,946 see if I can track an IP address. 24 00:01:14,266 --> 00:01:17,696 >> So there we have, I'll create a GUI interface using Visual 25 00:01:17,696 --> 00:01:19,706 Basic, see if I can track an IP address. 26 00:01:19,976 --> 00:01:22,486 So, a lot of technical words independently 27 00:01:22,486 --> 00:01:25,536 that are very much accurate and used in technical context. 28 00:01:25,716 --> 00:01:27,876 But GUI, graphical user interface, 29 00:01:27,976 --> 00:01:28,816 kind of [inaudible] said, 30 00:01:28,816 --> 00:01:30,806 a graphical user interface interface, 31 00:01:31,206 --> 00:01:33,046 two using Visual Basic. 32 00:01:33,046 --> 00:01:35,036 So this is kind of a modern show and that is kind 33 00:01:35,036 --> 00:01:37,766 of a retro language and it's also as will be one 34 00:01:37,766 --> 00:01:40,326 of the takeaways of this course completely irrelevant 35 00:01:40,326 --> 00:01:41,826 to what problem you are solving, 36 00:01:41,826 --> 00:01:44,036 the fact that this engineer is using-- 37 00:01:44,036 --> 00:01:47,126 proclaiming to use Visual Basic really is not a compelling part 38 00:01:47,126 --> 00:01:47,676 of the story. 39 00:01:47,866 --> 00:01:50,166 And finally, see if I can track an IP address. 40 00:01:50,386 --> 00:01:52,916 Well, all of that might in fact be the goal but it's 41 00:01:52,916 --> 00:01:55,226 when you start hearing things like this hopefully that you 42 00:01:55,226 --> 00:01:58,016 at least start to grimace a little bit. 43 00:01:58,016 --> 00:02:01,096 And let me pull up a second one, it turns out it's also from CSI. 44 00:02:01,156 --> 00:02:06,906 Let me make sure that the user annotations are disabled this 45 00:02:06,906 --> 00:02:13,916 time and let's take a little look at this one here. 46 00:02:13,916 --> 00:02:13,983 [ Music ] 47 00:02:13,983 --> 00:02:17,986 >> This is the vacation shot, it gives us something to work with. 48 00:02:17,986 --> 00:02:22,246 >> [Inaudible] was taking a picture of this girl. 49 00:02:22,456 --> 00:02:25,226 So, margin the reflection in her eye. 50 00:02:25,946 --> 00:02:27,286 Just slide the image over. 51 00:02:28,766 --> 00:02:32,586 >> And there is our victim, our program. 52 00:02:32,586 --> 00:02:37,106 >> Okay, so when you are working with source material that looks 53 00:02:37,106 --> 00:02:41,096 like this, there is in fact no such thing 54 00:02:41,096 --> 00:02:44,096 as infinite zoom in computer science. 55 00:02:44,246 --> 00:02:47,736 You can not just tell the computer to enhance that 56 00:02:47,786 --> 00:02:50,546 or can you clean that up and then magically use zoom 57 00:02:50,546 --> 00:02:52,746 in not only on the image but also on the reflection 58 00:02:52,796 --> 00:02:54,926 of the victim in someone's eyeball. 59 00:02:54,926 --> 00:02:57,596 So here too are they taking some liberties. 60 00:02:57,596 --> 00:03:00,276 But thankfully I also found in my trolling around this morning, 61 00:03:00,566 --> 00:03:03,576 something that is perhaps technically motivating 62 00:03:03,576 --> 00:03:05,776 and at least remains for those of you which is many of you 63 00:03:05,956 --> 00:03:09,356 who actually use Gmail, you might have seen a little advert 64 00:03:09,356 --> 00:03:12,586 in the top right hand corner recently saying new beta version 65 00:03:12,736 --> 00:03:15,106 of a little something called Gmail Priority Inbox. 66 00:03:15,106 --> 00:03:18,076 So this one is not a spoof, it's actually a pretty cute video 67 00:03:18,076 --> 00:03:21,126 and it offers us the opportunity to just take a look at some 68 00:03:21,126 --> 00:03:24,116 of the kinds of ideas we'll be looking at in this course. 69 00:03:24,116 --> 00:03:26,726 So I give you your Gmail Priority Inbox. 70 00:03:26,726 --> 00:03:28,296 If you haven't turned it on or don't know what 71 00:03:28,296 --> 00:03:29,866 that thing is [background music] here we go. 72 00:03:30,516 --> 00:05:20,506 [ Music ] 73 00:05:21,006 --> 00:05:22,476 >> So, if you've ever wondered, 74 00:05:22,476 --> 00:05:25,606 that is in fact how Gmail works underneath the hood? 75 00:05:25,606 --> 00:05:29,616 So, what are the takeaways though for us? 76 00:05:29,616 --> 00:05:32,516 So there're actually some really interesting computer science 77 00:05:32,516 --> 00:05:34,916 ideas underlying that we promised on Wednesday 78 00:05:34,916 --> 00:05:36,196 that computer science. 79 00:05:36,196 --> 00:05:38,626 And this course in particular isn't at the end of the day 80 00:05:38,626 --> 00:05:40,146 about programming even though that is 81 00:05:40,146 --> 00:05:42,586 in fact how you will spend a good amount of your time 82 00:05:42,586 --> 00:05:45,206 and the skill that you will in fact walk away with. 83 00:05:45,406 --> 00:05:46,736 But it's about approaching something 84 00:05:46,736 --> 00:05:49,176 that you actually care about, for instance, just-- 85 00:05:49,176 --> 00:05:52,056 it's even something work a day like managing your email 86 00:05:52,056 --> 00:05:54,776 and getting through the day more efficiently and trying 87 00:05:54,776 --> 00:05:59,176 to answer a lot more cleverly, a lot more effectively questions 88 00:05:59,176 --> 00:06:00,976 like which things do I care about. 89 00:06:00,976 --> 00:06:03,456 I mean these are the kinds of things the computers can in fact 90 00:06:03,946 --> 00:06:06,166 if programmed effectively help us with. 91 00:06:06,166 --> 00:06:08,786 So this little video suggested there's a couple of heuristics 92 00:06:09,056 --> 00:06:11,936 that a computer or that a programmer could use to figure 93 00:06:11,936 --> 00:06:14,636 out what emails are important to someone like me. 94 00:06:14,636 --> 00:06:18,176 We looked at what emails you reply to if you reply in theory 95 00:06:18,176 --> 00:06:21,516 that suggest this user must care about whoever sent this email 96 00:06:21,586 --> 00:06:22,776 or the topic they are in. 97 00:06:23,046 --> 00:06:26,426 If you actually read it, that's a useful indicator. 98 00:06:26,426 --> 00:06:29,646 Are there other indicators or tricks or rules of thumb 99 00:06:29,646 --> 00:06:31,706 that just off the top of your head come to you 100 00:06:32,046 --> 00:06:34,536 as useful mechanisms for doings this as well? 101 00:06:34,536 --> 00:06:35,566 Yeah. 102 00:06:35,771 --> 00:06:37,771 [ Inaudible Remark ] 103 00:06:37,976 --> 00:06:39,196 >> So that's a good one. 104 00:06:39,196 --> 00:06:41,776 So, whether or not the email is addressed specifically to you 105 00:06:41,776 --> 00:06:44,916 in like the two field or if maybe you were BCC'd 106 00:06:44,916 --> 00:06:47,086 or it's a big email list of which you're just part, 107 00:06:47,266 --> 00:06:49,876 that could signify that this is in fact useful for you. 108 00:06:49,876 --> 00:06:51,436 Yeah, in the back. 109 00:06:51,436 --> 00:06:51,706 [ Inaudible Remark ] 110 00:06:51,706 --> 00:06:55,856 >> So what the subject is, okay, so if it's something like, 111 00:06:55,856 --> 00:06:58,746 you know, buy such and such, a whole bunch of spam. 112 00:06:58,936 --> 00:07:01,166 I mean buy could actually be a negative indicator 113 00:07:01,166 --> 00:07:03,216 that this is probably not of interest to the user. 114 00:07:03,386 --> 00:07:06,296 Whereas please help or dinner or something 115 00:07:06,296 --> 00:07:08,816 like that might actually be more compelling to a human. 116 00:07:09,056 --> 00:07:10,616 Other thoughts that come to mind. 117 00:07:11,196 --> 00:07:13,556 Yeah, in the middle. 118 00:07:13,556 --> 00:07:13,623 [ Inaudible Remark ] 119 00:07:13,623 --> 00:07:14,136 >> Okay, good. 120 00:07:14,136 --> 00:07:16,536 So in Gmail context most of yo know, you can not-- 121 00:07:16,536 --> 00:07:18,436 you can delete things but most people just save 122 00:07:18,436 --> 00:07:19,396 or archive emails. 123 00:07:19,636 --> 00:07:21,536 So if you archive it, that's maybe a little hint 124 00:07:21,536 --> 00:07:23,746 that either this is just your habit or perhaps 125 00:07:23,746 --> 00:07:26,166 that you might actually care about this later in the future, 126 00:07:26,166 --> 00:07:28,396 whereas if you delete it, no, you really don't care. 127 00:07:29,106 --> 00:07:29,456 Yeah. 128 00:07:29,456 --> 00:07:29,886 [ Inaudible Remark ] 129 00:07:29,886 --> 00:07:32,826 >> So who the sender is, so maybe you could keep track 130 00:07:32,826 --> 00:07:35,766 of just who your most frequent correspondents are 131 00:07:35,766 --> 00:07:38,086 and if you keep seeing the same person from person X 132 00:07:38,156 --> 00:07:41,706 or person Y coming into your inbox and clearly I 133 00:07:41,706 --> 00:07:44,776 like having a dialog with these people or have to for work, 134 00:07:44,936 --> 00:07:46,626 that might in fact bubble up in your inbox. 135 00:07:46,696 --> 00:07:47,276 Other thoughts? 136 00:07:47,276 --> 00:07:48,546 [ Inaudible Remark ] 137 00:07:48,546 --> 00:07:51,696 >> Speed of response, right, so I actually do tend to respond 138 00:07:51,696 --> 00:07:53,976 to some people's emails more quickly than others and that 139 00:07:53,976 --> 00:07:55,886 in fact might be a useful indicator. 140 00:07:55,886 --> 00:07:59,296 And if I'm already in this habit, let my software, 141 00:07:59,296 --> 00:08:02,916 let my computer do that thinking for me and bubble up to the top 142 00:08:02,916 --> 00:08:05,206 of my attention what I should address first. 143 00:08:05,206 --> 00:08:06,236 And another idea? 144 00:08:06,236 --> 00:08:07,716 [ Inaudible Remark ] 145 00:08:07,716 --> 00:08:09,666 >> So how long you leave the window open. 146 00:08:09,666 --> 00:08:11,706 So this one too is an interesting heuristic 147 00:08:11,706 --> 00:08:14,746 and these kinds of ideas are actually really prevalent 148 00:08:14,746 --> 00:08:17,446 in like the advertising world, and I'm sure of sites 149 00:08:17,446 --> 00:08:19,746 like Facebook and the like actually do keep track 150 00:08:19,746 --> 00:08:22,226 of how much time you spend using this application 151 00:08:22,226 --> 00:08:24,316 or how much time you spend on this particular page 152 00:08:24,526 --> 00:08:27,696 so that they can infer from that behavior what you actually care 153 00:08:27,696 --> 00:08:31,386 about and what you might actually look at more intensely. 154 00:08:31,546 --> 00:08:33,596 So feel free to play with this if you like. 155 00:08:33,596 --> 00:08:36,386 I just turned it on literally this morning to start playing 156 00:08:36,386 --> 00:08:38,286 and I'm on myself a couple of email list, 157 00:08:38,666 --> 00:08:41,146 one of which had an email this morning saying, "Hey, 158 00:08:41,146 --> 00:08:43,386 has anyone tried this, it really kind of sucks." 159 00:08:43,636 --> 00:08:46,196 Whereas the other email list said completely the opposite. 160 00:08:46,196 --> 00:08:49,036 So it's this interesting scenario where it's probably hit 161 00:08:49,036 --> 00:08:51,156 or miss, certainly early on and as one 162 00:08:51,486 --> 00:08:54,356 of the clips they are indicated, these are the kinds of things 163 00:08:54,356 --> 00:08:57,336 where computers ideally have to learn overtime. 164 00:08:57,336 --> 00:08:59,416 A priori, Google has probably not going 165 00:08:59,416 --> 00:09:00,466 to know what you care about. 166 00:09:00,706 --> 00:09:02,916 But if watches you over some amount of time just 167 00:09:02,916 --> 00:09:06,306 like it's been for years with advertisements, can this kind 168 00:09:06,306 --> 00:09:10,216 of algorithm, this kind of process presumably improve? 169 00:09:10,216 --> 00:09:13,376 So that's perhaps a hint of where we're going in the future. 170 00:09:13,376 --> 00:09:15,186 So for those of you joining us for the last time, 171 00:09:15,186 --> 00:09:16,616 know that the video of Wednesday 172 00:09:16,616 --> 00:09:19,086 as will generally be the case is already online. 173 00:09:19,086 --> 00:09:22,876 You can go to cs50.net/lectures and that will lead you to a link 174 00:09:22,876 --> 00:09:25,396 where the video is nicely embedded in HDV. 175 00:09:25,486 --> 00:09:27,256 Thanks to our videographers this year. 176 00:09:27,416 --> 00:09:29,736 What you'll see here is a little clip of what I showed 177 00:09:29,736 --> 00:09:32,036 on Wednesday whereby this semester 178 00:09:32,036 --> 00:09:34,536 for the first time we'll be including after a few days, 179 00:09:34,536 --> 00:09:36,376 it takes a few days of human labor to-- 180 00:09:36,546 --> 00:09:40,276 we will be transcribing the lectures in their entirety word 181 00:09:40,276 --> 00:09:42,296 for word, awkward as this is for me 182 00:09:42,296 --> 00:09:45,116 to actually see the words I'm saying in retrospect. 183 00:09:45,456 --> 00:09:48,266 But you will then be able to read what's there. 184 00:09:48,496 --> 00:09:52,486 Do keyword search based on anything that I happen to say, 185 00:09:52,486 --> 00:09:54,756 if you search for this in a few days' time. 186 00:09:54,756 --> 00:09:57,776 And similarly can you click on any sentence in the transcript, 187 00:09:57,776 --> 00:09:59,406 jump right to that point in the video. 188 00:09:59,696 --> 00:10:03,836 So this is very much online education CS50 style. 189 00:10:04,466 --> 00:10:07,456 >> And if you speak other languages that I don't, 190 00:10:07,456 --> 00:10:09,766 you can nonetheless compel me to speak them 191 00:10:09,766 --> 00:10:11,216 at least in subtitle form. 192 00:10:11,526 --> 00:10:13,136 So I wanted to take a few excerpts 193 00:10:13,136 --> 00:10:15,806 from the course's syllabus since it's not an interesting document 194 00:10:15,806 --> 00:10:18,516 to walk through line by line, but something you should read 195 00:10:18,516 --> 00:10:19,816 at some point very soon. 196 00:10:20,076 --> 00:10:22,106 What ultimately matters in this course is not-- 197 00:10:22,106 --> 00:10:25,196 is not so much where you end up relative to your classmates 198 00:10:25,266 --> 00:10:30,756 but where you end up in week 12 relative to yourself in week 0. 199 00:10:30,756 --> 00:10:32,856 And so this really is the mantra of the course. 200 00:10:32,856 --> 00:10:35,086 One of the concerns out of the gate for students 201 00:10:35,086 --> 00:10:37,986 in this course, particularly those we dub less comfortable is 202 00:10:37,986 --> 00:10:39,796 that you're already starting off at a disadvantage. 203 00:10:39,796 --> 00:10:42,636 My god, this student sitting next to me was programming 204 00:10:42,636 --> 00:10:44,096 since he or she was 6. 205 00:10:44,096 --> 00:10:46,826 This person next to me took AP computer science, 206 00:10:46,996 --> 00:10:48,616 and that may actually be the case. 207 00:10:48,616 --> 00:10:51,406 And statistically it probably is the case to some extents 208 00:10:51,636 --> 00:10:52,906 but it really doesn't matter. 209 00:10:52,906 --> 00:10:55,236 I mean unlike a lot of the courses here 210 00:10:55,236 --> 00:10:57,696 and at universities, we really do take a much more 211 00:10:57,696 --> 00:11:01,076 individualistic approach and that is to say at the end 212 00:11:01,076 --> 00:11:04,156 of the day do we consider both upward trending, 213 00:11:04,406 --> 00:11:06,376 both your initial experience 214 00:11:06,636 --> 00:11:11,186 and also how you approach the course's projects throughout the 215 00:11:11,186 --> 00:11:12,056 course of the semester. 216 00:11:12,056 --> 00:11:13,896 You can nonetheless take the course pass fail. 217 00:11:13,896 --> 00:11:15,046 I mentioned this on Wednesday. 218 00:11:15,286 --> 00:11:17,316 This is actually something very near and dear to my heart 219 00:11:17,316 --> 00:11:19,456 because I literally would not be doing what I do 220 00:11:19,456 --> 00:11:22,266 in life today had I not taken a couple of courses here, 221 00:11:22,266 --> 00:11:24,126 this one in particular, pass fail. 222 00:11:24,126 --> 00:11:26,996 It helped me in my mind sort of take that step 223 00:11:27,106 --> 00:11:29,236 that I was otherwise just a little too hesitant 224 00:11:29,236 --> 00:11:30,506 to take my freshman year. 225 00:11:30,686 --> 00:11:31,986 And then for a lot of students too, 226 00:11:31,986 --> 00:11:35,636 what this mechanism does is it just takes the edge off a course 227 00:11:35,636 --> 00:11:36,086 like this. 228 00:11:36,086 --> 00:11:37,506 Odds are if you're an upperclassman, 229 00:11:37,726 --> 00:11:40,666 you've had that experience where it's 12 AM, 1 AM, 2 AM, 230 00:11:40,666 --> 00:11:43,666 and you're really starting to stress over the incompletion 231 00:11:43,666 --> 00:11:45,166 of some problems that for some course, 232 00:11:45,376 --> 00:11:47,476 well frankly what this mechanism allows you to do 233 00:11:47,476 --> 00:11:49,436 if you're already 90 percent of the way there, 234 00:11:49,766 --> 00:11:52,316 you can call it a night and you can put it down 235 00:11:52,316 --> 00:11:53,686 and you could feel good nonetheless 236 00:11:53,956 --> 00:11:55,116 about where you got to. 237 00:11:55,116 --> 00:11:57,986 And that in my mind is one of the upsides of taking a course 238 00:11:57,986 --> 00:12:01,636 like this, pass fail, in order to take the edge off. 239 00:12:01,696 --> 00:12:04,056 The course is not FYI graded on the curve. 240 00:12:04,056 --> 00:12:07,196 There is no pre-determined cutoffs between letter grades 241 00:12:07,196 --> 00:12:08,486 for those who do take letter grades, 242 00:12:08,676 --> 00:12:11,606 and those less comfortable and somewhere in between are not 243 00:12:11,746 --> 00:12:12,546 at a disadvantage 244 00:12:12,546 --> 00:12:14,356 as the syllabus promises vis-a-vis those 245 00:12:14,636 --> 00:12:15,896 more comfortable. 246 00:12:15,896 --> 00:12:18,906 We do in fact-- I do have conversations with all 30 plus 247 00:12:18,906 --> 00:12:21,406 of the teaching fellows about all 300 plus of the students 248 00:12:21,576 --> 00:12:22,526 at the end of the semester, 249 00:12:22,866 --> 00:12:25,596 and that is in the end what determines the outcome. 250 00:12:25,826 --> 00:12:27,626 So some of the mechanisms that are in place now 251 00:12:27,626 --> 00:12:31,556 to make the next several weeks among the most memorable 252 00:12:31,556 --> 00:12:32,376 of experiences. 253 00:12:32,376 --> 00:12:33,536 So with the problems, that is 254 00:12:33,536 --> 00:12:35,406 where you really will get your hands dirty 255 00:12:35,546 --> 00:12:37,686 and truly immerse yourself in this world 256 00:12:37,686 --> 00:12:39,186 of computer science and programming. 257 00:12:39,436 --> 00:12:42,036 But life happens, stuff comes up with sports, 258 00:12:42,036 --> 00:12:43,626 with student groups, with elements and the like. 259 00:12:43,856 --> 00:12:46,516 So the course very generously offers 9 late days 260 00:12:46,516 --> 00:12:48,346 that you can spend accurate discretion throughout 261 00:12:48,346 --> 00:12:48,906 the semester. 262 00:12:49,126 --> 00:12:50,826 You can take one late day on one piece set, 263 00:12:50,826 --> 00:12:52,576 9 late days on one piece set. 264 00:12:52,916 --> 00:12:56,496 It really is up to you to manage throughout the term. 265 00:12:56,496 --> 00:13:00,266 We also drop the lowest score on a problem set and also lest 266 00:13:00,476 --> 00:13:02,896 in my appeal in the last lecture 267 00:13:02,896 --> 00:13:05,376 in this sounds a little too tailored 268 00:13:05,376 --> 00:13:08,516 to only those less comfortable realize too those more 269 00:13:08,516 --> 00:13:09,856 comfortable as we'll see today. 270 00:13:10,146 --> 00:13:13,146 For those do we offer what we call hacker editions 271 00:13:13,146 --> 00:13:14,256 of each of the problem sets. 272 00:13:14,256 --> 00:13:16,406 We do expect the majority of the students to tackle, 273 00:13:16,606 --> 00:13:19,316 as you'll see tonight when the PDFs go online at 7 PM, 274 00:13:19,536 --> 00:13:21,776 the so called standard edition of each problem set. 275 00:13:22,046 --> 00:13:24,426 But if you are so inclined whether for this problem set 276 00:13:24,426 --> 00:13:26,096 or any other throughout the term, 277 00:13:26,096 --> 00:13:27,586 you can change your mind week to week. 278 00:13:27,906 --> 00:13:31,186 Do you have available to you what we call the hacker editions 279 00:13:31,186 --> 00:13:34,866 in more details on those in the courses syllabus? 280 00:13:35,416 --> 00:13:38,166 And besides that, lest that not be enough 281 00:13:38,566 --> 00:13:41,546 to make sure everyone can succeed in a course like this, 282 00:13:41,756 --> 00:13:44,736 we have a very diligent teaching fellow who not only likes 283 00:13:44,776 --> 00:13:47,096 to scribe the courses lectures. 284 00:13:47,096 --> 00:13:50,496 It's not much fun to read 20 pages of my verbal text written. 285 00:13:50,756 --> 00:13:54,586 But having a few pages of authoritative note do exist. 286 00:13:54,666 --> 00:13:56,656 The teaching fellow for each lecture takes what we call 287 00:13:56,656 --> 00:13:57,306 scribe notes. 288 00:13:57,306 --> 00:13:59,166 These are posted within a few days online. 289 00:13:59,406 --> 00:14:01,116 He likes to include some snarky comments 290 00:14:01,116 --> 00:14:02,966 on the footnotes generally about me at my expense. 291 00:14:02,966 --> 00:14:04,536 So keep an eye up for those. 292 00:14:04,536 --> 00:14:07,406 And the point of this is so that you don't come to class heads 293 00:14:07,406 --> 00:14:10,286 down the whole time thinking everything I say is absolutely 294 00:14:10,286 --> 00:14:11,476 worthy of being written down. 295 00:14:11,786 --> 00:14:14,066 Ideally like we started today, it will be a bit more 296 00:14:14,316 --> 00:14:16,606 like a conversation to the extent that's possible 297 00:14:16,826 --> 00:14:17,686 in a theater like this. 298 00:14:17,986 --> 00:14:21,106 One hundred fifty plus office hours is the current tally 299 00:14:21,106 --> 00:14:23,326 that you'll see starting to appear on the course's website, 300 00:14:23,326 --> 00:14:24,956 thanks to our 60 plus person staff 301 00:14:25,236 --> 00:14:28,356 and you'll also see online soon once you have your accounts 302 00:14:28,356 --> 00:14:31,626 as per problem set 0 spec. For the course's website, 303 00:14:31,626 --> 00:14:35,276 there'll be support forms and an email address, help@cs50.net, 304 00:14:35,576 --> 00:14:38,406 that you can turn to and frankly this is more a commentary 305 00:14:38,406 --> 00:14:41,146 on our lack of social lives during the term. 306 00:14:41,446 --> 00:14:44,646 But we pride ourselves generally on 5 or so minute response times 307 00:14:44,646 --> 00:14:45,906 at most hours during the day. 308 00:14:47,046 --> 00:14:50,486 So, it's a sick obsession with some of us, myself included. 309 00:14:50,696 --> 00:14:53,256 So with that said, what can you do? 310 00:14:53,256 --> 00:14:56,396 So this is such a silly thing, but 15 years ago, 311 00:14:56,396 --> 00:14:59,686 I took this course followed by a course called CS51 and then sat 312 00:14:59,876 --> 00:15:02,916 down one night and then I'm spending the next week 313 00:15:02,916 --> 00:15:06,196 on this project even though I lived in Mather House, 314 00:15:06,196 --> 00:15:08,746 never really was the shuttling type on a lot of quad friends 315 00:15:08,746 --> 00:15:10,696 who did, and this was kind of interesting to me. 316 00:15:10,696 --> 00:15:12,746 There was this big printout of the shuttle schedule 317 00:15:13,006 --> 00:15:15,066 and this was not a very navigable document. 318 00:15:15,066 --> 00:15:18,116 Certainly this is like mid 1990s, we did have the web 319 00:15:18,116 --> 00:15:19,876 and the internet but things were slow 320 00:15:19,876 --> 00:15:21,276 and it just wasn't really conducive 321 00:15:21,276 --> 00:15:24,456 to actually finding things quickly unless you really gave 322 00:15:24,456 --> 00:15:25,596 some thought to the problem. 323 00:15:25,766 --> 00:15:27,516 So I sat down over the course of a week 324 00:15:27,516 --> 00:15:31,176 and implement what I probably shouldn't have called Shuttleboy 325 00:15:31,176 --> 00:15:33,646 at the time 'cause this jargon has lived on. 326 00:15:34,036 --> 00:15:37,256 And this is now a program that's web based, it's SMS based, 327 00:15:37,256 --> 00:15:41,756 it's voice based and it used to be Linux based as you'll see 328 00:15:41,756 --> 00:15:44,036 in a couple of weeks and it's just a program 329 00:15:44,036 --> 00:15:46,346 that let's you click where you are, click where you wanna go 330 00:15:46,346 --> 00:15:48,776 and voila, here are the next several shuttles 331 00:15:48,826 --> 00:15:49,666 that you can take. 332 00:15:49,896 --> 00:15:52,356 I thought I'd give you a little glimpse at what you can do 333 00:15:52,666 --> 00:15:54,986 for your final project toward terms end. 334 00:15:54,986 --> 00:15:59,626 We own our own phone number, that allows you 335 00:15:59,626 --> 00:16:02,916 to input key strokes like you would any system 336 00:16:02,996 --> 00:16:07,446 and this is an example of what we call CS50 Voice. 337 00:16:07,556 --> 00:16:10,586 And that's an example of someone else's phone. 338 00:16:10,586 --> 00:16:11,206 [ Laughter ] 339 00:16:11,206 --> 00:16:12,426 >> This is CS50. 340 00:16:12,736 --> 00:16:14,546 For Shuttleboy, press 1. 341 00:16:14,906 --> 00:16:17,516 To start over, Press 0. 342 00:16:17,516 --> 00:16:20,696 What is your origin? 343 00:16:20,926 --> 00:16:27,296 For Quad, press 1; Mather, press 2; Boylston, press 3; Lamont, 344 00:16:27,666 --> 00:16:33,036 press 4; Mem Hall, press 5; to start over, press 0. 345 00:16:33,036 --> 00:16:34,906 >> So press 1 for Quad. 346 00:16:35,536 --> 00:16:40,016 >> The next shuttle leaves in 2 minutes at 1:30 PM and then 347 00:16:40,016 --> 00:16:46,846 at 1:40 PM, 1:50 PM and 2 PM. 348 00:16:46,846 --> 00:16:47,786 This is CS50. 349 00:16:47,786 --> 00:16:48,916 >> So that is only-- 350 00:16:48,916 --> 00:16:49,236 [ Laughter ] 351 00:16:49,236 --> 00:16:53,656 >> That is only option 1. 352 00:16:53,656 --> 00:16:56,036 We have like 9 more slots to fill. 353 00:16:56,036 --> 00:16:58,316 So that's 9 potential final projects that can live 354 00:16:58,316 --> 00:17:01,246 on in telephone form toward semester's end. 355 00:17:01,246 --> 00:17:03,896 And we will show you exactly how you can write programs 356 00:17:03,896 --> 00:17:07,226 that actually interact with the user in that way. 357 00:17:07,466 --> 00:17:11,396 And just as a fun aside, we also realized as computer scientists 358 00:17:11,396 --> 00:17:13,686 that sometimes technology is not the answer. 359 00:17:13,686 --> 00:17:16,946 This is an unfortunate thing you see throughout education 360 00:17:16,946 --> 00:17:19,146 frankly, certainly at the secondary 361 00:17:19,146 --> 00:17:21,386 and primary school level where you just insert technology 362 00:17:21,386 --> 00:17:23,226 into the classroom and expect to solve problems, 363 00:17:23,456 --> 00:17:25,636 that is not in life always the case. 364 00:17:25,676 --> 00:17:28,626 Sometimes the simplest solutions are in fact the best 365 00:17:28,626 --> 00:17:32,176 and thus consistent with this constant reminder 366 00:17:32,176 --> 00:17:35,536 to ourselves was born last year what we dubbed Shuttleboy Cards. 367 00:17:35,536 --> 00:17:37,886 Now granted we're now starting to take this all shuttle theme 368 00:17:37,886 --> 00:17:40,536 to an extreme perhaps, but we realized you know what, 369 00:17:40,536 --> 00:17:42,706 it's actually not that efficient sometimes 370 00:17:42,706 --> 00:17:44,706 to call a phone number, it's not that efficient 371 00:17:44,706 --> 00:17:45,956 to pull up the mobile web. 372 00:17:46,226 --> 00:17:48,126 Sometimes it's a lot easier to reach into your wallet, 373 00:17:48,316 --> 00:17:50,046 pull out a piece of plastic and voila, 374 00:17:50,246 --> 00:17:51,736 there are the next several shuttle times. 375 00:17:51,736 --> 00:17:54,486 We mention this only because we're just going to press 376 00:17:54,486 --> 00:17:56,856 with the latest incarnation of this this year. 377 00:17:57,096 --> 00:17:59,556 So if you go back to shuttleboy.cs50.net, 378 00:17:59,836 --> 00:18:02,446 you can pre-order for free your own CS50 shuttle card, 379 00:18:02,446 --> 00:18:05,836 particularly those of you in the Quad, Mather and the like. 380 00:18:06,076 --> 00:18:09,916 So, what does that mean as you exit a course like this? 381 00:18:09,916 --> 00:18:12,486 Well really, the things we've looked at thus far can you do 382 00:18:12,486 --> 00:18:15,816 after just a semester of this kind of material and exposure 383 00:18:15,816 --> 00:18:17,246 to this particular world. 384 00:18:17,476 --> 00:18:18,976 I just wanted to draw your attention to some 385 00:18:18,976 --> 00:18:21,386 of the handouts we had Wednesday which are still available today 386 00:18:21,386 --> 00:18:22,926 if you didn't yet get them. 387 00:18:22,926 --> 00:18:26,186 This is targeted for the most part at students 388 00:18:26,186 --> 00:18:28,576 who might want a major or minor in computer science, 389 00:18:28,616 --> 00:18:30,516 but there's also some interesting detail toward the 390 00:18:30,516 --> 00:18:33,146 end of this document, if and when you get a chance to peruse, 391 00:18:33,146 --> 00:18:35,646 including this chart that shows you the pathways 392 00:18:35,646 --> 00:18:37,776 that you can take throughout computer science here, 393 00:18:38,006 --> 00:18:40,626 sort of recommend it or popular courses that students tend 394 00:18:40,626 --> 00:18:43,526 to take even if they are in the humanities or life sciences 395 00:18:43,526 --> 00:18:47,106 or social sciences but want to round out their education here 396 00:18:47,106 --> 00:18:50,236 with something in the computing sciences do we have quads 397 00:18:50,366 --> 00:18:54,536 of courses recommended in the back that you can take after 50 398 00:18:54,536 --> 00:18:56,376 in order to get a minor in this stuff. 399 00:18:56,556 --> 00:18:59,426 And frankly this kind of stuff, this visualization of data, 400 00:18:59,426 --> 00:19:02,966 this is one of the themes of a course here called CS171, 401 00:19:02,966 --> 00:19:05,126 visualizations, which we'll actually learn-- 402 00:19:05,156 --> 00:19:07,726 hear a bit about toward the end of the semester and it's all 403 00:19:07,726 --> 00:19:09,896 about taking data that might very well have come 404 00:19:09,896 --> 00:19:12,196 out of a computer and trying to decide what is 405 00:19:12,196 --> 00:19:14,556 in fact the best way to present this data. 406 00:19:14,836 --> 00:19:17,466 To be honest, especially those of you less comfortable here, 407 00:19:17,466 --> 00:19:21,076 if you've ever struggled with some program or struggled 408 00:19:21,076 --> 00:19:22,326 with some piece of software, 409 00:19:22,616 --> 00:19:24,336 oh it's alright, it's not your fault. 410 00:19:24,336 --> 00:19:26,486 It just really wasn't designed very well. 411 00:19:26,706 --> 00:19:29,586 So actually thinking about how humans interact with machines 412 00:19:29,586 --> 00:19:32,866 and how you can optimize your so called user interface 413 00:19:33,146 --> 00:19:36,496 or GUI interface is also one of the themes 414 00:19:36,576 --> 00:19:38,246 in this particular field. 415 00:19:38,246 --> 00:19:42,746 So, we ended Wednesday with some quotes, particularly 416 00:19:42,746 --> 00:19:45,206 from isawyouharvard.com, we thought it would be fun 417 00:19:45,206 --> 00:19:46,556 to just give you a couple of teasers 418 00:19:46,556 --> 00:19:49,616 from another favorite website of ours, 419 00:19:49,616 --> 00:19:52,826 a little something called Harvard FML, search for CS50 420 00:19:52,866 --> 00:19:55,446 and you see some choice quotes like this. 421 00:19:56,706 --> 00:19:58,576 I talk about CS50 so much 422 00:19:58,576 --> 00:20:00,956 that my teammates implemented a CS50 talk tax. 423 00:20:01,226 --> 00:20:03,206 >> I get charged one dollar for each mention of the class. 424 00:20:03,696 --> 00:20:06,086 I already owed 20 dollars and haven't been able to talk 425 00:20:06,086 --> 00:20:07,106 for more than five minutes 426 00:20:07,206 --> 00:20:10,256 without getting called out on it FML. 427 00:20:11,086 --> 00:20:13,726 This is what happens over time as does-- whoops! 428 00:20:13,726 --> 00:20:14,386 Did I miss one there? 429 00:20:14,756 --> 00:20:17,756 This is what may, in fact, happen to you over time. 430 00:20:17,846 --> 00:20:19,606 We are a recurring theme it seems 431 00:20:19,606 --> 00:20:20,996 on that particular website. 432 00:20:21,386 --> 00:20:23,606 So now, let's make things a little more technical 433 00:20:23,606 --> 00:20:24,056 for a moment. 434 00:20:24,056 --> 00:20:26,346 Those of you more comfortable, rest assured we'll start filling 435 00:20:26,346 --> 00:20:27,596 in some gaps before long 436 00:20:27,596 --> 00:20:28,786 if you're already familiar with this. 437 00:20:29,096 --> 00:20:32,186 But all of you in this room probably remember what we 438 00:20:32,246 --> 00:20:35,956 technically call the base 10 system or decimal system 439 00:20:35,956 --> 00:20:39,146 because back in grade school or the like, you learned to count 440 00:20:39,146 --> 00:20:42,126 and add and subtract numbers by way of columns. 441 00:20:42,156 --> 00:20:45,516 The so called ones column on the right, the tens column next 442 00:20:45,516 --> 00:20:48,886 to it, the hundreds column, the thousands column, and so forth. 443 00:20:48,886 --> 00:20:53,756 So if you had some number back in grade school like 123, well, 444 00:20:53,756 --> 00:20:56,956 why do we express this as 123? 445 00:20:56,996 --> 00:20:59,386 When really I just see on the board 1, 2, 3? 446 00:20:59,666 --> 00:21:00,686 Well, we have what? 447 00:21:01,016 --> 00:21:03,766 One in the so called hundreds columns, a two in the 448 00:21:03,766 --> 00:21:07,476 so called tens column so that's 10 times 1 plus 10 times 2 is 449 00:21:07,476 --> 00:21:11,806 120, plus 3 times 1, 123 alright, 450 00:21:11,806 --> 00:21:15,296 so completely uninteresting, if this is something long familiar 451 00:21:15,296 --> 00:21:17,136 to you, but it turns out computers work 452 00:21:17,136 --> 00:21:18,466 in exactly the same way. 453 00:21:18,686 --> 00:21:21,646 The so called binary system, these zeros and ones 454 00:21:21,906 --> 00:21:24,576 that you'd probably have some vague sense underlie all 455 00:21:24,576 --> 00:21:26,676 computers today actually reduced 456 00:21:26,676 --> 00:21:30,336 to the exact same grade school kind of math and system except 457 00:21:30,546 --> 00:21:32,946 with computers, because it's a lot easier 458 00:21:32,946 --> 00:21:36,146 to use just two digits, zero and one. 459 00:21:36,436 --> 00:21:39,726 Do they use only columns like with the ones column, 460 00:21:39,906 --> 00:21:43,046 the twos columns, the fours column, and the eights column? 461 00:21:43,276 --> 00:21:46,506 And if you noticed earlier that these are what we'd call powers 462 00:21:46,506 --> 00:21:48,896 of ten, these are just powers of two. 463 00:21:49,066 --> 00:21:50,466 So if you need more-- 464 00:21:50,466 --> 00:21:53,116 bigger numbers, you just have a 16's column 465 00:21:53,116 --> 00:21:55,406 and a 32's column, and so forth. 466 00:21:55,446 --> 00:21:56,726 So what's the takeaway here? 467 00:21:56,916 --> 00:21:59,346 Well, if we actually want to represent something 468 00:21:59,346 --> 00:22:03,466 like the number 7, well in binary, 469 00:22:03,516 --> 00:22:05,896 not actually in decimal like this. 470 00:22:06,166 --> 00:22:07,046 Well, what do we do? 471 00:22:07,046 --> 00:22:11,046 If we need a 7, this is the ones column, the twos, fours, eights, 472 00:22:11,786 --> 00:22:14,506 so here are our columns and this was our decimal system a moment 473 00:22:14,506 --> 00:22:16,626 ago, and I wanna express the number 7 474 00:22:16,626 --> 00:22:20,976 and the only digits I now have access to are zero and one, 475 00:22:21,156 --> 00:22:23,046 whereas, in decimal, dec meaning 10. 476 00:22:23,046 --> 00:22:25,676 I had zero to 9, which was 10, zero and 1, 477 00:22:25,676 --> 00:22:27,676 bi meaning two, high binary numbers. 478 00:22:28,156 --> 00:22:30,846 I can only put a zero or 1 in each of these slides. 479 00:22:31,056 --> 00:22:33,486 But after that, the math is the same, eight times whatever, 480 00:22:33,486 --> 00:22:36,026 four times whatever, two times whatever, and so forth. 481 00:22:36,106 --> 00:22:36,776 So what's 7? 482 00:22:38,356 --> 00:22:40,986 >> Right, one, one, one and then a zero. 483 00:22:41,156 --> 00:22:42,646 And just like in the decimal system, 484 00:22:42,646 --> 00:22:45,066 you can put as many leading zeros, any-- 485 00:22:45,066 --> 00:22:46,606 as many zeros on the left that you want. 486 00:22:46,606 --> 00:22:48,056 They're completely inconsequential 487 00:22:48,316 --> 00:22:49,676 and so we now have the number 7. 488 00:22:49,676 --> 00:22:50,956 Meanwhile, the number zero is? 489 00:22:51,846 --> 00:22:54,856 Alright, it's all zeros so I'll-- just for consistency, 490 00:22:54,856 --> 00:22:57,496 use four of them here, but that's just an aesthetic. 491 00:22:57,696 --> 00:23:00,116 And I mentioned on Wednesday that computer scientists do 492 00:23:00,116 --> 00:23:02,506 in fact start counting from zero not one. 493 00:23:02,786 --> 00:23:04,006 Well, this is pretty much why. 494 00:23:04,006 --> 00:23:06,546 Because if you ever hold-- the numbering system reduces 495 00:23:06,546 --> 00:23:10,076 to this basic idea of zeros and ones, each of which is 496 00:23:10,076 --> 00:23:11,316 in a certain column, each 497 00:23:11,316 --> 00:23:13,496 of which has some weights associated 498 00:23:13,496 --> 00:23:15,026 with it, it's just natural. 499 00:23:15,026 --> 00:23:16,936 It's obvious to start counting at zero. 500 00:23:16,936 --> 00:23:20,496 Otherwise, you're wasting a bit, so to speak, unnecessarily. 501 00:23:20,496 --> 00:23:24,256 And a bit, B-I-T, just a shorthand for binary digit, 502 00:23:24,576 --> 00:23:26,706 so a digit of zero over a one, bi means two, 503 00:23:26,706 --> 00:23:27,686 you only have two digits. 504 00:23:27,686 --> 00:23:30,166 Hence, the word bit was born. 505 00:23:30,406 --> 00:23:32,136 So just as a little sanity check, 506 00:23:32,256 --> 00:23:35,356 number 15 in binary would be? 507 00:23:36,096 --> 00:23:42,026 Just four ones, and how about the number 65,535? 508 00:23:42,836 --> 00:23:46,156 Anyone? You know you're a nerd if-- 509 00:23:46,516 --> 00:23:49,516 so 16 of those ones will give you that particular number. 510 00:23:49,516 --> 00:23:51,136 And I can't, myself, go higher than that 511 00:23:51,326 --> 00:23:53,086 but you could certainly do it mathematically. 512 00:23:53,086 --> 00:23:54,276 Now this is not the kind of stuff 513 00:23:54,276 --> 00:23:56,036 that computer scientists spend all their time doing, 514 00:23:56,306 --> 00:23:57,496 but it will germane. 515 00:23:57,496 --> 00:23:59,696 In fact, midway through the semester, when we look 516 00:23:59,696 --> 00:24:03,296 at the notion of digital forensics and recovering things 517 00:24:03,326 --> 00:24:06,476 like JPEGS and representing files like JPEGS and JIPS 518 00:24:06,476 --> 00:24:08,616 and the like on disk we're actually gonna have 519 00:24:08,616 --> 00:24:12,696 to revisit this idea of actually storing information in zero 520 00:24:12,696 --> 00:24:16,346 or one form and so it's going to become relevant 521 00:24:16,566 --> 00:24:18,616 as to how you represent these numbers on disk, 522 00:24:18,616 --> 00:24:20,316 how you manipulate these numbers on disk, 523 00:24:20,676 --> 00:24:24,436 but this really only gives us the ability to express numbers 524 00:24:24,476 --> 00:24:25,596 at this point in time. 525 00:24:25,906 --> 00:24:27,876 We ultimately wanna be able to express letters 526 00:24:27,876 --> 00:24:29,606 so we can implement things like Gmail 527 00:24:29,606 --> 00:24:31,646 and actually implement text on the screen. 528 00:24:31,996 --> 00:24:32,976 So how do we do that? 529 00:24:33,286 --> 00:24:38,216 Well first, a cartoon that you might now actually get those 530 00:24:38,596 --> 00:24:39,846 otherwise unfamiliar. 531 00:24:40,516 --> 00:24:47,696 [ Pause ] 532 00:24:48,196 --> 00:24:50,466 >> See this happens every semester that the chuckles, 533 00:24:50,466 --> 00:24:52,546 the grimaces, kind of roll through the crowd 534 00:24:52,546 --> 00:24:54,586 as people catch on, but there you go. 535 00:24:54,586 --> 00:24:56,056 Now, you get geek humor. 536 00:24:56,056 --> 00:24:58,446 And for better or for worse we've done a lot of damage 537 00:24:58,446 --> 00:24:59,716 over the past few years for this stuff. 538 00:24:59,976 --> 00:25:02,256 When you get more and more acquainted with geek humor 539 00:25:02,256 --> 00:25:05,506 from the likes of this is Foxtrot XKCD is popular, 540 00:25:05,506 --> 00:25:08,316 Ph.D. comics, there's a whole bunch of geekery out there 541 00:25:08,316 --> 00:25:11,146 that will perhaps turn to-- so that you do exit this course 542 00:25:11,146 --> 00:25:13,986 as a complete side effect with an understanding 543 00:25:13,986 --> 00:25:16,866 as to why it was funny or at least awkward that we did, 544 00:25:16,866 --> 00:25:20,016 in fact on Wednesday, have a CAT pictured in a ceiling. 545 00:25:20,296 --> 00:25:24,496 So, how do you go from just numbers, zeros and ones 546 00:25:24,496 --> 00:25:26,126 to actually useful information? 547 00:25:26,256 --> 00:25:29,566 Well it turns out a bunch of years ago people just decided 548 00:25:29,836 --> 00:25:32,606 that if we have the ability to express numbers 549 00:25:32,796 --> 00:25:35,076 and we actually care about expressing letters 550 00:25:35,076 --> 00:25:37,566 of the alphabet, well we just need some kind of mapping 551 00:25:37,566 --> 00:25:38,856 between one and the other, 552 00:25:39,076 --> 00:25:41,786 and so thus was born what's generally called the ASCII. 553 00:25:42,086 --> 00:25:44,936 This is just an acronym that you still see and use today, 554 00:25:44,936 --> 00:25:47,206 though there were newer systems that are more expressive 555 00:25:47,256 --> 00:25:49,906 for other languages, non-romance languages. 556 00:25:50,156 --> 00:25:51,486 But ASCII is just a code. 557 00:25:51,656 --> 00:25:53,256 This might look a little cryptic at first, 558 00:25:53,446 --> 00:25:56,276 but it turns there is some very obvious patterns here, 559 00:25:56,276 --> 00:25:56,936 for instance. 560 00:25:56,936 --> 00:26:01,136 According to this chart, if you want to represent the letter A 561 00:26:01,136 --> 00:26:03,776 in the so called ASCII system, 562 00:26:03,776 --> 00:26:06,216 what number do you actually use to do so? 563 00:26:06,716 --> 00:26:07,806 >> Ninety-seven? 564 00:26:07,806 --> 00:26:08,396 >> So, okay. 565 00:26:08,396 --> 00:26:13,086 So lower case A would be 97 and upper case A would be 65. 566 00:26:13,316 --> 00:26:14,646 So this is kind of a nice chichi. 567 00:26:14,686 --> 00:26:16,306 Now, once you know each of those, 568 00:26:16,306 --> 00:26:18,586 you can now do 25 more upper case letters 569 00:26:18,586 --> 00:26:21,406 and 25 more lower case letters then there are some other stuff 570 00:26:21,406 --> 00:26:23,256 like punctuation and things you see on the keyboard. 571 00:26:23,256 --> 00:26:25,796 All of those do need their own encodings, but at the end 572 00:26:25,796 --> 00:26:27,656 of the day, if you already knew coming into this class 573 00:26:28,056 --> 00:26:30,786 that your computer stores information, somehow, 574 00:26:31,036 --> 00:26:33,616 using zeros and ones, well it turns out that 575 00:26:33,616 --> 00:26:37,316 if you have typed the letter A on your keyboard and thus need 576 00:26:37,316 --> 00:26:39,796 to store that inside of your computer, well, 577 00:26:39,796 --> 00:26:44,256 how do you actually go from numbers to that letter and back? 578 00:26:44,886 --> 00:26:47,636 Well again, we can go to our ones column, twos, 579 00:26:47,726 --> 00:26:51,646 four, eight, 16, damn, 32. 580 00:26:51,646 --> 00:27:00,996 So we can go to 32 and then we can go to 64, and then 128, 581 00:27:00,996 --> 00:27:04,836 and this gives me 1, 2, 3, 4, 5, 6, 7, 8. 582 00:27:05,276 --> 00:27:06,326 So this is intentional. 583 00:27:06,326 --> 00:27:08,846 I now have eight columns, though sloppily written there, 584 00:27:09,126 --> 00:27:10,806 eight columns or 8 bits. 585 00:27:11,176 --> 00:27:12,876 So this is what we know as a byte. 586 00:27:13,166 --> 00:27:15,286 You've probably been surrounded for years now by bytes 587 00:27:15,286 --> 00:27:17,746 and kilobytes, and megabytes and terabytes, and the like. 588 00:27:17,956 --> 00:27:20,206 Well, this is just a way of saying not bits, 589 00:27:20,536 --> 00:27:22,806 but units of eight bits at a time. 590 00:27:22,806 --> 00:27:23,786 Why is this useful? 591 00:27:23,786 --> 00:27:25,996 Well one bit, really not all that useful, 592 00:27:25,996 --> 00:27:27,726 two bits still not all that useful. 593 00:27:27,726 --> 00:27:28,236 Eight bits? 594 00:27:28,356 --> 00:27:30,136 Starting to get useful because, 595 00:27:30,136 --> 00:27:33,286 in fact with eight bits can you implement things like this? 596 00:27:33,786 --> 00:27:38,586 So with eight bits can you express 256 possible characters? 597 00:27:38,936 --> 00:27:40,086 That's pretty good 'cause now, 598 00:27:40,086 --> 00:27:42,416 I can pretty much cover my American keyboard pretty 599 00:27:42,416 --> 00:27:44,376 effectively both upper case, lower case, 600 00:27:44,376 --> 00:27:45,826 and a whole bunch of punctuation. 601 00:27:46,046 --> 00:27:49,696 For other languages as in aside, there are other encoding schemes 602 00:27:49,826 --> 00:27:51,076 when there are more characters. 603 00:27:51,286 --> 00:27:54,236 So what would be the letter A in binary inside 604 00:27:54,236 --> 00:27:56,546 of a computer's memory when you hit the letter A 605 00:27:56,546 --> 00:27:58,666 on the keyboard, for capital A? 606 00:27:59,696 --> 00:28:01,506 >> Zero, one, zero, zero, zero, zero, zero, one. 607 00:28:01,896 --> 00:28:05,186 >> Zero, one, zero, zero, zero, zero, zero, one. 608 00:28:05,426 --> 00:28:08,636 And so this, in fact, when you say your computer stores 609 00:28:08,676 --> 00:28:10,176 information as zeros and ones, 610 00:28:10,436 --> 00:28:11,986 you've just typed the capital letter A, 611 00:28:11,986 --> 00:28:14,046 that's all that's going on inside. 612 00:28:14,226 --> 00:28:16,076 Now, how is that actually being implemented? 613 00:28:16,076 --> 00:28:17,576 It actually depends on the technology. 614 00:28:17,576 --> 00:28:19,686 You probably know your computer has something called RAM 615 00:28:19,976 --> 00:28:20,926 which is where documents 616 00:28:20,926 --> 00:28:23,516 and programs live just temporarily while you're running 617 00:28:23,516 --> 00:28:25,056 them 'cause RAM tends to be pretty fast 618 00:28:25,056 --> 00:28:27,656 and whereas your hard disk is where programs 619 00:28:27,656 --> 00:28:29,076 and files live permanently. 620 00:28:29,076 --> 00:28:31,796 You can pull the cord and your files should not actually get 621 00:28:31,796 --> 00:28:33,896 deleted but the hard disks are-- 622 00:28:33,896 --> 00:28:35,666 use a different technology altogether. 623 00:28:35,666 --> 00:28:38,326 But at the end of the day, and here's why we just went 624 00:28:38,326 --> 00:28:40,736 with binary and not decimal years ago, 625 00:28:41,236 --> 00:28:44,596 when you have one implement a computer with a physical device, 626 00:28:45,306 --> 00:28:47,046 it's actually really easy 627 00:28:47,226 --> 00:28:50,636 to represent the notion of on or off. 628 00:28:50,826 --> 00:28:51,856 Consider a light switch. 629 00:28:51,856 --> 00:28:54,666 You can go on or you can go off and actually, 630 00:28:54,926 --> 00:28:56,656 how about some gratuitous use of technology? 631 00:28:56,976 --> 00:28:59,456 For those of you for-- with iPhone 4, by far, 632 00:28:59,456 --> 00:29:03,216 the most useful application for 99 cents is this flashlight 633 00:29:03,216 --> 00:29:03,946 in the middle of the night. 634 00:29:04,436 --> 00:29:06,196 So this might represent a one. 635 00:29:06,756 --> 00:29:08,256 This now represents a zero. 636 00:29:08,536 --> 00:29:11,996 One, zero, one-- promise it gets more interesting, zero. 637 00:29:12,426 --> 00:29:14,516 So why is this germane? 638 00:29:14,516 --> 00:29:17,756 Well, if you're implementing a computer that needs 639 00:29:17,756 --> 00:29:20,066 to represent information now all you need is something 640 00:29:20,066 --> 00:29:23,826 like electricity which can be on or off, on or off. 641 00:29:23,826 --> 00:29:25,706 And when you actually wanna store information on disk, 642 00:29:25,706 --> 00:29:27,936 can you actually use, as we'll see 643 00:29:27,936 --> 00:29:29,696 in a moment, magnetic particles. 644 00:29:29,756 --> 00:29:33,316 But just to hammer home this point, if I could, we have time 645 00:29:33,366 --> 00:29:35,876 for one awkward demonstration. 646 00:29:36,646 --> 00:29:40,836 And for that I need a byte of volunteers, alright? 647 00:29:41,486 --> 00:29:44,056 First eight hands that I saw we're roughly in here. 648 00:29:44,056 --> 00:29:48,706 So come on up and I'll-- okay, one, two, three, four, five-- 649 00:29:48,706 --> 00:29:52,216 five, six, seven, eight. 650 00:29:52,216 --> 00:29:53,396 But you have to be comfortable on stage, 651 00:29:53,396 --> 00:29:56,056 that's the catch 'cause this will be going 652 00:29:56,056 --> 00:29:56,706 out on the Internet. 653 00:29:57,636 --> 00:30:01,036 One, two, three, four, five, six, seven-- sure, come on up, 654 00:30:01,036 --> 00:30:02,936 and the eighth person to stand up right here. 655 00:30:03,236 --> 00:30:04,706 >> Come on up. 656 00:30:04,706 --> 00:30:07,636 Okay. So we now have a byte's worth of volunteers. 657 00:30:07,636 --> 00:30:09,516 Why don't we use this side of the stage 658 00:30:09,516 --> 00:30:10,786 and I'll make some room for you. 659 00:30:11,016 --> 00:30:15,986 You are the 128th's column, you're the 64's, 32's, 16's, 660 00:30:17,306 --> 00:30:20,916 8's, and we're gonna have to fix this slightly in a moment. 661 00:30:22,346 --> 00:30:24,396 Otherwise the math is gonna get completely screwed up. 662 00:30:24,666 --> 00:30:26,566 So if you guys could come over here 663 00:30:26,566 --> 00:30:28,106 but still maintain your alignment 664 00:30:28,106 --> 00:30:30,666 so 128 should be all the way over here and one, 665 00:30:30,856 --> 00:30:32,736 you should be all the way over here 666 00:30:32,926 --> 00:30:34,606 and you guys similarly need to shuffle. 667 00:30:35,356 --> 00:30:37,326 And if you wanna come up closer to the stage 668 00:30:37,326 --> 00:30:40,626 where everyone can see you? 669 00:30:41,016 --> 00:30:44,526 Alright! We now have a byte's worth of volunteers. 670 00:30:44,746 --> 00:30:46,966 Now fortunately this time, it's not speaking role. 671 00:30:46,966 --> 00:30:51,606 You just need to express in ASCII character, one at a time, 672 00:30:51,816 --> 00:30:54,546 and these brave souls are simply going to spell something 673 00:30:54,546 --> 00:30:56,786 out for us to hammer home this point of binary. 674 00:30:57,006 --> 00:30:59,306 Now, each of you is essentially a place holder or a column. 675 00:30:59,476 --> 00:31:02,186 Why don't we have you, when the time comes, raise your hand 676 00:31:02,286 --> 00:31:04,196 if you're supposed to be representing a one? 677 00:31:04,526 --> 00:31:08,236 So on, and or true, is another way we generally put this. 678 00:31:08,456 --> 00:31:11,166 And if you're our zero just continue standing there 679 00:31:11,166 --> 00:31:12,206 awkwardly, alright. 680 00:31:12,676 --> 00:31:15,026 So with that said, we have a three-letter word 681 00:31:15,026 --> 00:31:17,476 so we'll have three rounds of hands going up or down. 682 00:31:17,696 --> 00:31:19,046 On the back, they have a little chichi 683 00:31:19,046 --> 00:31:20,366 that tells them what to do. 684 00:31:20,636 --> 00:31:24,266 So folks [laughter], otherwise this gets really awkward 685 00:31:24,266 --> 00:31:26,346 and really inaccurate quickly under pressure. 686 00:31:26,346 --> 00:31:29,396 So go ahead, round one. 687 00:31:31,916 --> 00:31:32,616 That's okay. 688 00:31:33,346 --> 00:31:37,386 So what number first are they presenting? 689 00:31:37,476 --> 00:31:40,366 Sixty-six, right 'cause we've got one in the 64's column 690 00:31:40,366 --> 00:31:42,016 and a one in the two's column, okay. 691 00:31:42,176 --> 00:31:43,796 So now, a little chichi up top, 692 00:31:43,796 --> 00:31:44,916 they are representing the letter? 693 00:31:44,916 --> 00:31:44,983 >> B. 694 00:31:45,716 --> 00:31:49,236 >> Okay B. Alright, so a little pause, just to let that sink in. 695 00:31:50,256 --> 00:31:53,066 Okay, round two, execute [laughter]. 696 00:32:00,846 --> 00:32:01,946 They really-- it says on the back 697 00:32:01,946 --> 00:32:03,086 of your seat what you should be doing. 698 00:32:04,456 --> 00:32:06,366 Alright, what number are they representing now? 699 00:32:06,866 --> 00:32:08,036 >> Seventy-nine. 700 00:32:08,236 --> 00:32:08,986 >> Seventy-nine. 701 00:32:09,346 --> 00:32:10,986 In fact, if you add up each of these numbers, 702 00:32:10,986 --> 00:32:13,196 you should get the decimal number 79 703 00:32:13,196 --> 00:32:14,586 from this binary number here. 704 00:32:14,836 --> 00:32:18,146 Seventy-nine is, of course, the letter O so we're almost there. 705 00:32:18,176 --> 00:32:19,506 Round three, go. 706 00:32:19,506 --> 00:32:23,856 And this spells? 707 00:32:24,006 --> 00:32:27,506 No it shouldn't spell boy [laughter]. 708 00:32:27,506 --> 00:32:29,446 We have an error somewhere. 709 00:32:29,706 --> 00:32:39,206 Its 87 if I did the math right myself, 87which is? 710 00:32:39,406 --> 00:32:39,836 >> Bow. 711 00:32:40,026 --> 00:32:41,686 >> Bow, so take your bow. 712 00:32:41,686 --> 00:32:42,416 Thank you very much. 713 00:32:42,916 --> 00:32:47,176 [ Applause ] 714 00:32:47,676 --> 00:32:48,026 >> Alright. 715 00:32:48,086 --> 00:32:50,616 That's the soon-- we came a little better prepared this time 716 00:32:50,616 --> 00:32:52,676 and we brought CS50 stress balls for everyone 717 00:32:52,676 --> 00:32:54,656 to make this all the more of an incentive. 718 00:32:54,656 --> 00:32:55,896 Oh, that was sweet. 719 00:32:56,076 --> 00:32:56,726 What a gift. 720 00:32:56,726 --> 00:33:00,446 Oh-- but if you can meet with our teaching fellows over there, 721 00:33:00,446 --> 00:33:02,496 they're gonna ask the legal department 722 00:33:02,556 --> 00:33:03,926 to see you next so [laughter]. 723 00:33:04,536 --> 00:33:07,006 Alright, I think we're all set. 724 00:33:07,006 --> 00:33:08,456 Is that number eight? 725 00:33:08,456 --> 00:33:09,436 Okay. Oh, you can keep that. 726 00:33:09,766 --> 00:33:10,366 You can keep that. 727 00:33:10,366 --> 00:33:16,756 Okay. So what does-- how does that actually apply 728 00:33:16,756 --> 00:33:18,376 to real computers, right? 729 00:33:18,376 --> 00:33:19,716 So this is not the most efficient way 730 00:33:19,716 --> 00:33:20,756 of representing information. 731 00:33:20,906 --> 00:33:22,816 What actually goes on underneath the hood? 732 00:33:22,976 --> 00:33:23,926 Well, it turns out some 733 00:33:23,926 --> 00:33:26,506 of you might recall this silly game from years ago. 734 00:33:26,506 --> 00:33:27,136 Wooly Willy? 735 00:33:27,136 --> 00:33:28,616 It turns out these are really hard 736 00:33:28,616 --> 00:33:30,046 to find in the 21st century. 737 00:33:30,306 --> 00:33:33,326 So these things called Wooly Willy is just a plastic-- 738 00:33:33,676 --> 00:33:36,156 it's this paper mend with a plastic cover 739 00:33:36,296 --> 00:33:39,526 and there's all these black magnetic particles here. 740 00:33:39,526 --> 00:33:42,156 And if you use this little magnet you can draw a mustache 741 00:33:42,156 --> 00:33:45,286 or hair, or eyebrows or whatever on this particular face. 742 00:33:45,536 --> 00:33:48,856 Now this is mostly irrelevant to what we're talking about except 743 00:33:48,896 --> 00:33:51,576 for the fact that there are magnetic particles involved 744 00:33:51,576 --> 00:33:54,456 and they're really small because it turns out what's inside most 745 00:33:54,456 --> 00:33:56,796 of your laptops and desktop computers are these things 746 00:33:56,796 --> 00:33:58,036 called hard drives. 747 00:33:58,036 --> 00:34:00,496 And a hard drive, if you ever open that thing up, 748 00:34:00,756 --> 00:34:04,046 is actually just a big metal container that contains one 749 00:34:04,046 --> 00:34:07,536 or more platters, so to speak, these circular pieces of metal 750 00:34:07,826 --> 00:34:09,646 and on top of those circular pieces 751 00:34:09,646 --> 00:34:14,426 of metal are essentially tiny little magnetic particles 752 00:34:14,426 --> 00:34:16,886 like this, so small that you actually can't see them. 753 00:34:16,886 --> 00:34:19,086 But if you touch them or open the hard drive 754 00:34:19,346 --> 00:34:21,636 and actually poke around, you will do damage 755 00:34:21,826 --> 00:34:22,966 because you'll mangle these-- 756 00:34:22,966 --> 00:34:24,606 the alignment of these particles. 757 00:34:24,606 --> 00:34:25,666 You'll corrupt your data. 758 00:34:25,666 --> 00:34:28,386 But what's interesting is when they're actually there, 759 00:34:28,606 --> 00:34:30,686 essentially, if this is a magnetic particle, 760 00:34:31,066 --> 00:34:34,476 you can actually represent zeros and ones pretty easily. 761 00:34:34,476 --> 00:34:36,996 You don't need a light switch or a light bulb or an iPhone app 762 00:34:36,996 --> 00:34:38,446 to turn something on or off. 763 00:34:38,666 --> 00:34:40,406 You can take something that's magnetic 764 00:34:40,406 --> 00:34:44,366 with a north-south magnetization and just say arbitrarily, 765 00:34:44,716 --> 00:34:46,076 this will represent one. 766 00:34:46,436 --> 00:34:49,236 But if its south-north, this will represent zero. 767 00:34:49,476 --> 00:34:53,066 So on your computer's hard drive are again, a whole bunch 768 00:34:53,066 --> 00:34:56,306 of tiny magnetic particles aligned this way or this way. 769 00:34:56,306 --> 00:34:59,676 And now that you have patterns of bits after bits after bits, 770 00:34:59,816 --> 00:35:02,666 and if you chunk them up into say, eight-unit quantities, 771 00:35:02,906 --> 00:35:06,426 now can you start storing words and sentences, and paragraphs. 772 00:35:06,426 --> 00:35:09,226 And as we'll see mid semester, photographs and videos 773 00:35:09,226 --> 00:35:11,256 and other more sophisticated file formats. 774 00:35:11,486 --> 00:35:13,126 It's one thing to talk about this. 775 00:35:13,406 --> 00:35:14,526 Let me go ahead and open 776 00:35:14,526 --> 00:35:19,516 up instead a more interesting graphical carnation-- 777 00:35:19,616 --> 00:35:21,466 incarnation of this. 778 00:35:21,466 --> 00:35:22,236 [ Background Music ] 779 00:35:22,236 --> 00:35:26,156 >> The hard drive is where your PC stores most 780 00:35:26,156 --> 00:35:27,296 of its permanent data. 781 00:35:27,886 --> 00:35:32,016 To do that the data travels from RAM along with software signals 782 00:35:32,086 --> 00:35:34,526 that tell the hard drive how to store that data. 783 00:35:35,266 --> 00:35:37,746 The hard drive circuits translate those signals 784 00:35:37,786 --> 00:35:39,396 into to voltage fluctuations. 785 00:35:40,126 --> 00:35:42,896 These in turn control the hard drive's moving parts. 786 00:35:43,476 --> 00:35:46,346 Some of the few moving parts left in the modern computer. 787 00:35:47,116 --> 00:35:48,756 Some of the signals control a motor 788 00:35:48,756 --> 00:35:50,636 which spins metal-coded platters. 789 00:35:51,296 --> 00:35:53,926 Your data is actually stored on these platters. 790 00:35:54,666 --> 00:35:57,706 Other signals move the read/write heads to read 791 00:35:57,706 --> 00:35:59,196 or write data on the platters. 792 00:35:59,926 --> 00:36:01,746 This machinery is so precise 793 00:36:02,236 --> 00:36:04,766 that a human hair couldn't even pass between the heads 794 00:36:04,766 --> 00:36:08,916 and spinning platters, yet it all works in terrific speeds. 795 00:36:09,386 --> 00:36:11,086 >> So if you've ever done something bad 796 00:36:11,086 --> 00:36:14,146 like drop your laptop or smack your computer 797 00:36:14,146 --> 00:36:15,926 and you've never been told not to do this. 798 00:36:15,986 --> 00:36:18,836 It's largely because-- and if you've never been, 799 00:36:18,836 --> 00:36:20,426 don't do this, it's largely 800 00:36:20,426 --> 00:36:23,326 because there are these very sensitive moving parts 801 00:36:23,326 --> 00:36:25,416 and there are relatively few moving parts left 802 00:36:25,416 --> 00:36:26,246 in today's computers. 803 00:36:26,246 --> 00:36:29,336 Some of you, in fact, might not even have these devices anymore 804 00:36:29,336 --> 00:36:30,306 with moving parts. 805 00:36:30,516 --> 00:36:32,866 The fan is perhaps the only thing left in those of you 806 00:36:32,866 --> 00:36:35,136 who have computers with what are called SSDs. 807 00:36:35,286 --> 00:36:37,396 But in hard drives where we actually have these moving 808 00:36:37,396 --> 00:36:40,046 platters, here is in fact, how we get from electricity 809 00:36:40,046 --> 00:36:42,696 and magnetism to those zeros and ones. 810 00:36:42,696 --> 00:36:43,046 [ Background Music ] 811 00:36:43,046 --> 00:36:45,836 >> Let's look at what we just saw in slow motion. 812 00:36:46,106 --> 00:36:48,486 When a brief pulse of electricity is sent 813 00:36:48,486 --> 00:36:51,466 to the read/write head it flips on a tiny electromagnet 814 00:36:51,466 --> 00:36:52,696 for a fraction of a second. 815 00:36:53,256 --> 00:36:56,636 The magnet creates a field which changes the polarity of a tiny, 816 00:36:56,706 --> 00:36:58,776 tiny portion of the metal particles 817 00:36:58,776 --> 00:37:00,366 which coat each platter's surface. 818 00:37:01,356 --> 00:37:03,646 A patterned series of these tiny charged berries 819 00:37:03,646 --> 00:37:05,566 on the disk represents a single bit of data 820 00:37:05,566 --> 00:37:08,976 in the binary number system used by computers. 821 00:37:09,066 --> 00:37:11,386 Now, if the current is sent one way through the read/write head, 822 00:37:11,476 --> 00:37:13,676 the area is polarized in one direction. 823 00:37:14,046 --> 00:37:16,206 If the current is sent in the opposite direction, 824 00:37:16,206 --> 00:37:17,896 the polarization is reversed. 825 00:37:18,276 --> 00:37:20,896 How do you get data off the hard disk? 826 00:37:20,956 --> 00:37:21,946 Just reverse the process. 827 00:37:22,506 --> 00:37:24,966 So as the particles on the disk that get the current 828 00:37:24,966 --> 00:37:27,456 in the read/write head moving put together millions 829 00:37:27,456 --> 00:37:30,676 of these magnetized segments and you've got a file. 830 00:37:31,276 --> 00:37:34,116 Now, the pieces of a single file may be scanning all the hard 831 00:37:34,516 --> 00:37:37,396 drive's platters, patterns-- the mess of papers on your desk. 832 00:37:38,456 --> 00:37:41,366 So the special active file keeps track of whatever you missed. 833 00:37:41,366 --> 00:37:44,906 Don't you wish that you had something like that? 834 00:37:44,906 --> 00:37:44,976 [ Laughter ] 835 00:37:44,976 --> 00:37:45,466 >> Alright. 836 00:37:45,536 --> 00:37:46,916 So take it with a grain of salt. 837 00:37:46,916 --> 00:37:48,436 It was made by a computer scientist, 838 00:37:48,846 --> 00:37:50,786 but now, it's fun time. 839 00:37:50,846 --> 00:37:53,466 So, these things here that you have in your hand, 840 00:37:53,596 --> 00:37:55,156 is the results of my spontaneously going 841 00:37:55,156 --> 00:37:56,196 to staples before class. 842 00:37:56,196 --> 00:37:58,416 I was the only one, believe it or not, at the store, 843 00:37:58,416 --> 00:37:59,656 who was buying floppies today [laughter]. 844 00:38:00,106 --> 00:38:03,126 What you'll notice very delicately is 845 00:38:03,126 --> 00:38:06,206 that there's not all that much to this so called floppy disk. 846 00:38:06,206 --> 00:38:09,036 It's actually a much cheaper example 847 00:38:09,036 --> 00:38:10,286 than handing out hard drives. 848 00:38:10,286 --> 00:38:12,786 But at the end of the day, if you move this metal thing aside 849 00:38:12,786 --> 00:38:14,396 with your fingers, don't squeeze it too hard. 850 00:38:14,676 --> 00:38:16,936 You will see inside that there's a platter, 851 00:38:16,936 --> 00:38:19,116 but it's literally a floppy platter, 852 00:38:19,116 --> 00:38:21,936 even though the disks themselves are fairly firm plastic. 853 00:38:22,206 --> 00:38:25,846 This thing, if you now go ahead and very gently corrupt a few 854 00:38:25,846 --> 00:38:28,396 of the bytes, you can see that you can push down on 855 00:38:28,396 --> 00:38:30,156 that thing pretty easily. 856 00:38:30,556 --> 00:38:33,066 Now-- oh, now we've ruined them. 857 00:38:33,256 --> 00:38:35,416 So why don't we go ahead and take this just a step further? 858 00:38:35,416 --> 00:38:37,416 Go ahead and just pinch the metal plates 859 00:38:37,416 --> 00:38:38,626 and watch your eyes 'cause these do-- 860 00:38:38,626 --> 00:38:39,776 things do have little springs. 861 00:38:40,006 --> 00:38:42,096 Go ahead and just pull that metal plate off. 862 00:38:42,096 --> 00:38:46,436 And now you truly can see that there's not much to this disk. 863 00:38:46,436 --> 00:38:50,696 And then this is where you can really tear into this device. 864 00:38:50,946 --> 00:38:53,166 If you put your fingers between the plastic opening 865 00:38:53,166 --> 00:38:55,006 at the bottom, and here's where you gotta watch 866 00:38:55,006 --> 00:39:03,546 out for the spring, pull the thing apart and that's it. 867 00:39:04,596 --> 00:39:07,376 The irony is-- these things cost like a dollar each now 868 00:39:07,376 --> 00:39:08,876 because no one needs them anymore. 869 00:39:08,876 --> 00:39:12,426 It's kind of an Ec 10 thing there, but that's it. 870 00:39:13,016 --> 00:39:18,516 So unfortunately, we had just ruined roughly 1.4 million bytes 871 00:39:18,986 --> 00:39:20,546 worth of data. 872 00:39:20,546 --> 00:39:23,546 They came formatted or blank so not such a big deal. 873 00:39:23,756 --> 00:39:26,326 But in fact, if you just run your fingers again and again 874 00:39:26,326 --> 00:39:30,066 over this floppy disk you are disorienting those particles 875 00:39:30,066 --> 00:39:32,426 or knocking them off perhaps altogether, 876 00:39:32,476 --> 00:39:33,346 depending on the medium. 877 00:39:33,346 --> 00:39:34,436 And the rest of this thing, 878 00:39:34,656 --> 00:39:37,216 this is just a cheap piece of molded plastic. 879 00:39:37,446 --> 00:39:41,816 This little felt thing there is just to avoid too much friction 880 00:39:41,816 --> 00:39:42,906 from building up with the plastic 881 00:39:42,906 --> 00:39:45,476 or to keep it slightly separated from the case, but that's it. 882 00:39:45,896 --> 00:39:48,716 That's all there was to those things called floppy disks. 883 00:39:48,986 --> 00:39:52,186 But what's amazing is that the hard drives we have today 884 00:39:52,186 --> 00:39:54,666 in a desktop or in a laptop, a hard drive 885 00:39:54,666 --> 00:39:56,386 and a laptop is only about-- yey big! 886 00:39:56,386 --> 00:40:00,336 It's roughly the same size physically as those floppy disks 887 00:40:00,536 --> 00:40:03,146 and yet how many, how much, how many bytes fit 888 00:40:03,146 --> 00:40:04,656 on a typical hard drive today? 889 00:40:05,156 --> 00:40:07,216 [ Inaudible Remark ] 890 00:40:07,716 --> 00:40:13,116 >> What's that 500, so 500 megabytes, this is 1.4 megabytes 891 00:40:13,116 --> 00:40:16,376 so a typical hard drive might have 500-- no, not 500 megabyte, 892 00:40:16,536 --> 00:40:20,146 500 gigabytes which is 500 billion bytes 893 00:40:20,416 --> 00:40:22,756 and if you have a desktop computer you might actually have 894 00:40:22,756 --> 00:40:25,786 a 1 terabyte drive or 1.5 terabyte drive 895 00:40:25,946 --> 00:40:28,366 or 1-- 2.0 terabyte drive. 896 00:40:28,576 --> 00:40:30,876 These are trillions now of bytes. 897 00:40:31,096 --> 00:40:34,196 And so it wasn't all that many years ago frankly that you know, 898 00:40:34,196 --> 00:40:37,326 certainly, people in this class were still using these things. 899 00:40:37,356 --> 00:40:38,896 Thankfully, they've fallen into disuse. 900 00:40:39,166 --> 00:40:41,876 They're not the most robust things anymore. 901 00:40:42,086 --> 00:40:44,906 But the technology and the fundamentals and the ideas, 902 00:40:44,906 --> 00:40:47,866 it's pretty much exactly the same as we're using today 903 00:40:47,866 --> 00:40:50,136 in some of our modern computers. 904 00:40:50,426 --> 00:40:56,916 So, any questions on zeroes and ones? 905 00:40:57,336 --> 00:40:59,016 It's a little awkward asking questions in here 906 00:40:59,016 --> 00:41:03,666 but let's give it a try. 907 00:41:03,666 --> 00:41:03,886 [ Inaudible Question ] 908 00:41:03,886 --> 00:41:05,056 >> Good question, so what happens 909 00:41:05,056 --> 00:41:07,776 when you format a floppy disk or format a hard drive? 910 00:41:08,076 --> 00:41:11,806 To be honest, not very much and this is one of the reasons 911 00:41:11,806 --> 00:41:14,146 that forensic investigators are actually able to do 912 00:41:14,146 --> 00:41:17,186 such a good job for the police and FBI or the like because 913 00:41:17,186 --> 00:41:20,256 so many computer programs, Mac OS and Windows, they'll say, 914 00:41:20,256 --> 00:41:23,266 are you sure you want to do this, this will erase everything 915 00:41:23,266 --> 00:41:25,676 from your disk, this will erase everything from your hard drive 916 00:41:25,906 --> 00:41:28,526 if you so called format it or partition it. 917 00:41:28,526 --> 00:41:30,176 It's another piece of jargon you often hear. 918 00:41:30,506 --> 00:41:33,926 That generally is just modifying a few bytes, 919 00:41:33,996 --> 00:41:36,316 a few kilobytes worth of information. 920 00:41:36,656 --> 00:41:40,606 The end result of which is that the computer forgets where all 921 00:41:40,606 --> 00:41:42,136 of your files and folders are. 922 00:41:42,386 --> 00:41:44,766 But the bits that actually compose those files 923 00:41:44,766 --> 00:41:48,296 and folders are in fact exactly where you left them. 924 00:41:48,616 --> 00:41:51,046 And so this is why in problem set 5 last year 925 00:41:51,046 --> 00:41:52,516 when I took photographs on campus 926 00:41:52,516 --> 00:41:55,376 with a compact flash card, just standard consumer media 927 00:41:55,556 --> 00:41:58,786 and I accidentally formatted that compact flash card, 928 00:41:58,916 --> 00:42:01,186 I only lost the first few kilobytes, 929 00:42:01,186 --> 00:42:04,486 the first few thousand bits on that compact flash card. 930 00:42:04,486 --> 00:42:06,326 But as you probably know, a JPEG, a photograph, 931 00:42:06,526 --> 00:42:08,996 these are usually multiple megabytes these days 932 00:42:08,996 --> 00:42:11,416 which means there's a ridiculous amount of data still 933 00:42:11,416 --> 00:42:12,816 on that digital camera. 934 00:42:13,106 --> 00:42:15,966 And so if you know what patterns of zeroes and ones to look 935 00:42:15,966 --> 00:42:17,876 for as you will yourselves this year 936 00:42:18,236 --> 00:42:19,636 in that forensics problem set, 937 00:42:19,846 --> 00:42:21,666 can you recover a lot of that data? 938 00:42:21,716 --> 00:42:24,966 So in short, formatting a disk gets it ready for new data 939 00:42:24,966 --> 00:42:27,206 but it tends not to get rid of the old 940 00:42:27,206 --> 00:42:30,866 and only recently are Apple and Microsoft finally realizing 941 00:42:30,866 --> 00:42:34,416 that consumers actually want to securely erase their information 942 00:42:34,416 --> 00:42:36,586 for privacy or financial or whatever reasons, 943 00:42:36,846 --> 00:42:38,346 but up until now and even know 944 00:42:38,346 --> 00:42:40,126 on some operating systems it's not 945 00:42:40,126 --> 00:42:42,816 in fact very easy, other questions. 946 00:42:43,146 --> 00:42:43,276 Yeah. 947 00:42:44,516 --> 00:42:53,946 [ Inaudible Question ] 948 00:42:54,446 --> 00:42:57,636 >> Exactly, so you might have been thought especially 949 00:42:57,636 --> 00:42:59,806 in years past to defragment, so to speak, 950 00:42:59,806 --> 00:43:00,986 your hard drive once in a while. 951 00:43:01,226 --> 00:43:03,286 And this is because as you start writing-- 952 00:43:03,286 --> 00:43:04,926 saving files to your hard drive, 953 00:43:05,226 --> 00:43:08,126 what happens is you might save this file here, then this one, 954 00:43:08,126 --> 00:43:09,086 then this one, then this one, 955 00:43:09,286 --> 00:43:11,276 but very reasonably you might go back eventually 956 00:43:11,276 --> 00:43:12,176 and delete this one. 957 00:43:12,386 --> 00:43:14,556 Now you have a gap in your data and 958 00:43:14,556 --> 00:43:16,856 yet you still have some magnetic particles there 959 00:43:16,856 --> 00:43:18,286 that could be useful. 960 00:43:18,536 --> 00:43:21,536 So thankfully, modern operating systems allow you to put parts 961 00:43:21,536 --> 00:43:23,426 of files here, parts of your file here, 962 00:43:23,426 --> 00:43:25,756 parts of your file here, but the end result is 963 00:43:25,756 --> 00:43:27,856 that your files get fragmented. 964 00:43:28,096 --> 00:43:30,466 The operating system still finds it but this process 965 00:43:30,466 --> 00:43:33,146 of getting some of your files bits from here, some from here, 966 00:43:33,146 --> 00:43:35,956 some from here, induces a potential slow down. 967 00:43:36,106 --> 00:43:38,386 Now defragmentation as an aside is not 968 00:43:38,386 --> 00:43:39,966 so much necessary these days 969 00:43:39,966 --> 00:43:42,446 because hardware has gotten so performance. 970 00:43:42,776 --> 00:43:45,976 But it is in fact indicative of what's actually going 971 00:43:46,166 --> 00:43:48,386 on underneath the hood and for a forensic investigator 972 00:43:48,386 --> 00:43:50,186 to be honest and even problem set 5, 973 00:43:50,376 --> 00:43:53,356 it poses a potential wrinkle if those JPEGs, 974 00:43:53,386 --> 00:43:56,476 those photos we took are not contiguous back to back to back 975 00:43:56,476 --> 00:43:57,496 but are all over the place. 976 00:43:57,716 --> 00:43:59,996 That's a lot harder of a problem to solve if you need 977 00:43:59,996 --> 00:44:02,456 to reconstruct the fragmentation, yeah. 978 00:44:03,516 --> 00:44:08,656 [ Inaudible Question ] 979 00:44:09,156 --> 00:44:12,246 >> Good question, so there is this little reading head kind 980 00:44:12,246 --> 00:44:14,896 of like in an old phonograph player that does move back 981 00:44:14,896 --> 00:44:17,496 and forth and in and out depending on the implementation. 982 00:44:17,766 --> 00:44:20,666 So there is generally a little computer, a circuit board 983 00:44:20,666 --> 00:44:23,846 in the hard drive itself that knows how to tell it to go up, 984 00:44:23,846 --> 00:44:25,266 down, left, right and so forth. 985 00:44:25,426 --> 00:44:27,886 And if you've ever heard the word driver software 986 00:44:28,096 --> 00:44:30,756 that you install in your computer so that your computer, 987 00:44:30,756 --> 00:44:33,676 your operating system, Windows or Mac OS, knows how to talk 988 00:44:33,676 --> 00:44:36,726 to that piece of hardware, it's that driver software 989 00:44:36,726 --> 00:44:39,336 that then empowers the operating systems to send those commands 990 00:44:39,336 --> 00:44:41,956 as well, up, down, left, right depending on how the disk-- 991 00:44:42,236 --> 00:44:44,016 the data is laid out on the disk. 992 00:44:44,286 --> 00:44:46,206 Let me go over here for another question. 993 00:44:46,206 --> 00:44:46,371 [ Inaudible Question ] 994 00:44:46,371 --> 00:44:46,536 [ Laughter ] 995 00:44:46,536 --> 00:44:53,266 >> Okay, what are the advantages of SSDs and how do they work. 996 00:44:53,266 --> 00:44:54,386 Let me answer this briefly now, 997 00:44:54,386 --> 00:44:56,596 I'm happy to chat more during break time. 998 00:44:56,596 --> 00:44:57,906 SSDs are where things are going. 999 00:44:58,056 --> 00:45:01,216 SSDs is like using compact flash or SD cards. 1000 00:45:01,246 --> 00:45:03,206 The things we've had in cameras for several years 1001 00:45:03,366 --> 00:45:06,486 by putting gigabytes, soon hopefully terabytes of storage 1002 00:45:06,646 --> 00:45:08,506 on a device that has no moving parts. 1003 00:45:08,776 --> 00:45:11,886 Generally, the feature is that they are much faster 1004 00:45:12,196 --> 00:45:13,926 because they have no moving parts. 1005 00:45:14,036 --> 00:45:17,526 Even though a hard drive spins at 7200 times per minute 1006 00:45:17,526 --> 00:45:20,086 or even faster, that's relatively slower 1007 00:45:20,086 --> 00:45:20,886 than the speed of light. 1008 00:45:21,086 --> 00:45:22,626 And so when you actually have a device 1009 00:45:22,866 --> 00:45:25,546 that is purely electronic, and even that doesn't-- 1010 00:45:25,546 --> 00:45:27,496 the bits don't flow at the speed of light in reality. 1011 00:45:27,716 --> 00:45:29,376 It's a lot faster of a device. 1012 00:45:29,456 --> 00:45:31,936 But these days you pay for it which is why you get SSDs, 1013 00:45:31,986 --> 00:45:34,446 you're paying several hundred dollars more. 1014 00:45:34,676 --> 00:45:37,566 So let's transition from these lower level details. 1015 00:45:37,566 --> 00:45:39,546 I'm happy to take questions during break and after 1016 00:45:39,796 --> 00:45:44,346 to actually making this hardware do something in software. 1017 00:45:44,346 --> 00:45:47,046 And for this I need one volunteer. 1018 00:45:47,916 --> 00:45:52,056 Let's go and okay, right here. 1019 00:45:52,276 --> 00:45:53,096 Oh, but let's see. 1020 00:45:53,096 --> 00:45:55,356 Okay, I need a second volunteer for reasons 1021 00:45:55,356 --> 00:45:56,256 that will be clear in a second. 1022 00:45:56,256 --> 00:46:00,126 Come on down. 1023 00:46:00,336 --> 00:46:01,466 Your role has just been changed 1024 00:46:01,466 --> 00:46:02,956 because you're not wearing any socks today. 1025 00:46:04,036 --> 00:46:08,816 So come on over here, we're gonna have-- what's your name? 1026 00:46:09,576 --> 00:46:09,876 >> Sam. 1027 00:46:10,026 --> 00:46:10,646 >> Sam and? 1028 00:46:10,956 --> 00:46:11,166 >> Philip. 1029 00:46:11,456 --> 00:46:12,186 >> Sam and Philip. 1030 00:46:12,186 --> 00:46:14,776 Alright, I'm David and let's have Philip sit down. 1031 00:46:15,306 --> 00:46:17,906 You'll play role sort of a shoe salesman, shall we say? 1032 00:46:18,096 --> 00:46:18,266 >> Okay. 1033 00:46:18,416 --> 00:46:19,496 >> Alright, and don't worry I have a script 1034 00:46:19,496 --> 00:46:20,576 for you but not for Philip. 1035 00:46:21,626 --> 00:46:24,726 So here is a computer program. 1036 00:46:24,726 --> 00:46:26,926 This is not written in a particular language. 1037 00:46:26,966 --> 00:46:30,216 This is what's written in what we'll generally call pseudocode. 1038 00:46:30,356 --> 00:46:31,296 Pseudocode is kind 1039 00:46:31,296 --> 00:46:33,806 of an English-like syntax that's just a useful way 1040 00:46:33,806 --> 00:46:37,146 of expressing yourself fairly succinctly, fairly computer-like 1041 00:46:37,306 --> 00:46:39,286 but without having to worry about stupid details 1042 00:46:39,286 --> 00:46:41,376 like whether it's Java or C or whatever. 1043 00:46:41,596 --> 00:46:43,786 You just kind of say what you mean but you say it succinctly. 1044 00:46:43,786 --> 00:46:44,646 But what's interesting 1045 00:46:44,646 --> 00:46:47,476 about this particular example is one, it's imperfect. 1046 00:46:47,776 --> 00:46:49,576 I didn't quite get this program right. 1047 00:46:49,896 --> 00:46:53,536 Two, it also highlights a number of constructs 1048 00:46:53,536 --> 00:46:55,846 that we'll see today and we'll see recurring throughout this 1049 00:46:55,846 --> 00:46:58,946 world of programming, things like loops and conditions 1050 00:46:58,946 --> 00:46:59,976 and variables and the like. 1051 00:47:00,216 --> 00:47:04,306 So what we have Philip here for is to actually be the one 1052 00:47:04,476 --> 00:47:06,876 who if you could start taking off your shoes and socks, 1053 00:47:07,686 --> 00:47:10,896 I didn't just claim this in the beginning but we very quickly 1054 00:47:10,896 --> 00:47:13,926 in this course start to hemorrhage volunteers overtime. 1055 00:47:14,456 --> 00:47:14,626 Alright. 1056 00:47:14,751 --> 00:47:16,751 [ Laughter ] 1057 00:47:16,876 --> 00:47:21,486 >> You don't have to-- you don't have to touch. 1058 00:47:21,486 --> 00:47:21,816 It's okay. 1059 00:47:22,226 --> 00:47:24,926 So this first line of code, I will get it started 1060 00:47:24,926 --> 00:47:26,436 but then I'm gonna have you take over 1061 00:47:26,436 --> 00:47:28,946 and actually instruct Philip what to do here. 1062 00:47:29,256 --> 00:47:30,476 So this first line of code, 1063 00:47:30,476 --> 00:47:31,826 and some of this again we'll be rehashed 1064 00:47:31,826 --> 00:47:33,526 but at least you can delight in the awkwardness 1065 00:47:33,526 --> 00:47:34,596 that is this demonstration. 1066 00:47:34,596 --> 00:47:36,336 So line 1, I've numbered the lines just 1067 00:47:36,336 --> 00:47:37,236 for the sake of discussion. 1068 00:47:37,526 --> 00:47:39,436 Line 1 is creating what we'll call a variable. 1069 00:47:39,436 --> 00:47:41,566 Now, unlike high school math or in algebra 1070 00:47:41,566 --> 00:47:44,106 where you call things X and Y and Z, in programming, 1071 00:47:44,106 --> 00:47:46,936 in computer science, you're actually dealing with humans 1072 00:47:46,936 --> 00:47:50,156 where it's useful to have a variable name that's more 1073 00:47:50,156 --> 00:47:53,666 descriptive than X and Y and Z. So here is an example of socks 1074 00:47:53,666 --> 00:47:55,546 on feet being the number of socks 1075 00:47:55,546 --> 00:47:58,296 on Philip's feet which is in fact 0. 1076 00:47:58,456 --> 00:48:01,286 On line 2, we're gonna induce what's called a loop, 1077 00:48:01,356 --> 00:48:03,526 so do you wanna go ahead and Philip henceforth you get 1078 00:48:03,526 --> 00:48:04,996 to stare, stare at the awkwardness. 1079 00:48:05,516 --> 00:48:12,606 Go ahead and recite for us line 2 of this program. 1080 00:48:12,606 --> 00:48:13,026 [ Inaudible Remark ] 1081 00:48:13,026 --> 00:48:15,696 >> Okay, so while not equal to, so bang equals, 1082 00:48:15,696 --> 00:48:17,856 exclamation point equals is computer science syntax 1083 00:48:18,016 --> 00:48:21,676 for saying not equal to, while not equal to 2 1084 00:48:21,676 --> 00:48:23,286 which it is not, it is equal to 0. 1085 00:48:23,286 --> 00:48:29,226 What should he do next? 1086 00:48:29,226 --> 00:48:30,926 [ Inaudible Remark ] 1087 00:48:30,926 --> 00:48:31,336 >> Okay. 1088 00:48:31,336 --> 00:48:32,896 [ Inaudible Remark ] 1089 00:48:32,896 --> 00:48:34,756 >> Excellent, look for sock, alright. 1090 00:48:34,916 --> 00:48:36,436 Step 5, now this is an example 1091 00:48:36,436 --> 00:48:39,026 of what we'll henceforth call a condition or a branch 1092 00:48:39,226 --> 00:48:44,736 because it's sort of a fork in the road. 1093 00:48:44,736 --> 00:48:45,376 [ Inaudible Remark ] 1094 00:48:45,376 --> 00:48:49,926 >> Okay, if you find the sock then put on sock. 1095 00:48:51,736 --> 00:48:53,796 Intentionally, I bought the worst socks I could. 1096 00:48:53,856 --> 00:48:54,966 >> No, I like it. 1097 00:48:54,966 --> 00:48:55,236 [ Laughter ] 1098 00:48:55,236 --> 00:49:03,156 >> I get this. 1099 00:49:03,156 --> 00:49:03,366 [ Laughter ] 1100 00:49:03,366 --> 00:49:04,626 >> Available at the Harvard Coop. 1101 00:49:05,906 --> 00:49:07,376 Alright, next line. 1102 00:49:07,686 --> 00:49:09,956 >> Socks on feet plus plus. 1103 00:49:09,956 --> 00:49:11,296 >> So this plus plus is sort 1104 00:49:11,296 --> 00:49:13,146 of shorthand notation for incrementation. 1105 00:49:13,146 --> 00:49:16,516 So just add 1 to this variable's value, so now socks on feet is 1106 00:49:16,516 --> 00:49:19,716 of course 1 and so next. 1107 00:49:20,126 --> 00:49:23,166 >> Look for matching sock. 1108 00:49:23,646 --> 00:49:26,836 >> Problem, so where are we at line 9? 1109 00:49:26,836 --> 00:49:30,396 >> If you find a matching sock which you didn't so then else. 1110 00:49:30,486 --> 00:49:33,226 >> Okay, so notice again the control flow and this-- 1111 00:49:33,406 --> 00:49:35,886 the choice of indentation here is deliberate throughout 1112 00:49:35,886 --> 00:49:38,656 programming whether it's in C or PHP or JavaScript 1113 00:49:38,656 --> 00:49:39,596 in this particular course. 1114 00:49:39,746 --> 00:49:41,806 The indentation gives you a visual cue as to 1115 00:49:41,806 --> 00:49:43,946 which lines are related to each other. 1116 00:49:43,946 --> 00:49:46,226 So the fact that line 9 did not match, 1117 00:49:46,556 --> 00:49:48,786 if you find a matching sock which we didn't, 1118 00:49:48,896 --> 00:49:51,856 that means we immediately jump to the else which is line 13 1119 00:49:52,036 --> 00:49:53,476 and so Philip now has to do what? 1120 00:49:54,116 --> 00:49:56,276 >> Remove first sock from foot. 1121 00:49:56,276 --> 00:49:57,396 >> Oh man! 1122 00:49:58,276 --> 00:50:00,656 >> Socks on feet, minus minus. 1123 00:50:00,656 --> 00:50:02,876 >> We decrement so to speak the variable and then 1124 00:50:02,876 --> 00:50:05,906 where will we go next in terms of the flow control, 1125 00:50:05,906 --> 00:50:06,976 the flow of this program. 1126 00:50:07,526 --> 00:50:08,866 >> Back to the while. 1127 00:50:09,116 --> 00:50:09,866 >> Right, so the fact 1128 00:50:09,866 --> 00:50:12,326 that everything is indented means while we're doing, 1129 00:50:12,326 --> 00:50:14,906 while the variable is not equal to 2, keep doing this. 1130 00:50:15,176 --> 00:50:16,716 And so we're going to repeat. 1131 00:50:16,716 --> 00:50:18,546 Now, rather than go through this again and again, 1132 00:50:18,546 --> 00:50:19,886 because frankly you can probably see 1133 00:50:19,886 --> 00:50:23,176 where this goes before long we're gonna hit some problems. 1134 00:50:23,176 --> 00:50:24,526 What's one of the problems you see 1135 00:50:25,436 --> 00:50:26,576 or that we tripped over already? 1136 00:50:26,576 --> 00:50:28,376 [ Inaudible Remark ] 1137 00:50:28,376 --> 00:50:33,086 >> If there is no matching socks then what's gonna happen 1138 00:50:33,086 --> 00:50:33,776 with Philip here? 1139 00:50:34,206 --> 00:50:37,436 We're gonna have a so called a loop, an infinite loop 1140 00:50:37,436 --> 00:50:39,396 and you actually experience this in the real world. 1141 00:50:39,396 --> 00:50:40,856 If you've ever been using some program, 1142 00:50:41,066 --> 00:50:43,086 you did something completely innocuous, pull something 1143 00:50:43,086 --> 00:50:44,406 down from a menu, click a button, 1144 00:50:44,596 --> 00:50:46,496 you didn't do anything wrong and yet all 1145 00:50:46,496 --> 00:50:48,136 of a sudden the thing just starts hanging there 1146 00:50:48,136 --> 00:50:49,916 or you get a little spinning beach ball 1147 00:50:49,916 --> 00:50:51,276 or the hour glass or whatever it is. 1148 00:50:51,276 --> 00:50:54,066 Something completely not your fault, it's not. 1149 00:50:54,226 --> 00:50:56,486 It's because the programmer or programmers that wrote 1150 00:50:56,486 --> 00:50:58,816 that software might have been pretty specific 1151 00:50:59,016 --> 00:51:00,356 but not specific enough. 1152 00:51:00,356 --> 00:51:02,576 Computers smart though they may be 1153 00:51:02,576 --> 00:51:04,876 and intimidating though they may be, they can not 1154 00:51:04,986 --> 00:51:06,726 yet think for themselves. 1155 00:51:06,726 --> 00:51:08,476 They can't just know what you mean. 1156 00:51:08,626 --> 00:51:10,746 And so similarly as Gmail's priority inbox, 1157 00:51:10,746 --> 00:51:13,456 it's gonna be pretty flawed for a lot of us at least initially 1158 00:51:13,616 --> 00:51:17,106 because it just doesn't know the answers a priori correctly 1159 00:51:17,106 --> 00:51:19,966 unless we teach it or program it to be better. 1160 00:51:19,966 --> 00:51:23,536 There is also another flaw in here or multiple flaws arguably. 1161 00:51:23,536 --> 00:51:25,206 But something else catch your eye? 1162 00:51:25,446 --> 00:51:28,256 This is a very imperfect program. 1163 00:51:28,256 --> 00:51:29,996 [ Inaudible Remark ] 1164 00:51:29,996 --> 00:51:35,026 >> So, in fact we may not find a sock at all and 1165 00:51:35,026 --> 00:51:37,526 yet we don't seem to handle that at all unless 1166 00:51:37,836 --> 00:51:40,136 if we don't find any socks, what do we do? 1167 00:51:41,116 --> 00:51:42,386 We replenish the sock drawer. 1168 00:51:42,386 --> 00:51:44,566 So if we tease this apart and this is actually nice, 1169 00:51:44,566 --> 00:51:45,396 every semester I get beat 1170 00:51:45,396 --> 00:51:46,856 up for just how bad this thing actually is 1171 00:51:46,856 --> 00:51:48,136 if you start really picking it apart. 1172 00:51:48,436 --> 00:51:50,736 You find that there's a lot of flaws but this is intentional 1173 00:51:50,946 --> 00:51:54,156 and this is one of the sort of arts that you learn early on is 1174 00:51:54,156 --> 00:51:56,476 that with computers you really do need to be careful 1175 00:51:56,476 --> 00:51:58,676 and you need to think about this so called corner cases 1176 00:51:58,856 --> 00:52:01,596 and even you might use popular websites or programs that have 1177 00:52:01,806 --> 00:52:05,136 so called bugs or mistakes and that is simply the results 1178 00:52:05,136 --> 00:52:09,266 of the programmer not having anticipated some 1179 00:52:09,266 --> 00:52:10,286 particular problem. 1180 00:52:10,286 --> 00:52:11,926 So we have a parting gift. 1181 00:52:11,926 --> 00:52:15,816 Why don't we give Philip both the matching pair 1182 00:52:16,016 --> 00:52:17,656 and give you each a pair of socks since he didn't get 1183 00:52:17,656 --> 00:52:20,106 to wear this one, they are brand new, in fact, and a big round 1184 00:52:20,106 --> 00:52:21,946 of applause for what I'm sure is a little difficult. 1185 00:52:22,516 --> 00:52:28,476 [ Applause ] 1186 00:52:28,976 --> 00:52:29,676 >> Take your time. 1187 00:52:30,166 --> 00:52:34,096 So, let's actually now take a 2-minute break, 1188 00:52:34,096 --> 00:52:35,436 we're gonna change tapes and we'll come back 1189 00:52:35,436 --> 00:52:37,866 and we'll actually write programs with a real computer 1190 00:52:37,866 --> 00:52:40,376 and some real animated characters. 1191 00:52:40,376 --> 00:52:41,796 More in just a couple of minutes. 1192 00:52:41,796 --> 00:52:42,346 [ Silence ] 1193 00:52:42,346 --> 00:52:48,086 >> Alright, we are back 1194 00:52:48,546 --> 00:52:52,866 so we just wrote a programming pseudocode or walk 1195 00:52:52,866 --> 00:52:54,136 through a programming pseudocode. 1196 00:52:54,136 --> 00:52:55,566 Let's take a quick glimpse of what it's 1197 00:52:55,566 --> 00:52:58,866 like to write a real program albeit a very trivial one. 1198 00:52:58,866 --> 00:53:02,476 Starting next week you'll actually be using a cluster 1199 00:53:02,476 --> 00:53:06,926 of systems that CS50 itself runs called Cloud.CS50.net. 1200 00:53:07,166 --> 00:53:09,026 This is a bunch of computers running an operating system 1201 00:53:09,026 --> 00:53:11,836 called Linux which has a variety of interfaces too 1202 00:53:11,836 --> 00:53:12,956 and more on that next week. 1203 00:53:13,156 --> 00:53:14,316 But it turns out that on Macs 1204 00:53:14,426 --> 00:53:16,656 and if you have the right software on PCs, you can kind 1205 00:53:16,656 --> 00:53:19,476 of get a teaser of what this environment tends to look like 1206 00:53:19,676 --> 00:53:20,836 and be forewarned, what you're 1207 00:53:20,836 --> 00:53:23,576 about to see is intentionally very underwhelming. 1208 00:53:23,576 --> 00:53:25,966 I am going to run a program called Nano 1209 00:53:26,296 --> 00:53:30,276 and type nano hello.c and I'm gonna type the following very 1210 00:53:30,276 --> 00:53:33,486 quickly without much explanation because we'll dive 1211 00:53:33,486 --> 00:53:34,796 into this more next week. 1212 00:53:35,236 --> 00:53:38,036 But what I'm doing here is programming. 1213 00:53:38,976 --> 00:53:44,626 Sorry, I didn't mean to make it sound so condescending. 1214 00:53:44,626 --> 00:53:44,736 [ Laughter ] 1215 00:53:44,736 --> 00:53:47,596 >> So this is just a dumb text editor called Nano, 1216 00:53:47,596 --> 00:53:49,426 dumb in that it's very simple which is nice 1217 00:53:49,466 --> 00:53:51,206 because it eliminates a lot of the complexities 1218 00:53:51,206 --> 00:53:52,086 of learning a new tool 1219 00:53:52,086 --> 00:53:54,326 when really all you wanna do is solve an actual problem. 1220 00:53:54,516 --> 00:53:57,556 So I'm gonna go ahead and save this file, it's hello.c, 1221 00:53:57,796 --> 00:54:00,516 dot C hints at the fact that this program I just whipped 1222 00:54:00,516 --> 00:54:03,436 up is written in a language called C. Now, 1223 00:54:03,436 --> 00:54:06,016 this is underwhelming with what you can do in just a second 1224 00:54:06,016 --> 00:54:07,286 in this particular language. 1225 00:54:07,506 --> 00:54:09,826 But again as per Wednesday's lecture by the end 1226 00:54:09,826 --> 00:54:11,236 of the semester, you'll be making things 1227 00:54:11,236 --> 00:54:13,286 like isawyouharvard.com 1228 00:54:13,286 --> 00:54:15,156 or any websites really that you can imagine. 1229 00:54:15,156 --> 00:54:18,856 Can you probably produce after just several weeks 1230 00:54:18,856 --> 00:54:20,626 of fundamentals like these? 1231 00:54:20,626 --> 00:54:23,306 So I'm saving this file, notice there is a few keywords 1232 00:54:23,306 --> 00:54:25,496 that we'll come back to next week like main which is kind 1233 00:54:25,496 --> 00:54:26,986 of the main part of my program. 1234 00:54:27,156 --> 00:54:30,486 There is this include which allows me to include code, 1235 00:54:30,486 --> 00:54:32,846 source code so to speak that other people wrote 1236 00:54:33,026 --> 00:54:34,686 so I don't have to figure out for myself how 1237 00:54:34,686 --> 00:54:35,946 to print things to the screen. 1238 00:54:36,146 --> 00:54:37,746 Other people are telling me how to-- 1239 00:54:38,126 --> 00:54:40,786 other people had solved that problem for me, and this thing 1240 00:54:40,786 --> 00:54:42,746 between quotes, we'll start calling a string. 1241 00:54:42,966 --> 00:54:45,326 It's just a sentence or words or whatever that I wanna print. 1242 00:54:45,326 --> 00:54:47,876 And then there are some stupid syntax like curly braces 1243 00:54:47,876 --> 00:54:50,316 and semicolons that initially are kind of annoying 1244 00:54:50,316 --> 00:54:52,156 because you have to remember where all this junk goes. 1245 00:54:52,156 --> 00:54:55,516 But at the end of the day, it's really going to be identical 1246 00:54:55,516 --> 00:54:57,256 to what we see pictorially with Scratch. 1247 00:54:57,486 --> 00:54:59,066 I'm now gonna run a program called GCC 1248 00:54:59,116 --> 00:55:01,126 which is what's called the compiler. 1249 00:55:01,406 --> 00:55:03,566 Compiler, we'll also revisit next week takes-- 1250 00:55:03,826 --> 00:55:08,976 human text, ASCII text as input and output zeroes and ones 1251 00:55:09,246 --> 00:55:13,686 that represent that program in a manner that the CPU, 1252 00:55:13,686 --> 00:55:17,726 the Intel Inside, actually understands which is-- 1253 00:55:17,726 --> 00:55:21,616 interesting, dammit, not installed on this computer. 1254 00:55:21,996 --> 00:55:26,006 So what we would see, I'm going to completely fake this, 1255 00:55:27,266 --> 00:55:30,586 is a program that operates like that. 1256 00:55:30,586 --> 00:55:32,886 So I just realized this is a new MacBook Pro 1257 00:55:32,886 --> 00:55:35,946 that I didn't actually download the compiler onto it apparently. 1258 00:55:36,296 --> 00:55:38,526 So good, that will give us something to do next week. 1259 00:55:38,706 --> 00:55:41,416 But what you would have seen is the program just doing this, 1260 00:55:41,526 --> 00:55:42,776 printing out to the screen. 1261 00:55:42,776 --> 00:55:45,036 But unfortunately, this is incredibly underwhelming 1262 00:55:45,036 --> 00:55:46,596 certainly in the first week of a course. 1263 00:55:46,856 --> 00:55:49,506 It's much more interesting if you can actually build things 1264 00:55:49,736 --> 00:55:52,576 that are interactive, that are animated, that play music 1265 00:55:52,576 --> 00:55:55,316 and so forth and not just produce things on day 1 1266 00:55:55,526 --> 00:55:57,376 that outputs zeroes and ones like this. 1267 00:55:57,376 --> 00:55:59,776 So those are in fact the patterns of zeroes and ones, 1268 00:55:59,776 --> 00:56:02,746 the bytes that would have been outputted had I remembered 1269 00:56:02,966 --> 00:56:06,616 to download the compiler to this computer and run it 1270 00:56:07,096 --> 00:56:09,546 on that little hello.c file. 1271 00:56:09,546 --> 00:56:11,256 But we'll do that again correctly next time. 1272 00:56:11,496 --> 00:56:13,926 But it turns out that with this language we glimpsed 1273 00:56:13,926 --> 00:56:16,556 on Wednesday, you can do the step so much more easily and 1274 00:56:16,556 --> 00:56:19,236 yet the ideas are identical to what we're gonna explore 1275 00:56:19,236 --> 00:56:21,066 at a lower level in the weeks to come. 1276 00:56:21,296 --> 00:56:23,966 So this is the simplest program you can probably write 1277 00:56:23,966 --> 00:56:25,706 in this language called Scratch. 1278 00:56:25,956 --> 00:56:28,326 Scratch is a program that you can download for free 1279 00:56:28,556 --> 00:56:32,146 and you will see in problem set 0 which will be posted 1280 00:56:32,146 --> 00:56:35,476 on CS50.net tonight under problem sets in both standard 1281 00:56:35,476 --> 00:56:38,646 and hacker editions, can you do the-- can you-- 1282 00:56:38,646 --> 00:56:40,146 it will walk you through the process 1283 00:56:40,146 --> 00:56:41,256 of getting this software. 1284 00:56:41,526 --> 00:56:43,216 This software now looks like this. 1285 00:56:43,646 --> 00:56:46,136 On the top right hand side is the so called stage. 1286 00:56:46,136 --> 00:56:47,236 This is where as we saw 1287 00:56:47,236 --> 00:56:50,106 on Wednesday are sprites or our characters. 1288 00:56:50,106 --> 00:56:53,536 Our little characters are going to play or move 1289 00:56:53,536 --> 00:56:56,016 as we instruct them to do. 1290 00:56:56,236 --> 00:56:59,416 On the left hand side is my palette of puzzle pieces 1291 00:56:59,416 --> 00:57:01,036 or building blocks and those are the things. 1292 00:57:01,036 --> 00:57:02,966 In a moment, I'm gonna drag and drop in order 1293 00:57:02,966 --> 00:57:04,786 to induce this right to do something. 1294 00:57:05,066 --> 00:57:07,316 And in the middle of this blank slate, in the middle, 1295 00:57:07,616 --> 00:57:09,556 this is where my program is going to go. 1296 00:57:09,786 --> 00:57:11,186 And so as we saw on Wednesday, 1297 00:57:11,186 --> 00:57:13,126 if I wanna just get this thing started, 1298 00:57:13,406 --> 00:57:16,706 notice that there is this thing here when green flag clicked, 1299 00:57:16,996 --> 00:57:20,236 that scratches version of that keyword "main". 1300 00:57:20,496 --> 00:57:22,536 So main is equivalent to this green flag. 1301 00:57:22,776 --> 00:57:23,616 What can I now do? 1302 00:57:23,616 --> 00:57:26,196 We'll shape like a puzzle piece that will allow me to go 1303 00:57:26,196 --> 00:57:28,216 to the looks palette at top left 1304 00:57:28,216 --> 00:57:29,996 and it's pretty self-explanatory. 1305 00:57:29,996 --> 00:57:33,006 The categories, the colors, very quickly start to make sense 1306 00:57:33,006 --> 00:57:34,216 when you just start poking around. 1307 00:57:34,216 --> 00:57:37,316 I'm gonna drag this thing here, zoom in, 1308 00:57:37,416 --> 00:57:39,116 and voila, what do I now see? 1309 00:57:39,376 --> 00:57:41,566 Well, I now have two blocks interlocked 1310 00:57:41,566 --> 00:57:43,986 and you can pretty much guess what this is gonna do. 1311 00:57:43,986 --> 00:57:48,436 It's going to say hello and I can change this here. 1312 00:57:48,706 --> 00:57:50,646 I can change the number of seconds that it does it. 1313 00:57:50,646 --> 00:57:52,766 And if I want to detach it, I just click and drag, 1314 00:57:52,766 --> 00:57:54,906 and now I can go back and put different puzzle pieces 1315 00:57:54,906 --> 00:57:56,186 there altogether. 1316 00:57:56,416 --> 00:57:58,176 But it turns out though simple, though, 1317 00:57:58,176 --> 00:58:01,356 some of these puzzle pieces actually are, 1318 00:58:01,596 --> 00:58:05,376 we can actually start to do very interesting things very quickly. 1319 00:58:05,616 --> 00:58:06,906 So, some jargon first. 1320 00:58:07,226 --> 00:58:09,116 Computers generally have things called-- 1321 00:58:09,116 --> 00:58:12,126 computer languages generally have things called "statements". 1322 00:58:12,126 --> 00:58:13,476 A statement is an action. 1323 00:58:13,476 --> 00:58:14,396 It's an instruction. 1324 00:58:14,636 --> 00:58:18,026 It's a capability that just tells the computer what to do. 1325 00:58:18,296 --> 00:58:21,776 Much as you might instruct as a human, a robot, to do something 1326 00:58:21,776 --> 00:58:23,396 to the extent that's currently possible. 1327 00:58:23,646 --> 00:58:25,226 So say, "Oh, hi world." 1328 00:58:25,426 --> 00:58:26,856 This would be called a statement. 1329 00:58:26,856 --> 00:58:28,896 Another one might be "wait one second" 1330 00:58:29,146 --> 00:58:31,746 which is another building block or puzzle piece and scratch. 1331 00:58:31,746 --> 00:58:34,316 And another one might be "play sound meow." 1332 00:58:34,506 --> 00:58:36,556 So now you can start to see the things can get 1333 00:58:36,556 --> 00:58:37,946 interesting quickly. 1334 00:58:37,946 --> 00:58:39,256 Well, let's go ahead and do that. 1335 00:58:39,426 --> 00:58:40,906 Let me go ahead and open up some 1336 00:58:40,906 --> 00:58:42,826 of the examples that I came with. 1337 00:58:42,916 --> 00:58:44,906 All of these are available on the courses' website 1338 00:58:45,096 --> 00:58:46,446 so you can play afterward. 1339 00:58:46,576 --> 00:58:49,436 And I'm gonna go ahead and open a file called hai2.sb 1340 00:58:50,356 --> 00:58:52,366 which is the file extension for this language. 1341 00:58:52,656 --> 00:58:55,056 Now, notice in the middle, I wrote this at home already, 1342 00:58:55,326 --> 00:58:57,916 you can pretty much read this stuff top 1343 00:58:57,916 --> 00:58:59,306 to bottom to see what it does. 1344 00:58:59,486 --> 00:59:01,496 When green flag clicked, I'm gonna say, "Oh, 1345 00:59:01,496 --> 00:59:05,726 hi world for a second", then wait, say it again and wait, 1346 00:59:05,886 --> 00:59:08,136 say it again, and then that's it. 1347 00:59:08,136 --> 00:59:09,986 So let's go ahead and click the green flag. 1348 00:59:09,986 --> 00:59:12,926 And in fact, very overwhelming. 1349 00:59:13,366 --> 00:59:16,556 So let's actually start to make this more interesting. 1350 00:59:16,556 --> 00:59:20,936 Let me go ahead and instead open up what I called high3. 1351 00:59:21,806 --> 00:59:23,666 I'm gonna go ahead and say don't say it 'cause I didn't make 1352 00:59:23,666 --> 00:59:24,146 any changes. 1353 00:59:24,146 --> 00:59:24,836 I'll play this-- 1354 00:59:25,516 --> 00:59:30,576 [ Sound Effects ] 1355 00:59:31,076 --> 00:59:31,956 >> Okay, getting cute. 1356 00:59:31,956 --> 00:59:34,466 You do that on loop too long, it gets really annoying quickly. 1357 00:59:35,666 --> 00:59:37,576 [Laughter] But it's just a different statement. 1358 00:59:37,576 --> 00:59:40,076 And so when you start to poke around the puzzle pieces, 1359 00:59:40,076 --> 00:59:42,256 you see that it can say things, we'll see movement 1360 00:59:42,256 --> 00:59:44,666 in just a moment and sound and so forth, but at the end 1361 00:59:44,666 --> 00:59:47,466 of the day, this is just like the program we used a moment ago 1362 00:59:47,466 --> 00:59:50,346 for the sock exercise where we just hold Philip a step 1363 00:59:50,346 --> 00:59:53,286 after step after step, do this, do this, do that, and yet, 1364 00:59:53,376 --> 00:59:55,906 here too, we already see an opportunity 1365 00:59:56,066 --> 00:59:57,476 for that thing we called the loop. 1366 00:59:57,476 --> 01:00:00,596 I am meowing three times and you can very quick-- 1367 01:00:00,596 --> 01:00:02,976 easily see perhaps that this very quickly could get messy. 1368 01:00:03,216 --> 01:00:05,626 >> I could do a whole lot of copy-paste essentially. 1369 01:00:05,836 --> 01:00:08,216 If I want the cats meow six times, I just make a copy 1370 01:00:08,216 --> 01:00:09,896 of this which you can do by right-clicking 1371 01:00:09,896 --> 01:00:11,206 or control-clicking as you'll see, 1372 01:00:11,416 --> 01:00:14,226 and then I just keep doing this and this, and this, and this, 1373 01:00:14,226 --> 01:00:15,726 but now, what's the problem? 1374 01:00:15,726 --> 01:00:18,346 Well, one, it just starts to look ridiculous, frankly. 1375 01:00:18,346 --> 01:00:21,226 You should acquire overtime this instinctive aversion 1376 01:00:21,226 --> 01:00:25,216 to just code or programs that just look ugly because things 1377 01:00:25,216 --> 01:00:28,146 that look ugly generally are not easy to maintain. 1378 01:00:28,286 --> 01:00:30,306 For instance, if I wanted to change the sound 1379 01:00:30,306 --> 01:00:32,846 that the cat is making, my God, now I have to change it 1380 01:00:32,846 --> 01:00:34,956 on three places but like 30 places 1381 01:00:35,006 --> 01:00:36,576 if all I've done is copy and paste. 1382 01:00:36,876 --> 01:00:38,436 So hopefully, there's an opportunity 1383 01:00:38,436 --> 01:00:40,546 for actually looping and, ultimately, 1384 01:00:40,546 --> 01:00:42,176 than doing things conditionally. 1385 01:00:42,436 --> 01:00:44,506 So if you wanna do something conditionally, 1386 01:00:44,726 --> 01:00:46,346 you generally needs to ask the question, 1387 01:00:46,556 --> 01:00:48,486 is the following true or false. 1388 01:00:48,486 --> 01:00:51,246 In Philip's case, we ask the question, does he have zero 1389 01:00:51,396 --> 01:00:54,176 or none zero socks on his feet? 1390 01:00:54,176 --> 01:00:57,506 Or rather, does he have two or not two socks on his feet? 1391 01:00:57,706 --> 01:01:00,066 That's what's called a Boolean expression named 1392 01:01:00,066 --> 01:01:01,896 after literally a man named Boole. 1393 01:01:01,896 --> 01:01:05,186 And this puzzle piece here colored in blue 1394 01:01:05,186 --> 01:01:08,156 because it's a Boolean expression is just something 1395 01:01:08,156 --> 01:01:10,666 that-- whose answer is either a yes or no, 1396 01:01:10,746 --> 01:01:13,346 true or false, one or zero. 1397 01:01:13,556 --> 01:01:16,646 So notice already the parallels between the lower level details 1398 01:01:16,646 --> 01:01:18,676 and now these higher level details, so to speak, 1399 01:01:18,886 --> 01:01:19,886 of actually programming. 1400 01:01:20,116 --> 01:01:22,846 This Boolean expression allows you to say to scratch 1401 01:01:23,126 --> 01:01:25,086 if you are touching the mouse pointer, 1402 01:01:25,086 --> 01:01:27,126 the little arrow, do something. 1403 01:01:27,486 --> 01:01:28,396 How do we do something? 1404 01:01:28,396 --> 01:01:29,176 We'll see in a moment. 1405 01:01:29,176 --> 01:01:30,696 What else can you detect as a yes 1406 01:01:30,696 --> 01:01:32,576 or no answer is the mouse down? 1407 01:01:32,896 --> 01:01:33,906 Yes or no. 1408 01:01:33,906 --> 01:01:37,026 That can give you a true or false, a one or a zero answer. 1409 01:01:37,276 --> 01:01:37,866 What about this? 1410 01:01:38,056 --> 01:01:41,476 Is the number on the left less than the number on the right? 1411 01:01:41,476 --> 01:01:43,636 That might be a question you might wanna answer 1412 01:01:43,856 --> 01:01:48,616 or you might wanna say, is the thing on the left and the thing 1413 01:01:48,616 --> 01:01:50,646 on the right both true? 1414 01:01:50,766 --> 01:01:52,366 Do I have two yes answers 1415 01:01:52,566 --> 01:01:54,886 if you wanna check two conditions at once? 1416 01:01:55,226 --> 01:01:58,126 You know, this might seem to be a bit of a new context for some 1417 01:01:58,126 --> 01:02:00,806 of you but consider a typical website. 1418 01:02:00,806 --> 01:02:03,146 If you've been shopping for courses on Harvard courses, 1419 01:02:03,276 --> 01:02:05,396 the website we mentioned on Wednesday, well, 1420 01:02:05,396 --> 01:02:07,226 you'll notice you'll recall perhaps 1421 01:02:07,346 --> 01:02:10,006 that there's all these checkboxes, all these checkboxes 1422 01:02:10,006 --> 01:02:12,236 that allow you to, say, you want a course in the fall 1423 01:02:12,236 --> 01:02:14,926 or the spring, Monday, Tuesday, Wednesday, Thursday, well, now, 1424 01:02:14,926 --> 01:02:17,816 think about even with today's basics already in mind, 1425 01:02:18,116 --> 01:02:20,296 that this is just kind of the same idea 1426 01:02:20,486 --> 01:02:22,746 where if you wanna look for a course that's on the fall 1427 01:02:22,746 --> 01:02:26,476 and on Monday, Tuesday, that's like saying I want fall 1428 01:02:26,476 --> 01:02:31,756 and Monday, and Tuesday, so each of these checkboxes is itself, 1429 01:02:31,756 --> 01:02:33,626 really, a Boolean expression. 1430 01:02:33,626 --> 01:02:35,106 And so you see that stuff all over the place 1431 01:02:35,106 --> 01:02:36,376 on Facebook, Google, and the like. 1432 01:02:36,586 --> 01:02:38,046 These are not foreign concepts. 1433 01:02:38,046 --> 01:02:39,966 It's just we're now slapping some new, 1434 01:02:39,966 --> 01:02:41,196 perhaps jargon on them. 1435 01:02:41,386 --> 01:02:44,246 Now that you have the ability to ask yes or no questions, 1436 01:02:44,426 --> 01:02:46,506 you wanna be able to branch or fork 1437 01:02:46,506 --> 01:02:48,516 in the road based on those answers. 1438 01:02:48,516 --> 01:02:50,836 We saw this with the sock algorithm a moment ago. 1439 01:02:51,016 --> 01:02:54,106 In scratch, a condition looks a little something like this. 1440 01:02:54,156 --> 01:02:55,966 It's a puzzle piece that looks kind of small 1441 01:02:56,206 --> 01:02:57,796 but notice there is this little funky shape 1442 01:02:57,796 --> 01:02:59,116 up top that's the same shape 1443 01:02:59,116 --> 01:03:01,986 as the blue blocks we've just looked at 'cause you can drag 1444 01:03:01,986 --> 01:03:03,716 and drop that condition on top of that, 1445 01:03:03,906 --> 01:03:05,926 and even though there's not much space in the middle here, 1446 01:03:05,926 --> 01:03:08,646 it turns out what's nice about scratches, it will grow 1447 01:03:08,646 --> 01:03:10,626 to fill more and more puzzle pieces. 1448 01:03:10,626 --> 01:03:12,976 If you just drag them and drag them, and drag them in there, 1449 01:03:13,066 --> 01:03:16,736 it will keep growing to fill-- to fit any such statements. 1450 01:03:16,816 --> 01:03:20,326 And you don't just have to have an if or nothing construct. 1451 01:03:20,486 --> 01:03:22,616 You can say if this is true, then go 1452 01:03:22,616 --> 01:03:25,446 and do the following pieces of code or puzzle pieces 1453 01:03:25,446 --> 01:03:27,976 that are inside this part of the block, else go ahead 1454 01:03:27,976 --> 01:03:29,866 and do these that are down here. 1455 01:03:29,866 --> 01:03:31,216 And we saw this with Philip's example. 1456 01:03:31,216 --> 01:03:33,166 But sometimes there are three roads you can take 1457 01:03:33,436 --> 01:03:35,856 and so even though it starts to look a little messy, 1458 01:03:35,856 --> 01:03:38,826 if you do this too much, you can certainly branch this way 1459 01:03:38,826 --> 01:03:40,506 or this way, or this way 1460 01:03:40,506 --> 01:03:43,316 and these are what we generally call conditions. 1461 01:03:43,316 --> 01:03:47,736 Well, let's actually put these to use. 1462 01:03:48,226 --> 01:03:50,396 Here's high4.sb. 1463 01:03:50,396 --> 01:03:50,463 [ Sound Effects ] 1464 01:03:50,463 --> 01:03:52,686 >> Kind of a stupid program, why? 1465 01:03:55,506 --> 01:03:55,806 [Laughter] Right. 1466 01:03:55,896 --> 01:03:59,256 So this is a great way of like fulfilling the requirements 1467 01:03:59,256 --> 01:04:00,946 of the problem step but not quite the spirit 1468 01:04:00,946 --> 01:04:02,176 of using a condition. 1469 01:04:02,866 --> 01:04:04,886 So this is not all that interesting, 1470 01:04:04,916 --> 01:04:08,096 but let's actually take a look at a 5th version of high 1471 01:04:08,386 --> 01:04:09,856 that actually does something interesting. 1472 01:04:09,856 --> 01:04:12,316 Oh, it turns out there's a puzzle piece that allows you 1473 01:04:12,386 --> 01:04:14,896 to pick a random or as we'll start calling it soon a 1474 01:04:14,896 --> 01:04:18,676 pseudorandom number so that scratch can effectively roll a 1475 01:04:18,676 --> 01:04:22,406 dice or flip a coin, or give you a bit of non-determinism. 1476 01:04:22,406 --> 01:04:23,656 It's the fancy way of saying this. 1477 01:04:23,896 --> 01:04:25,786 And this is useful because if you're actually writing a 1478 01:04:25,786 --> 01:04:28,056 program that's interactive or that you want 1479 01:04:28,056 --> 01:04:31,446 to change overtime much like you would a game, hopefully, 1480 01:04:31,606 --> 01:04:34,556 the game is not going to have the bad guys, for instance, 1481 01:04:34,556 --> 01:04:37,576 always standing in the same place or the rocks 1482 01:04:37,576 --> 01:04:39,066 or whatever it is falling from the sky 1483 01:04:39,066 --> 01:04:41,616 in the same place 'cause it would very quickly become a very 1484 01:04:41,756 --> 01:04:42,426 tedious game. 1485 01:04:42,426 --> 01:04:45,406 Almost any game you play has some kind of randomness 1486 01:04:45,406 --> 01:04:47,506 or pseudorandomness which means 1487 01:04:47,506 --> 01:04:50,826 that things change overtime somewhat unpredictably. 1488 01:04:50,826 --> 01:04:52,676 So now, if I click the green flag, 1489 01:04:53,276 --> 01:04:56,986 the program seems broken or-- I don't know. 1490 01:04:56,986 --> 01:04:58,656 It's just the number that was picked between 1 1491 01:04:58,656 --> 01:05:03,116 and 10 that's probably bigger than 5 or 6, not smaller. 1492 01:05:03,116 --> 01:05:05,236 Let's try it again. 1493 01:05:05,236 --> 01:05:06,556 Let's try it again. 1494 01:05:06,556 --> 01:05:07,516 [ Sound Effects ] 1495 01:05:07,516 --> 01:05:08,086 >> There we go. 1496 01:05:08,086 --> 01:05:12,416 Now if I do this, an infinite [sound effects] number of times, 1497 01:05:12,416 --> 01:05:15,096 we should get roughly 50/50, but now we have the ability 1498 01:05:15,096 --> 01:05:16,796 to do things only once in awhile. 1499 01:05:16,796 --> 01:05:18,176 So now, loops. 1500 01:05:18,416 --> 01:05:21,576 You wanna do something again and again. 1501 01:05:21,576 --> 01:05:24,306 You can kind of see where the syntax is going, 1502 01:05:24,566 --> 01:05:27,276 looks like a loop, but you can kind of put blocks inside 1503 01:05:27,276 --> 01:05:29,016 of you, and the little arrow suggests that once you get 1504 01:05:29,016 --> 01:05:31,026 to the bottom just like our socks example, 1505 01:05:31,276 --> 01:05:32,666 you're gonna do the following again. 1506 01:05:32,906 --> 01:05:33,976 What else might it look like? 1507 01:05:33,976 --> 01:05:34,916 You might be able to say 1508 01:05:34,916 --> 01:05:36,946 and we'll see this in C and PHP as well. 1509 01:05:37,166 --> 01:05:40,056 Do the following a bunch of times, but a finite number 1510 01:05:40,106 --> 01:05:41,476 of times which might be useful. 1511 01:05:41,476 --> 01:05:42,946 So here we have a repeat block. 1512 01:05:43,196 --> 01:05:44,626 Let's actually put this into play 1513 01:05:44,626 --> 01:05:46,556 with the little sprite known as scratch. 1514 01:05:46,996 --> 01:05:47,926 So this is high6. 1515 01:05:47,926 --> 01:05:50,766 And now, as promised, and all even full screen, 1516 01:05:50,766 --> 01:05:51,456 it's really annoying. 1517 01:05:52,516 --> 01:06:00,906 [ Sound Effects ] 1518 01:06:01,406 --> 01:06:02,456 >> If we weren't so pressed for time, 1519 01:06:02,456 --> 01:06:04,036 I kinda wanna see how long we could get away 1520 01:06:04,036 --> 01:06:06,876 with this before it gets awkward, but [laughter] that, 1521 01:06:06,876 --> 01:06:10,256 in fact, is an infinite loop that's hopefully deliberate. 1522 01:06:10,256 --> 01:06:12,516 Otherwise, it's a pretty bad mistake, 1523 01:06:12,776 --> 01:06:15,296 but sometimes you do want an infinite loop, for instance, 1524 01:06:15,296 --> 01:06:18,236 Microsoft Word if you use it or pages or the 1525 01:06:18,236 --> 01:06:19,886 like on your Mac or PC. 1526 01:06:20,116 --> 01:06:23,116 These days, those things constantly spell check your 1527 01:06:23,116 --> 01:06:23,976 program for you. 1528 01:06:23,976 --> 01:06:26,746 So in a sense, that's a good infinite loop that is as long 1529 01:06:26,746 --> 01:06:27,696 as you're using the program, 1530 01:06:27,836 --> 01:06:30,056 it's constantly checking your grammar and spelling, 1531 01:06:30,056 --> 01:06:30,986 and underlining things, 1532 01:06:31,226 --> 01:06:33,286 so infinite loops aren't necessarily bad 1533 01:06:33,566 --> 01:06:36,006 if the objective is actually being met. 1534 01:06:36,256 --> 01:06:38,306 Well, let's take a look at this high7 variant 1535 01:06:38,686 --> 01:06:41,906 that also use loops, that also uses a loop. 1536 01:06:42,286 --> 01:06:44,216 So this one is a little cute, I like to think. 1537 01:06:45,026 --> 01:06:45,636 So notice this. 1538 01:06:45,686 --> 01:06:46,796 My mouse cursor is over here 1539 01:06:46,796 --> 01:06:49,086 on the top right, now, I touch the cat. 1540 01:06:49,086 --> 01:06:50,026 [ Sound Effects ] 1541 01:06:50,026 --> 01:06:50,506 >> Move away. 1542 01:06:50,506 --> 01:06:51,866 [ Sound Effects ] 1543 01:06:51,866 --> 01:06:55,336 >> So this is my-- petting a cat, example. 1544 01:06:55,336 --> 01:06:56,376 Well, how does this work? 1545 01:06:56,786 --> 01:06:58,936 We'll notice, it's just a few puzzle pieces. 1546 01:06:58,936 --> 01:07:01,296 I'm forever watching the situation. 1547 01:07:01,436 --> 01:07:04,026 And now, if I'm touching mouse pointer, 1548 01:07:04,026 --> 01:07:06,856 we saw that Boolean expression before, play sound meow, 1549 01:07:06,906 --> 01:07:09,056 wait a couple of seconds, and then just keep checking. 1550 01:07:09,056 --> 01:07:11,416 So if I left my cursor there like you're petting the cat, 1551 01:07:11,606 --> 01:07:13,916 it would just keep meowing and meowing every two seconds, 1552 01:07:13,976 --> 01:07:17,126 but if I move it away, that Boolean expression becomes false 1553 01:07:17,126 --> 01:07:19,226 or zero and so we don't do it again. 1554 01:07:19,226 --> 01:07:21,936 And just to be clear, you can disassemble these programs, 1555 01:07:21,936 --> 01:07:23,296 you can move this thing over here. 1556 01:07:23,466 --> 01:07:25,496 It's all about dragging and dropping which is, 1557 01:07:25,496 --> 01:07:26,506 to say, is very intuitive. 1558 01:07:26,506 --> 01:07:28,656 If you think of the idea, you think of the basic logic, 1559 01:07:28,926 --> 01:07:31,256 and then you go ahead and drag and drop accordingly. 1560 01:07:31,256 --> 01:07:33,086 Let's look at this 8th variance of this, 1561 01:07:33,086 --> 01:07:34,426 otherwise, simple example. 1562 01:07:34,766 --> 01:07:37,326 Well, this one was me having a little fun here. 1563 01:07:37,326 --> 01:07:38,156 So play-- 1564 01:07:38,156 --> 01:07:39,336 [ Sound Effects ] 1565 01:07:39,336 --> 01:07:40,586 >> Cat meows ad nauseam. 1566 01:07:41,496 --> 01:07:45,266 But touch the cat and-- [sound effects] [laughter]. 1567 01:07:46,296 --> 01:07:47,876 So don't touch this particular cat. 1568 01:07:48,146 --> 01:07:49,696 So how is this working? 1569 01:07:49,856 --> 01:07:52,736 Well, again, I'm not spending too much time on the specifics 1570 01:07:52,736 --> 01:07:54,226 because again, it should hopefully start-- 1571 01:07:54,226 --> 01:07:56,006 it was, oh, that's kind of intuitive. 1572 01:07:56,006 --> 01:08:00,076 If something is true do this, else something is true, do that. 1573 01:08:00,426 --> 01:08:02,526 Well, what are some of the other constructs we're gonna have 1574 01:08:02,626 --> 01:08:04,366 access to starting with scratch and see? 1575 01:08:04,526 --> 01:08:05,546 Well, certainly, variables. 1576 01:08:05,666 --> 01:08:08,066 If you want to maintain states, that is, to say, 1577 01:08:08,066 --> 01:08:10,946 remember some value, well, you can use what's called a variable 1578 01:08:10,946 --> 01:08:13,276 and here's what it looks like in this language called scratch. 1579 01:08:13,526 --> 01:08:15,956 Now, who cares about variables Xs and Ys and all these? 1580 01:08:15,956 --> 01:08:17,476 Well, what about a game? 1581 01:08:17,516 --> 01:08:19,426 Anything where you're actually keeping track of something 1582 01:08:19,426 --> 01:08:21,546 like a score that's having a variable 1583 01:08:21,546 --> 01:08:24,786 that you increment plus, plus, or decrement, minus, minus, 1584 01:08:25,086 --> 01:08:27,306 using the appropriate puzzle piece could certainly 1585 01:08:27,306 --> 01:08:27,996 be compelling. 1586 01:08:28,226 --> 01:08:29,776 Suppose you want a character to move 1587 01:08:29,776 --> 01:08:31,796 around the screen and collect things. 1588 01:08:31,876 --> 01:08:34,306 So it doesn't make sense to just use a number 'cause you want 1589 01:08:34,306 --> 01:08:35,606 this character to collect something 1590 01:08:35,606 --> 01:08:37,196 from here or here, or there. 1591 01:08:37,386 --> 01:08:40,326 Well, you can use what's called an array which is kind of a list 1592 01:08:40,586 --> 01:08:43,236 or a little satchel of that you might physically carry 1593 01:08:43,366 --> 01:08:45,646 that you can put things in again and again, 1594 01:08:45,856 --> 01:08:48,006 and with an array can you actually keep track 1595 01:08:48,006 --> 01:08:51,596 of not just numbers but any kinds of things, other sprites 1596 01:08:51,596 --> 01:08:54,756 or other pictures, or perhaps a little something like this. 1597 01:08:54,806 --> 01:08:57,726 Let me go ahead and pull up this little example here. 1598 01:08:57,726 --> 01:09:00,566 It looks like we're dwelling on only the most simple. 1599 01:09:01,216 --> 01:09:02,896 Go ahead and click the green flag. 1600 01:09:03,846 --> 01:09:06,776 You'll see this was written by a former student of ours. 1601 01:09:07,706 --> 01:09:09,956 Notice the top left is a picture of inventory. 1602 01:09:09,956 --> 01:09:11,666 That's just a graphical incarnation 1603 01:09:11,666 --> 01:09:15,376 of this thing called an array and notice, the games can, 1604 01:09:15,376 --> 01:09:17,076 in fact, interact with a human much 1605 01:09:17,076 --> 01:09:18,706 like Wednesday, I'm leaving my house. 1606 01:09:19,716 --> 01:09:20,706 Oh, here are some cherries. 1607 01:09:20,706 --> 01:09:22,776 Oh, look. In my array at top left, 1608 01:09:22,776 --> 01:09:23,976 they have now cherries in it. 1609 01:09:24,066 --> 01:09:26,286 Let's see what this is, probably an orange. 1610 01:09:26,956 --> 01:09:28,016 Let me go over here. 1611 01:09:28,016 --> 01:09:29,966 And now think about how you do this. 1612 01:09:29,966 --> 01:09:32,446 If right arrow key down, move right. 1613 01:09:32,486 --> 01:09:34,286 If right arrow key down, move right. 1614 01:09:34,546 --> 01:09:39,326 If touching sign, display this little cartoon bubble. 1615 01:09:39,326 --> 01:09:42,656 So let me go get the pineapple, let me go get the bananas. 1616 01:09:42,716 --> 01:09:44,096 Let me go get the apple. 1617 01:09:44,456 --> 01:09:46,236 I think I-- where do I have to go, the fruit place? 1618 01:09:46,336 --> 01:09:51,116 Oh, there's a man at the store and now we have a loop 1619 01:09:51,566 --> 01:09:54,486 where he is just looking through my inventory one at a time 1620 01:09:54,816 --> 01:09:59,906 and reciting what it is I actually picked up. 1621 01:10:00,046 --> 01:10:02,606 >> Well, what more can we do with some of these fundamentals? 1622 01:10:02,606 --> 01:10:05,526 Well, with arrays and the like, after arrays and the like, 1623 01:10:05,526 --> 01:10:06,976 we have these things called threads. 1624 01:10:07,316 --> 01:10:09,846 So thankfully, you can do multiple things at once 1625 01:10:09,846 --> 01:10:12,266 in a program because of what we'll call threads. 1626 01:10:12,576 --> 01:10:14,996 Here is an example in just a moment of a program, 1627 01:10:15,076 --> 01:10:18,646 a scratch project, so to speak, with two sprites; one bird 1628 01:10:18,646 --> 01:10:20,706 and one cat, and what this means is 1629 01:10:20,706 --> 01:10:23,006 that even though the interface is getting a little complicated, 1630 01:10:23,006 --> 01:10:25,156 realize the student did this with baby steps, 1631 01:10:25,156 --> 01:10:27,026 implements in a little bit of this, a little bit of this, 1632 01:10:27,026 --> 01:10:30,026 and then over time, it grows to be a pretty impressive program, 1633 01:10:30,256 --> 01:10:32,046 but it starts off as just a clean slate. 1634 01:10:32,286 --> 01:10:33,746 Notice at the bottom right here, 1635 01:10:33,876 --> 01:10:35,356 we have all these different icons. 1636 01:10:35,496 --> 01:10:36,916 I can click on this guy 1637 01:10:37,126 --> 01:10:39,536 to see what sprites are controlling him. 1638 01:10:39,776 --> 01:10:40,976 Here is where the guy yawned. 1639 01:10:41,256 --> 01:10:42,476 It's because of that script. 1640 01:10:42,646 --> 01:10:44,756 I can click on the cherries and see what they're doing, 1641 01:10:45,056 --> 01:10:46,086 you know, not all that much. 1642 01:10:46,206 --> 01:10:47,856 They're just sitting there, but they are listening 1643 01:10:47,856 --> 01:10:49,206 for something we'll see in a moment. 1644 01:10:49,476 --> 01:10:54,286 But let me go ahead and open up, let's say, this cat example, 1645 01:10:54,416 --> 01:10:58,146 move two-- you can even have different sprites interact 1646 01:10:58,146 --> 01:11:00,116 with each other much like this. 1647 01:11:01,766 --> 01:11:04,286 Now, all the cat is doing is that it's an infinite loop 1648 01:11:04,496 --> 01:11:08,326 and it's checking if I am not facing bird, 1649 01:11:08,326 --> 01:11:10,946 face bird, and it's [noise]-- 1650 01:11:10,946 --> 01:11:11,466 [ Laughter ] 1651 01:11:11,466 --> 01:11:12,896 >> It's constantly chasing the bird. 1652 01:11:12,896 --> 01:11:14,996 And so now, you have two threads so to speak, 1653 01:11:14,996 --> 01:11:16,516 two miniature programs, 1654 01:11:16,516 --> 01:11:19,726 two sprites all interacting with one another. 1655 01:11:19,726 --> 01:11:21,856 You can do other things too, and I know I'm flying through these 1656 01:11:21,856 --> 01:11:25,776 but only because it's more fun to play hands-on on your own-- 1657 01:11:25,776 --> 01:11:27,556 oh, actually, this guy is kinda funny. 1658 01:11:27,556 --> 01:11:29,766 Let's play this. 1659 01:11:29,766 --> 01:11:30,772 [ Noise ] 1660 01:11:30,772 --> 01:11:31,778 [ Laughter ] 1661 01:11:31,778 --> 01:11:32,784 [ Noise ] 1662 01:11:32,786 --> 01:11:34,796 >> This is all he does. 1663 01:11:34,796 --> 01:11:35,166 [ Laughter ] 1664 01:11:35,166 --> 01:11:35,536 [ Noise ] 1665 01:11:35,536 --> 01:11:38,596 >> But again, it hints with these fundamentals. 1666 01:11:38,596 --> 01:11:41,516 You've got a loop, you've got a condition and a boolean to check 1667 01:11:41,516 --> 01:11:43,776 if he's touching the edge, and some statements to tell him 1668 01:11:43,776 --> 01:11:47,576 to shout or to actually turn around. 1669 01:11:47,576 --> 01:11:49,446 So what more is there? 1670 01:11:49,516 --> 01:11:52,696 There are also these things called events in programming, 1671 01:11:52,696 --> 01:11:55,536 and specifically, scratch, whereby you can have two sprites 1672 01:11:55,536 --> 01:11:56,966 such as this boy and this girl, 1673 01:11:57,196 --> 01:12:00,436 and when you actually hit the spacebar with the like-- oops-- 1674 01:12:00,706 --> 01:12:03,166 if you actually hit the spacebar or the like, 1675 01:12:04,196 --> 01:12:06,106 one sprite can do something, 1676 01:12:06,776 --> 01:12:08,866 and then the other sprite can do something in response 1677 01:12:08,866 --> 01:12:11,376 because in addition to When Green Flag Clicked, 1678 01:12:11,686 --> 01:12:14,206 there's also this kind of starting point, this alternative 1679 01:12:14,206 --> 01:12:17,046 to main that says When I Receive Event. 1680 01:12:17,426 --> 01:12:20,226 In other words, you can pass sort of secret messages or notes 1681 01:12:20,226 --> 01:12:24,006 between sprites by giving them a name, like in this case, events, 1682 01:12:24,006 --> 01:12:26,016 and then having one talk to the other. 1683 01:12:26,016 --> 01:12:27,296 So this is a simple incarnation 1684 01:12:27,296 --> 01:12:29,676 of that game you might know as Marco Polo. 1685 01:12:29,896 --> 01:12:32,126 Now, in Problem Set Zero, well, you get to play 1686 01:12:32,126 --> 01:12:35,056 with exactly these things and in the hacker edition if you 1687 01:12:35,056 --> 01:12:37,386 so choose, can you play with one of these things. 1688 01:12:37,446 --> 01:12:39,856 I taught I'd demo just a couple little snippets with this. 1689 01:12:40,006 --> 01:12:41,586 So to be clear, we expect most students 1690 01:12:41,586 --> 01:12:44,446 to very comfortably pursue the standard edition of the P set, 1691 01:12:44,696 --> 01:12:47,436 but for this particular P set, the hacker edition gives you-- 1692 01:12:47,436 --> 01:12:50,086 and we have about 150 or so of these out on the hallway, 1693 01:12:50,086 --> 01:12:51,836 and we'll have them at office hours throughout the coming 1694 01:12:51,836 --> 01:12:54,576 week-- this is a little logic board with lots of sensors; 1695 01:12:54,576 --> 01:12:56,396 the sound sensor, a light sensor, 1696 01:12:56,476 --> 01:12:58,106 a little joystick and the like. 1697 01:12:58,376 --> 01:13:00,706 And now, that you have not just the keyboard, but a device 1698 01:13:00,706 --> 01:13:04,236 like this connected via USB can you do something like this, 1699 01:13:04,596 --> 01:13:06,066 like a former student did. 1700 01:13:06,406 --> 01:13:07,656 This is a little game-- 1701 01:13:08,176 --> 01:13:10,046 and again, don't be overwhelmed by the complexity. 1702 01:13:10,046 --> 01:13:13,106 It's all about building up bytes after bytes-- 1703 01:13:14,516 --> 01:13:18,516 [ Music ] 1704 01:13:19,016 --> 01:13:19,083 [ Background Music ] 1705 01:13:19,083 --> 01:13:20,896 >> So I'm now moving the joystick, and the goal 1706 01:13:20,896 --> 01:13:25,046 of this game is not to hit-- oh, to get the bananas, 1707 01:13:25,926 --> 01:13:28,836 but now I've been stunned, there's the man that fell 1708 01:13:28,836 --> 01:13:29,726 from the ceiling on Wednesday, 1709 01:13:29,726 --> 01:13:32,816 and it's responding to the joystick. 1710 01:13:32,966 --> 01:13:35,106 You can do other things too though, when you have sound. 1711 01:13:35,206 --> 01:13:38,876 For instance, let me go ahead and open up masquerade, 1712 01:13:38,876 --> 01:13:41,236 and I'll need Barry to help here, if you don't mind. 1713 01:13:41,486 --> 01:13:42,396 Let me hit play. 1714 01:13:42,876 --> 01:13:44,916 So here, we have-- come on. 1715 01:13:46,496 --> 01:13:49,466 Wait, don't do that yet. 1716 01:13:49,546 --> 01:13:55,476 Come on. I need more lights. 1717 01:13:55,526 --> 01:13:55,936 Wait a minute. 1718 01:13:55,936 --> 01:13:56,886 [ Laughter ] 1719 01:13:56,886 --> 01:13:58,366 >> We can solve this. 1720 01:13:59,156 --> 01:14:04,536 It's a little dark in here as well. 1721 01:14:04,536 --> 01:14:04,603 [ Background Music ] 1722 01:14:04,603 --> 01:14:06,816 >> Okay. It's very nice and beautiful, daylight outside, 1723 01:14:06,816 --> 01:14:07,976 and Barry, could you kill the lights? 1724 01:14:07,976 --> 01:14:08,043 [Noise ] 1725 01:14:08,043 --> 01:14:15,056 So can you actually detect sound in this way? 1726 01:14:16,166 --> 01:14:18,436 Let me stop playing this since it will just go 1727 01:14:18,436 --> 01:14:19,596 on ad nauseam as well. 1728 01:14:20,106 --> 01:14:22,926 So what does this actually mean for you? 1729 01:14:22,996 --> 01:14:25,936 So with problems at zero, which will be posted in two forms; 1730 01:14:26,026 --> 01:14:29,506 PDF for standard and PDF for hacker on cs50.net tonight, 1731 01:14:29,706 --> 01:14:30,586 you will have the choice 1732 01:14:30,586 --> 01:14:34,836 of implementing pretty much any scratch projects you can think 1733 01:14:34,836 --> 01:14:36,786 of, and which subject to very few constraints. 1734 01:14:36,886 --> 01:14:38,826 At the end of the day, the goal is to make something that's 1735 01:14:38,826 --> 01:14:43,756 of interest to you, fun for you, and you'll see at cs50.net/ohs 1736 01:14:43,756 --> 01:14:46,496 for office hours, what the schedule is therefore. 1737 01:14:46,496 --> 01:14:48,426 And let me conclude with this, 1738 01:14:48,426 --> 01:14:53,076 you have an amazing 10 weeks ahead of you. 1739 01:14:53,466 --> 01:14:56,516 And so, we will see you 1740 01:14:56,996 --> 01:15:00,926 if I time this correctly on Wednesday. 1741 01:15:02,516 --> 01:15:09,516 [ Music ] 1742 01:15:10,016 --> 01:15:12,766 [ Silence ]