Placeholder Image

Subtitles section Play video

  • >> [MUSIC PLAYING]

  • >> [APPLAUSE]

  • >> DAVID J. MALAN: This is CS50, Harvard University's introduction

  • to the intellectual enterprises of computer science

  • and the art of programming.

  • Now if you are among those that every year are sitting here

  • with a bit of nerves in your mind, such that you don't think you belong here,

  • you think that most anyone sitting around you

  • knows far more than you, is indeed more comfortable than you at computer

  • science or computers more generally, realize

  • that 78% of the students who now take CS50 have no prior experience.

  • >> Indeed, there's 100 dots there on the display, 78 of which

  • are solid green, which means you, if you're among that demographic,

  • are in very good company here on out.

  • And if you are instead among the 22% of CS50 students who do indeed

  • have prior experience, whether in high school or some other program,

  • realize that you, too, will be challenged in the course.

  • >> Not only do we have different tracks for students less comfortable and more

  • comfortable alike in sections, we also have so-called hacker editions

  • of most problem sets that will challenge those students

  • with that additional experience to explore similar material

  • but from a more sophisticated perspective.

  • >> But what is computer science?

  • Well, ultimately, what's going to matter as you explore this field is not

  • so much where you end up relative to your classmates,

  • but where you yourself end up in week 12 versus where you begin here

  • in week zero.

  • Now computer science-- well, let's call it the science of computation--

  • where computation is really just a fancy way of saying, taking some input,

  • producing some output, and doing so by running algorithms,

  • sets of instructions for solving some problem on those inputs

  • in order to produce some output or solution in which you are interested.

  • >> So we recently had occasion to travel out

  • to California to meet with an alumna.

  • Her name is Susan Wojcicki.

  • And she'd like to speak to you here on video

  • to testify to just how applicable even just a taste of computer

  • science at the introductory level can be.

  • Even if you don't go on to pursue computer science as a field,

  • or even engineering, or STEM more generally,

  • you'll see, in fact, how a certain course so influenced her life.

  • And she only just took it when she was a senior here at Harvard College.

  • >> If we could dim the lights for Susan.

  • SUSAN WOJCICKI: Hello, world.

  • I'm Susan Wojcicki.

  • I'm the CEO of YouTube.

  • And I took CS50 when I was a senior at Harvard in 1990.

  • I was actually a history and literature major.

  • >> And my junior summer, I realized that maybe I

  • wanted to learn something about computers.

  • And so, I came back.

  • I took CS50.

  • It was hard, but it was the most amazing class I took.

  • >> It changed how I think about everything.

  • And when I graduated from Harvard in 1990, I went to Silicon Valley.

  • And I got a job.

  • And I've been working in tech ever since.

  • DAVID J. MALAN: Now what Susan didn't mention in this video,

  • that it was actually in her garage that Google itself was

  • founded by Larry and Sergey.

  • >> Now we also reached out to our friends at code.org, an organization that

  • over the past year has been getting people particularly

  • excited about computer science and programming, in particular.

  • But it's worth noting that programming is not computer science per se.

  • Computer science is not programming.

  • Rather programming is just a tool-- with which all of you

  • will be all too well familiar by semester's end--

  • such that you can apply not just to future courses in CS

  • but to whatever fields from whence you're coming, in humanities,

  • social sciences, natural science, or the like.

  • >> Indeed, allow a few other alumni and their colleagues

  • to speak to the applicability of the field that awaits.

  • >> BILL GATES: I was 13 when I first got access to a computer.

  • >> JACK DORSEY: My parents bought me a Macintosh in 1984

  • when I was eight-years-old.

  • >> MARK ZUCKERBERG: I was in the sixth grade.

  • >> SPEAKER 1: I learned to code in college.

  • >> RUCHI SANGHVI: Freshman year, first semester, Intro to Computer Science.

  • >> BILL GATES: I wrote a program that played tic-tac-toe.

  • >> DREW HOUSTON: I think it was pretty humble beginnings.

  • I think the first program I wrote asked things like,

  • what's your favorite color?

  • Or how old are you?

  • ELENA SILENOK: I first learned how to make a green circle

  • and a red square appear on the screen.

  • GABE NEWELL: The first time I actually had

  • something come up and say, hello, world.

  • And I made a computer do that.

  • It was just astonishing.

  • >> MARK ZUCKERBERG: Learning how to program didn't start off

  • as wanting to learn all of computer science

  • or trying to master this discipline or anything like that.

  • It just started off because I wanted to do this one simple thing.

  • I wanted to make something that was fun for myself and my sisters.

  • >> And I wrote this little program.

  • And then basically just added a little bit to it.

  • And then when I needed to learn something new,

  • I looked it up, either in a book or on the internet,

  • and then added a little bit to it.

  • >> DREW HOUSTON: It's really not unlike playing an instrument or something

  • or playing a sport.

  • DAVID J. MALAN: All right.

  • So let us now actually dive in a little deeper.

  • What are these inputs and outputs that we're talking about here?

  • >> So how about something simple?

  • You probably know, even if you have no familiarity with computer science

  • whatsoever, that computers somehow use and understands only zeros and ones.

  • But how can that possibly be given how much today's desktops and laptops alike

  • can do?

  • >> The DNA of the day, the only alphabet that they understand

  • is a zero or a one.

  • Well, consider this.

  • We, humans, tend to use the decimal system. "Dec" meaning 10.

  • And that's 10 because we have 10 digits, 0 through nine.

  • >> Now computers, by contrast, tend to use binary.

  • "Bi" meaning two.

  • So they tend to use only zero and one.

  • But it turns out, that even just with zeros and ones, that

  • is a sufficiently large alphabet with which to represent most

  • any piece of data you want, whether it's a number,

  • whether it's a letter, whether it's a graphic or video on the screen.

  • >> Consider, for instance, how we humans typically interpret this number here.

  • This is just three digits, one, two, three.

  • But we know this number innately now as 123.

  • But why is that?

  • >> Well, if you think back to perhaps grade school,

  • you probably were taught to think of these numbers as being in columns,

  • where the one is in the hundreds place, the two is in the tens place,

  • and the three is in the ones place.

  • Why is that actually useful?

  • Well, think about the super simple arithmetic

  • that we all have been doing for years now.

  • Effectively, if you've got a one in the hundreds place,

  • you do the quick math 100 times 1 plus 10 times 2--

  • because two is in the tens place-- plus 1 times 3--

  • because three is in the ones place.

  • So, of course, if we actually multiply this out,

  • what we're really representing with this pattern-- one

  • two three-- is 100 plus 20 plus 3, which, of course, is 123.

  • >> Now binary, and computers really, fundamentally speak the same language

  • that we do.

  • They just have a smaller alphabet.

  • So computers only have zeros and ones at their disposal.

  • So whereas we humans have essentially powers of 10 in each of these places--

  • 10 to the zero, 10 to the one, ten to the two, giving you 110 and 100

  • respectively.

  • >> Because computers only have two values they can understand, zero and one,

  • they have to use different values in these columns, one, two, four.

  • And if we kept going, eight, 16, 32, 64, and so forth.

  • But the pattern and the mentality is exactly the same.

  • >> So by this logic, anyone, how would I go about representing the number

  • one in binary?

  • If you've never even thought about this before, what's your gut say?

  • >> AUDIENCE: One.

  • DAVID J. MALAN: One.

  • Exactly.

  • We just need a one in the ones place because the zeros

  • suffice to give us neither a four nor a two.

  • So one times one equals one.

  • Now things get a little interesting.

  • If I want to represent in binary the number two-- but,

  • again, even if you've never spoken this language before,

  • how do we represent in binary the value we humans know as two?

  • Zero one zero.

  • Just put the one in the column that you want it.

  • >> Now it's getting pretty easy probably now.

  • So if I want to represent three-- there is no three's column.

  • So, again, I can now add these values together by putting a one here.

  • So 2 times 1 plus 1 times 1 is, of course, 3.

  • >> Now things get a little fun in that the ones now become zeros.

  • And to represent four, I get this.

  • And if we increment slowly here-- that would be five.

  • This would be six.

  • This would be seven.

  • >> But now I seem to have run into a problem.

  • How might I go about representing eight-- would be the next value.

  • Yeah, so we need a new bits.

  • And, indeed, if you've heard this phrase before,

  • bits, that's just short for binary digit, zero or one.

  • >> And so I happen to be representing only three such bits here.

  • But if I had a way of storing not three different bits, but four,

  • surely I could represent eight, and then nine, and then

  • 10, and even higher and higher.

  • >> But that then calls into question how we can

  • go about representing these things in the first place.

  • It's one thing to draw them up here on a slide,

  • but how do you represent them if you're a mechanical device?

  • What is a computer doing to represent the inputs and outputs that

  • fundamentally define computation at the end of the day?

  • >> Well, what about something super simple like this?

  • It's just a light bulb.

  • And I can trigger this light bulb to go on

  • by turning some electricity on and allowing electrons

  • to flow through, which changes its state or its value, so to speak.

  • For instance, this is an old school desk lamp

  • here with one such light bulb inside of it.

  • And right now it's not really doing anything useful.

  • But as soon as I plug it into an electrical socket

  • and then use this switch-- or we can even call it a transistor

  • or think of it as such-- I can now represent either

  • this value, where the light bulb's obviously off, or this value.

  • This value or this value.

  • This value and so forth.

  • >> So inside of a computer, presumably, are much smaller pieces of hardware,

  • but that at the end of the day simply have

  • to use electricity-- perhaps capture it--

  • and then either keep something on or keep something off.

  • Of course, this isn't particularly interesting to do

  • with just a single light bulb.

  • >> In fact, how high can I count in binary with this desk lamp here?

  • >> AUDIENCE: One.

  • >> DAVID J. MALAN: One, right?

  • I need more desk lamps if I actually want to count higher.

  • But we can do better than that.

  • Because the light bulbs that we've put in these things

  • are actually fancier light bulbs than yesteryear would allow.

  • And they're actually networked light bulbs.

  • And bunches of companies make these things these days.

  • >> But it turns out that this one in particular

  • comes with a feature whereby you can change its colors.

  • So for instance, if you adorned your dorm room

  • with a few of these light bulbs, depending on your mood,

  • depending on who comes in, depending on the weather,

  • depending on the time of day, you can actually

  • change the colors of the bulbs in your room.

  • And that's because these light bulbs and others like it have what's

  • called an API, an application programming interface, which

  • is a topic with which you'll be well familiar with by semester's end.

  • >> And this is just a fancy, cryptic way of saying,

  • you can program these light bulbs to do your bidding.

  • You can send them messages just like you, a human,

  • can send a message to a web server saying, give me today's news

  • or give me my email.

  • >> You can send more arcane messages to these light bulbs

  • to say, turn on and turn off.

  • But that's not all that interesting.

  • You can say, turn on red, turn on green, turn on blue,

  • all with the same light bulb.

  • And you can even, with a bit more savvy, say, turn yourself to blue

  • when it's a gloomy day outside, for instance.

  • It can actually patch into a weather API and find out

  • what the weather is, or the time of day, or other such triggers.

  • >> So, in fact, two of CS50's own staff members,

  • Dan Bradley and Ansel Duff here, kindly procured

  • us a whole bunch of these light bulbs.

  • And they built CS50's first ever binary bulbs,