Placeholder Image

Subtitles section Play video

  • >> [MUSIC PLAYING]

  • >> [MUSIC PLAYING]

  • DAVID MALAN: All right.

  • This is CS50.

  • [MUSIC PLAYING Tritonal, Cash Cash, "Untouchable"]

  • [MUSIC PLAYING]

  • SPEAKER 1: I'm going to France, and you're going, too.

  • [MUSIC PLAYING]

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

  • to the intellectual enterprises of computer science

  • and the arts of program-- and for the first time in history,

  • Yale University's as well.

  • Indeed, whether you're here in Cambridge or in New Haven or Miami or St. Louis

  • or Amsterdam or anywhere around the world

  • taking CS50, computer science E50, CS50X, CS50 AP,

  • we are all one and the same.

  • Welcome to CS50.

  • >> What we have--

  • >> [APPLAUSE]

  • >> [LAUGHS]

  • >> [APPLAUSE]

  • >> So I made a mistake myself some time ago when I started off college.

  • And I got to college, and I decided to frankly, stick within my comfort zone.

  • I ended up declaring a concentration, or a major, of government.

  • Ant that was mostly a function of me being pretty familiar with government

  • or at least history or I really liked constitutional law in high school.

  • And so when I got here, I kind of gravitated toward things

  • with which I was already familiar.

  • Right?

  • God forbid I do poorly in the class.

  • I certainly wanted to stay within my comfort zone,

  • and it wasn't until sophomore year that I finally

  • got up the nerve to step foot in a classroom called CS50.

  • And at that point, did I finally realize that, my God, homework could actually

  • be fun.

  • >> Indeed, I was one of those kids that on Friday evenings when

  • the P-SETS would be released, I would go back to my room and dive

  • into the night's P-SETS.

  • And for me, that was a sign that this was a field for me.

  • But what was more important was the fact that I did get up this nerve

  • to explore waters unfamiliar to me and get beyond my own comfort zone

  • and frankly, I only was able to do that sophomore year by taking this class

  • pass/fail.

  • >> Indeed, it was the very last day that I finally switched over and finally

  • declared CS as my concentration, putting gov at that point behind me.

  • And so we're not setting out in this course to turn all of you

  • into CS majors or concentrators, but rather to give you an opportunity

  • to hopefully go beyond the world with which you're currently familiar

  • and bring back from this world skills and knowledge and savvy

  • that you can apply to your own world, whether that's

  • in the humanities, social sciences, natural sciences, or beyond.

  • >> Indeed, if you're feeling a little intrepid

  • about being in this room let alone in this class,

  • realize that if history is any indication, 72% of you

  • have never taken a CS course before.

  • So it is by all means not the case that the student sitting to the left

  • or to the right or in front or behind you knows far more about CS

  • or programming in particular than you.

  • That's not in fact the case.

  • And indeed, much of the support structure

  • that we've set up in this course over the past many years

  • has been for exactly that reason-- to provide an on ramp that still exits

  • just as rigorously and just as high as ever--

  • but the slope of which allow students less comfortable and more comfortable

  • alike to succeed irrespective of his or her prior background.

  • >> Indeed, what ultimately matters in this class is not

  • so much where you end up relative to your classmates

  • but where you in week 12 end up relative to yourself

  • in week zero, which is where we are here today.

  • >> Indeed and this may very well and probably does look like Greek

  • to many of you.

  • But rest assured, that this and so much more

  • is going to be completely within your grasp in just a little bit of time.

  • >> But today, we focus on some of the higher level ideas

  • to give you a taste of CS50 and computer science

  • in a sense of what you're signing up for.

  • And indeed, computer science might be distilled more

  • simply as computational thinking-- thinking like a computer, if you will.

  • And there's so many different things ingredients that go into that,

  • but let's propose just three for today.

  • If the goal of the class ultimately is not to teach you programming,

  • is not to teach you C or PHP or SQL or any number of the words

  • and acronyms in the course's description,

  • but rather to teach you to solve problems more effectively

  • and to think more methodically and more algorithmically, so to speak.

  • Let's see what exactly this means.

  • >> So I would propose that thinking computationally boils down

  • to solving problems.

  • What do you need to solve a problem?

  • You need to input-- like the input to the problem--

  • you need an output, which is hopefully the solution,

  • and then you need a process by which to solve that problem, which

  • we'll call an algorithm-- a set of instructions for solving some problem.

  • >> But first, let's focus on the first and the last of these inputs and outputs.

  • Computers after all, apparently only understands zeros and ones.

  • But how can that possibly be?

  • Even if you're not familiar at all with what's underneath the hood,

  • you probably at least heard that computers understand binary--

  • just zeros and ones-- but how can you possibly do anything interesting?

  • >> Well, one of the themes of the class is going

  • to be this layering-- where today, we'll take a quick glance at the lowest level

  • details, but with each passing day, where we layer

  • or abstract on top of those details to actually solve higher level

  • problems of interest to us.

  • >> So here is what we might call binary-- with just an alphabet of 0 and 1.

  • But we humans are mostly familiar with decimal.

  • Dec meaning 10.

  • Bi meaning two.

  • And so in the decimal system, we have 10 digits

  • at our disposal-- of course, zero through nine.

  • So if you look at a number like this, most of you

  • intuitively just grasp that is 123.

  • There's nothing really hard about that.

  • But why is it 123?

  • Well, if you think back to grade school-- or at least

  • the way I learned this kind of world-- you

  • might recall that we treated these things in columns, or places.

  • >> So we have the ones place on the right.

  • The tens place in the middle.

  • The hundreds place on the left.

  • And then how do we get from this pattern symbols--

  • 1 2 3-- to this higher level idea that we know as 123?

  • Well, it's just some simple arithmetic.

  • Right?

  • >> The one there is essentially means give us 100 times 1 plus 10 times

  • 2 plus 1 times 3.

  • And of course if we do out the math there, it's 100 plus 20

  • plus 3-- otherwise known as 123.

  • >> So if you're on the same page as that right

  • now and are comfortable with the so-called decimal system as a human,

  • it's actually well within your scope of comfort

  • to consider now the binary system.

  • Take a wild guess-- this represents, in the world of computers

  • in binary-- what number?

  • Zero.

  • >> But why is that?

  • Well, it turns out that the columns or places here-- they're not powers of 10.

  • 1, 10, 100, 1,000, and so forth.

  • They're instead, quite simply, powers of 2.

  • So, 1, 2, 4, 8, 16, 32, and so on.

  • And so now we of course get to 0 here simply because we have 4 times

  • 0 plus 2 times 0 plus 1 times 0, which of course gives us 0.

  • >> But how do I go about representing the number 1?

  • What's the pattern of zeros and ones to represent

  • the number we humans know as 1?

  • 001.

  • And 2?

  • 010.

  • >> And now the pattern starts to repeats.

  • Now it's 011.

  • And again, 0 fours, one 2, one 1.

  • So 2 plus 1.

  • That's 3.

  • >> And now to represent 4, we don't just change that 0 to a 1.

  • You sort of have to carry, so to speak, and the numbers

  • start flipping around just like in the decimal world.

  • >> So this is 4.

  • This is 5.

  • This is 6.

  • This is 7.

  • And so we've counted as high as 7.

  • >> Now all we just need is more a bits-- more zero's and one's.

  • And indeed "bits", if you've heard this term-- binary digit.

  • Bit is where that comes from.

  • And so if we want to represent bigger numbers, we need more bits.

  • But let's move away from slides now to something a little more real.

  • Suppose that we want to actually represent this thing.

  • >> Well let's take a look now at a little demonstration.

  • So this is a web based application that one of CS50's own, Michael G,

  • put together this summer to help us elucidate exactly this idea.

  • And would someone like to venture up on stage

  • in front of all his or her classmates?

  • Right there in front.

  • Come on up.

  • >> You have to be comfortable on camera and the internet.

  • Oh, right here.

  • OK.

  • We're OK.

  • All right.

  • Come on up.

  • What's your name?

  • Emily come on up.

  • So this is Emily.

  • What year are you?

  • >> Freshman.

  • >> Emily, nice to meet you.

  • David.

  • >> All right.

  • So up on the screen here, we have this touch screen

  • which is going to allow us to actually interact with this program,

  • and it's just a browser.

  • It's Chrome full screened at the moment, but it's

  • been programmed by Michael to respond in a way that allows

  • us to play around with binary digits.

  • >> So for instance, here we have not three but eight bits-- zeros and ones.

  • Right now, we're looking at the number 0.

  • And indeed, all eight zeros in decimal means zero.

  • So that's all that's being hinted at here.

  • >> So if you wanted to represent the number 8,

  • what's the pattern of zeros and ones that you want?

  • You can simply tap up or down or the numbers themselves.

  • All right.

  • So that of course is 8, as you can see up there.

  • And if we wanted to do 16, what do we do?

  • >> Yep, just touch it again.

  • 16.

  • All right.

  • So this is all fine and good, it's still very low level.

  • We need a way in the real world for Emily

  • of actually representing these things.

  • And so suppose that we turn these zeros and ones, which is very

  • conceptual, into actual light bulbs.

  • Right?

  • >> A computer is a physical, mechanical, electrical device.

  • And its input-- at least if you plug it in or charge it--

  • is to have battery power and electrons flowing in and out.

  • >> So now, why don't we stop thinking about bits as zeros and ones,

  • but something more physical like light bulbs here.

  • And if Dan Armendariz could join me for just a moment-- come on up--

  • we're going to queue up an application.

  • >> Come on over, Emily.

  • Sorry this is the most awkward demo for you ever.

  • Come on over here.

  • We're going to queue up with thanks to Dan

  • Armendariz, another member of our staff, an application known as binary bulb.

  • >> So what we have here is an iPad application

  • that has the following user interface on the screen for Emily.

  • It's just got the same exact UI essentially that's over there.

  • And if you now want to represent the number, say 8,

  • how would you go about doing this noticing at the right,

  • the light bulbs that we have here?

  • Ah-ha.

  • Magical.

  • So if we want to now turn this into something a little more challenging,

  • and let's go ahead and pick a random number like the number 50 here.

  • Input this.

  • And if you can now be challenged to come up with the number 50,

  • we'll have a fabulous prize for you.

  • >> EMILY: OK.

  • Oh my God.

  • DAVID MALAN: Arithmetic is indeed hard in front

  • of hundreds of your classmates.

  • But 50 has been the answer here.

  • >> [APPLAUSE]

  • >> And so now, this is meant to be demonstrative for Emily.

  • So, in here, is some light bulbs quite like these,

  • but it's actually the little magnetic strips.

  • And what's cool about these and the reason we use them in CS50

  • is that they support something called an API-- an application programming

  • interface, which is just a fancy way of saying that what one of our staff

  • did over the summer was create an iPad application here

  • that talks over the internet to the light bulbs over