字幕列表 影片播放 列印英文字幕 BENEDICT BROWN: This is CS50. I'm David Malan. And you can tell because I'm wearing all black. [LAUGHTER] So, when I'm not being David Malan, I'm Benedict Brown. I'm a lecturer here in the computer science department. And it's really my pleasure to welcome you all to CS50 at Yale. [SCATTERED CHEERING] [LAUGHTER] And we've been doing this-- this is now our fourth year. And it was great the first year. And it's been getting better and better every year since. So I'm really thrilled to be here. This is my second year with it. And we're looking forward to a fantastic year. You will see me throughout the semester, sometimes in the lab for office hours, sometimes when you come see me in my office for office hours, which I encourage you all to do. I also work a lot behind the scenes with the organization of the class with the staff and supporting the staff, making sure that they are in a position to help you and work with you in sections and in office hours. And the other person who is really working overtime all semester long on the course here at Yale is Natalie Melo, who I would like to bring up to introduce herself. And then she'll also introduce you to many of our core staff that are here. And Harvard's David Malan will also be making an appearance, I believe. NATALIE MELO: [CHUCKLES] Hi, everyone. [APPLAUSE] Oh! [LAUGHS] [APPLAUSE CONTINUES] Hi, everyone! Welcome! Happy Thursday! Woo-hoo1 [LAUGHS] [SCATTERED CHEERING] I'm Natalie Melo. I'm the course manager for CS50 at Yale. You'll see me a lot at office hours. I might have my own office hours by appointment this semester. But you'll see me around quite a bit. So when you see me, I hope you smile. [LAUGHS] But I'd like to introduce my amazing staff members. So come on up. [CHUCKLES] Woo-hoo! [APPLAUSE] So we have a full team out here ready to help you out, help you learn computer science-- people from all different backgrounds, some not even majoring in computer science. They only took CS50, and they still wanted to help out. So feel free if you see any of them around campus-- say hi. Wave to them. If they see you, and they remember your face, they'll obviously wave to you, as well. So, yeah-- let's give a round of applause to our staff. [APPLAUSE AND CHEERING] And now I'd like to hand it off to Professor Malan. DAVID MALAN: [LAUGHS] OK. NATALIE MELO: OK. DAVID MALAN: [LAUGHING] OK. [APPLAUSE] (WHISPERING) OK. [APPLAUSE CONTINUES] Thanks, guys. OK. (WHISPERING) We're good. [LAUGHTER] (LAUGHING) Thanks. (WHISPERING) Thanks. All right. So this is, indeed, CS50-- An Introduction to the Intellectual Enterprises of Computer Science and the Art of Programming. And what's perhaps striking is that so many of the folks who just stepped up here alongside Natalie and Benedict were exactly where you are seated here just last year. And so, let's get one detail out of the way. 68% of you have never-- if last year is any indication-- studied computer science before. So if you're in this classroom right now, and you're feeling, [SUCKING IN AIR] I'm not so much a computer person, or why am I shopping this class? Odds are, the person to the left of you and maybe even to the right of you is feeling that exact same thing. And if I can say, back in my day, when I first got to college, even I shied away from computer science, even though it's kind of in vogue these days. Certainly, I daresay, it's still a field to beware. An courses like this and others are a bit daunting, I think, if you don't think of yourself as a computer person. And you certainly use computers and mobile phones and all that everyday, but you don't really know what's going on. And god forbid, something goes wrong, it's not really in your wheelhouse to fix. And so ultimately in this class, it's about building comfort and confidence, skills, and a foundation in computer science. And we'll see what that looks like today. And let me start with this message that you'll see in the course's syllabus as well, that what ultimately matters in this course truly is just this, "is not so much where you end up relative to your classmates, but where you, in week 11, and up relative to yourself in week 0." As we'll soon see, computer scientists and programmers tend to start counting from 0. And it's about a 12-week semester. And so by week 11-- the 12th-- will you hopefully feel quite the delta versus where you feel today. So what is, then, computer science? And what are we going to get out of this? So I dare say, we could distill it-- maybe oversimplify it-- as just this-- inputs and outputs, right. It is problem solving, but using computation, using computers, using hardware, using thought to actually solve those problems. And to solve problems, we take inputs. Now what might the inputs to a problem be? I might want to take attendance and start counting. So the people in this room are the inputs. And the output is the total number of people. Or you have some ingredients in the kitchen. And the goal is to produce dinner. And so your inputs are those ingredients, and the output, of course, is dinner. So that's really what problem solving is. And inside of this so-called black box is where computer science really fits. And giving you the tools and the ideas with which you can take inputs and produce outputs that are of interest to you. But to do that, we have to represent inputs and outputs in some way. Right, I'm using English words right now. And if you're taking math classes, you're probably using math symbols and numbers. If you're taking chemistry classes, you might have yet other symbols to play with, as well. But so we have to represent inputs in this class and in this world of computer science in some way. So how might I represent information? If I'm doing something like attendance-- 1, 2, 3. It's not uncommon to do something old school, like, 1, 2, 3, 4. And then we have little tricks just to make it a little more compact-- 5, 6, 7, 8, 9, 10. So we can just use hash marks. And I could do that on my hands, too-- not for the whole class. But how high can I count with just one hand? You say five, right? 1, 2, 3, 4, 5. Not really a trick question. But I daresay, I can actually count higher than that on this hand, right. I'm pretty naively just treating each of my fingers at the moment like hash marks on the board. They're just straight lines representing people in this room. But I'm not really permuting them or combining my fingers in any interesting ways. They're just down or up, but from left to right, or from right to left, in your case. So how might I be more clever? Well, what if this is just 0? And what if this is 1? And what if this is 2? So just one finger up still-- so not one, but two. What if this is 3? What if this-- offensively-- is 4? [LAUGHTER] (CHUCKLING) What if this is 5? 5, 5. And 6, and 7. In other words, if I actually take into account the ordering in which I have my fingers up, I can actually count up notably higher. Off the top of one's head, anyone want to ballpark how high I can count on one hand? 30-- yeah, 31, actually. And we'll come back to why that is before long. But 31-- that's pretty painful to even imagine or physically do. But if you do kind of permute your fingers up and down in different patterns, we can do even better than just 5 people on one hand. So it turns out that computers aren't all that dissimilar to how they represent information, because we, in our human world, tend to use numbers like 1 and 2 and 3, and we immediately see that and think, probably, 123. But why is that? All you see on the screen, technically, are just like three symbols, right? They might be typed. They might be drawn or painted. But these are three symbols, or glyphs, if you will, that just have meaning that we humans ascribe to them. And we know that that is 123 because it's been ingrained in us. But we know this because we've had an alphabet for quite some time that's actually pretty expressive, right. I grew up knowing 0s and 1s and 2, 3, 4, 5, 6, 7, 8, 9-- technically called the decimal system, "dec" meaning 10-- 10 because there's 10 digits in this alphabet, so to speak, for representing numbers. But it turns out computers are more simple than this. And they actually don't have access, necessarily, to all of these numbers. They actually-- anyone know what alphabet they actually do use? Yeah, 0s and 1s, otherwise known as binary-- "bi" implying 2, because it has just 2 digits at its disposal-- 0 and 1. But how in the world using just 0 and 1 can you count to 2, let alone 3 or 4 or 31 or much higher than that? Well, it turns out, it's actually pretty familiar, if you think back to grade school, how you might have first learned math. Odds are, if you're like me, that you saw number like 123-- and it is 123 and not just 1-2-3, because this was the so-called 1's place, this was the so-called 10's place, this was the so-called 100's place. And then, none of us do this anymore, but this would be 100 times 1, plus 10 times 2, plus 1 times 3. And that, of course, is 100, plus 20, plus 3. And then we get, mathematically, 123. And even though it's obviously the same pattern of symbols, it now has some mathematical meaning because we ascribe meaning to these columns. Well, it turns out computers work in fundamentally the same way. But they just don't have 2s and 3s and 4s and 9s. They just have 0s and 1s. So they have to be a little more clever how they use those 0s and 1s-- those binary digits, or "bits." "Binary digits" is where the word "bits" comes from. And so they just change what these columns mean. And so instead of having 1, 10, and 100, which it turns out are powers of 10-- it's technically 10 to the 0, which gives you 1. 10 to the 1 gives you 10. 10 to the 2 gives you 100, and then 1,000, and 10,000, and so forth. Computers actually use powers of not 10, but you might guess-- 2s, because they only have 2 digits in their alphabet. So this is the 1's place, and this would be the 2's place, and this would be the 4's place, for instance. And now I only have 0s and 1s at my disposal. So how do I represent the number we humans know is the number 0? Well, if I need to put a number in these columns, I'm just going to put a 0. Or without fundamentally changing the meaning, I can actually do three 0s. But, just as in the human world, we don't need, necessarily, all of those left-most 0s. We just need the one. How do I represent 1 in binary using just 0s and 1s, if I have three of them at my disposal? 0, 0, 1. Why? Well, I need zero 4s, zero 2s, but I do need one 1 to represent the number 1. And here now, can you see why my fingers went up in the order they did? How do I represent the number 2 in binary? With what pattern? Yeah, 0, 1, 0. And again, if that's not obvious, that's fine. You can just literally do the math. Well, I don't need a 4 to represent the number 2. I do need a 2. But and once I have a 2, I don't need any more numbers. So I can have zero 1s. So here's where we began.