[ Music ]
[ Laughing ]
[ Music ]
>> Yeah.
[ Applause ]
>> My name is David Malan and this is CS50.
77% of the people around here
in this room have no prior experience
and that was the same way last year
with your 494 predecessors all of whom accomplished the sorts
of things that you saw depicted in those screens there.
There's a lot of misconceptions about computer science
that it is dominated by folks with their heads
down at computer terminals toiling away,
completely anti-social.
A reputation that it is dominated by men and not
so much women, and yet these are things that are changing.
In fact, last year alone we had a record number of women
in Computer Science 50, up to 37%, almost 40,
and I don't doubt before long that we will be
at 50/50 perhaps even this year here too.
And realize too, that if you're thinking what the hell am I
doing in a computer science class,
realize that same emotion is probably going on in maybe 77%
of the people to your left or to your right today.
But indeed, there's a whole gamut of comfort levels
that we have in this course and these are statistics
that are consistent throughout the years.
Last year 46% of the students in this course declared themselves
as being among those less comfortable.
There's no precise definition for that but you kinda know it
if you're in that bucket and perhaps some
of you have already just slapped that label on yourselves.
We had last year 42% of the students
in the class being somewhere in between less comfortable
and more comfortable with 12% of the class being those types
who may very well have been programming
since they were 10 years old or who took AP computer science,
but we have all sorts of demographics in the class,
and as you'll see today and on Friday, there are a number
of ways in which all students in this class can approach it
and ultimately succeed as in that imagery there.
And in no small part that's because of the sheer size
of the teaching staff this course has.
Seated in front of you are only those TF's and CA's
who are skipping classes right now,
but indeed we have some 87 teaching fellows
and course assistants on staff, many of whom you will meet
over the course of the semester.
Now what is computer science?
We've started this class in recent years
with a little demo involving tearing a phone book
and you might've heard about this sort of thing before
and it's a little hard to keep doing the same bit even though
it might very well send a very compelling,
we think, pedagogical message.
But I just found a huge stack of phone books in [inaudible]
in the computer science building this year, so I thought we might
as well do justice to last year's phone book
by actually having some
of our own team members here answer a question of this form.
So a phone book of this size has, you know,
some 1,000 pages in it.
And this is a fairly tedious problem to solve
if you're looking for something very small,
a needle in a haystack so to speak.
And so if you're looking for, let's suppose these are not
so much yellow pages but white pages with people's names
in them, someone like Mike Smith,
well you could certainly start at the beginning and turn
to the next page and you could see that you're on the A's.
You could see that you're on the B's and the C's and then
so forth and my god some 600 700 pages later, we might happen
across Mike Smith, but if we could perhaps have
about every third TF and CA here stand up,
perhaps we can do something a little more compelling than that
and send home the first such message of the day
as to what it actually means to do computer science
and to solve problems, as we say
in the course catalog description,
more efficiently and more effectively.
Those TF's and CA's who now have handbooks,
phone books in their hands, if you could please stand up
and let's see if we can't have the audience here too answer a
bit of, here we are, let's see do you wanna just keep passing
these down, otherwise this is gonna take all day.
Why don't we have each of these guys solve this
in what's probably a much more intuitive way.
I'll hang onto one for myself and of course anyone
from the audience probably now can point out that my algorithm,
my procedure that I proposed a moment ago starting
at the beginning and turning to the right, turning to the right,
might very well be correct.
And indeed it is correct but it's kind of stupid, right?
Because clearly we can do better than this.
So anyone in the audience,
what would a reasonable human being do to find Mike Smith
in a phone book of this size?
>> Tear it in half.
>> So te- tear it in half.
So we'll get there.
So you'd look roughly in the middle right?
You sort of haphazardly pull it on into the inside.
So if our volunteers here standing
with phone books could do exactly that, odds are,
Matt you ended up at what letter in the alphabet?
>> M.
>> M, indeed which makes sense 'cause it's roughly
in the middle of the alphabet and so Mike Smith is now clearly
to the right so perhaps our TF's
and CA's could demonstrate exactly how we can chop this
problem in half now.
[ Laughing ]
Most. . . perhaps most of our staff can demonstrate this.
So now we've got a problem that's half as big, right?
Now we have the M's through the Z's and so we might dive
in again and so the staff might split the phone book in two
yet again and now we've gone from 1,000 pages to 500.
We're about to go now instead to 250.
So if you'd like to iterate here again and tear.
So now we're down to just 250 pages and if you guys want
to repeat and repeat and repeat, after just a few tearings
of this, only around 10 in fact,
should they finally reach just a single page and on
that page should ideally, if they were paying attention
to the pages that they were tearing be someone, [laughter]
and I don't know what's going
on here [laughter] would be Mike Smith.
[ Applause ]
So thanks to our team here.
These are just a few of the faces you'll meet
over the course of the semester.
You're welcome to sit here the entire lecture, that's fine,
but in a moment we'll need just two of our team.
So what did this really do for us?
Well we went from a problem of size, again,
1,000 down to a problem of size 500 to 250
and this is a very powerful thing.
We're not just taking one page at a time
but rather we're taking huge, non-trivial bites
of this problem out at any given time.
So what does this actually mean?
Well, let's consider another example and, whoops,
let me zoom ahead to an algorithm here
so that we can get the juices flowing among the audience here
as well.
So every year it's a real pain to do attendance in a room
of this size and it would take me forever,
much like it would take me forever to find Mike
in this phone book, I could start sort
of like your grade school teacher would and do one, two,
three, four, five, six, and seven, and finally we'd get
up to N, the total number of students in the room.
Now what's a modification to that algorithm
that you probably learned say in middle school or in high school.
How could we speed up that algorithm very easily,
very mindlessly?
You count by two's right?
Instead of doing one, two, three, I'm pretty good
at counting even numbers so I can do two, four, six,
eight and so forth and so if we were
to plot this just very simply on a chart,
if I said that my original algorithm was just counting one
at a time and there's N students in the room,
well that algorithm's gonna take N steps, N seconds, N minutes,
N operations, whatever the unit of measure is.
But if I start counting in twos, well I can double the speed
of this algorithm and that's pretty good but my god it feels
like there's room for opportunity here
at the right-hand side.
And though I'm jumping around and spoiling some
of the imagery, let's see if we can't paint this picture
as a group as to how much faster we can count everyone
in this room than I could.
So if you would humor us, the staff of 50,
if everyone in this room could now stand up and think
to yourself the number one, go ahead now and execute step two,
pair off with someone near you, add your numbers together
and just one of you should sit down.
[ Audience chatter ]
>> Do we know what the total is roughly?
>> What's that?
>> Do we know what the total is roughly?
>> [Inaudible]
>> Oh god, I don't know.
>> Can you try to figure it out in the next 30 seconds?
>> [Inaudible]
>> Okay.
[ Audience chatter ]
>> So those still standing should continue pairing off.
. .
[ Audience chatter ]
And we see just a few folks still standing.
. .
[ Audience chatter ]
It's at this point where the demonstration starts
to get a little awkward 'cause either the people get far away
or the ri- arithmetic gets difficult.
[laughter] How many folks do we still ste- have standing?
I see one, two at at the top,
you two up at the top can pair up,
you three up at the top can pair off.
Anyone else down here still standing?
You two. What what's your number here?
>> 52.
>> 52 plus?
>> 91.
>> 52 plus 91 and what do we have in the balcony?
>> Balcony, 119.
>> 119 total or just you?
>> [Inaudible]
>> 172? Anyone else still standing?
>> [Inaudible]
>> Okay yeah?
>> 159.
>> 159. Uh oh.
I didn't hit plus, now we're up to 17,000.
[laughter] Anyone else?
We're gonna fake the rest of this.
>> [Inaudible]
>> 45 which puts us at 18,000 [laughter]
and the total should indeed be, did our teaching staff come.
. .
>> Yeah, 570.
>> 570. So plus, wait plus?
>> 121.
>> 121?
>> Yeah.
>> Okay so the the preface
for this demonstration historically is
that this algorithm tends not to work so well in reality,
but there, if you consider it
on a theoretical level how much faster that could,
how much faster that should have gone,
well indeed if I were still counting like this
and there were, let's say 500 people in this room,
my hand would've had to point at 500 people individually,
or better yet maybe 250 total iterations;
but how about your all here?
There's 500 people in the room, but on every iteration
of this algorithm, this procedure, this program,
call it whatever you want-- half of you were sitting down.
So it's much like this same phone book example.
500, 250, 125, and so forth and so
that begs the question how many times can you divide a room full
of 500 people in half?
Well, feels like it's only around nine if you do
out the math and you kind of ignore rounding errors
and so forth you'll get down to a single, lonely,
awkward volunteer standing in the middle
of the room ideally containing that number,
and I simply facilitated here by merging some
of these numbers together.
And that's a powerful thing because if we go back now
to where we started, counting sort of like in grade school,
and then we upgraded to twosies in middle school,
but now we have something fundamentally more powerful
and that's this notion of logarithmic growth as opposed
to something linear--
linear implying the straight lines there, logarithmic,
this is sort of the end game when trying
to implement something well,
and that will be a theme of this course.
Not just getting something to work, 'cause right,
I could fine Mike Smith the old fashioned way
but it's not slow, it's not efficient.
I'm gonna go use some other website,
I'm gonna go use some other program that performs better
and solves problems more efficiently for me.
Well the other thing about computers is
that they're not all that,
actually I did have one snippet here, let me pull this back.
Wimbledon.
So you might be familiar with the notion of tennis
and these tournaments that happen each year,
and in Wimbledon we have some,
what is it 128 people participating
in a given tournament?
And that tournament actually goes fairly rapidly
because when you're playing tennis of course you're playing
against another person, and so every time a game is played
and if you're assuming single elimination, you get to halve
and halve and halve and halve the number
of players participating until you have ideally just one winner
at the end of the game.
But imagine now how we can apply this idea of divide and conquer,
taking a problem and splitting it in half, and then in half
and then in half whereby we're not doing anything new
and different each time, we're doing the same darn thing again
and again but the problem is rapidly approaching the
solution, just one.
So I looked it up on Wikipedia earlier today and there's
about seven billion people on earth right now.
Well you know what's a pretty powerful thing?
We could actually have a worldwide tennis tournament
where all seven billion, maybe lets even round
up to eight billion people, could participate
and how many rounds would that actually take?
Well, how many times can you divide roughly eight billion
people in half?
Well you go from eight to four, four to two, two to one,
one to a half billion and so forth.
Well you know what, we could knock off this global Wimbledon
tournament after just 33 rounds of play.
Now, admittedly we'd need a whole lot of tennis courts
to be doing this all in parallel and simultaneously
but that's the power of actually thinking through
and actually coming up with algorithms
that are much more elegant and efficient
than what might otherwise be obvious.
The problem though is that computers need to be told what
to do and we've all gotten frustrated by computers
when they don't behave as expected
and that's usually not even your fault, but the fault
of some programmer who made some mistake,
who didn't anticipate some condition,
or made some assumptions that the user then kind of flaunted.
Well what's an example?
Well if you look up most any cooking book,
well a cooking book will typically start with a recipe
in step one something like put egg in bowl.
Well here's a bowl, here's an egg.
It's kind of assuming a few things.
That's not in fact what the author intended,
so we need to be more precise right?
We need to make m- we cannot make so many assumptions.
If we want the computer, if we want the cook
to do what we want him or her to do, we need to be more accurate
and we need to think about how best to express those things.
Now you've probably not had the fun of filling
out your own tax forms, but by contrast,
the world of federal taxes is very much the opposite.
You get these crazy worksheets that are now available
in PDF form or you can use software like TurboTax
and the like, but if you just glance at this sort
of thing you'll see that it's ever so precise.
For instance, it asks you to check a box and input a number
in row five, in row six, in row seven,
and then it explicitly says in row nine,
add lines five through eight.
In other words, the process of taxes is actually,
though overwhelming, much more precise.
It doesn't just say add up what you earned this year
and let us know, right?
It's much more precise than that.
So perhaps we could do something like that along the lines
of something more familiar and less daunting than taxes.
In a moment I'm gonna go ahead and play some background music
and let me ask that you humor us here too by pulling out a sheet
of paper and writing in no more than one, maybe two minutes,
an algorithm, a ste- a set of procedures,
some number of steps line by line
with which you could instruct a computer or a human
or just a friend to make you a peanut butter and jelly sandwich
and assume only that you have a jar of peanut butter,
a jar of jelly, a loaf of bread, and a knife.
You have those as your ingredients and so if you would,
take just one minute or two to write out this algorithm
and we'll see how well we have done.
[ Pause ]
[ Music ]
I'll let it play at least once more.
[ Music ]
Let's do one more iteration.
[ Music ]
And go ahead and finish what you're working on.
I'm gonna need a couple of volunteers.
How 'bout you two lovely contestants?
Come on up.
And how 'bout you folks who have not been prepped on the staff?
Yes I see two hands, how 'bout in the red shirt here and some
of someone from this side, someone from this side.
. . more interest.
More interest.
I'm not seeing the, how 'bout you with your hand the highest?
There. Ri- yup, you who just turned around.
Yeah, come on down.
There'll be ample opportunities during the remainder
of the term.
So, now there's still an opportunity
for some participation here.
I need two people's algorithms
that they actually wrote down, all right?
Better be good.
Thank you.
>> Preview it, it's right there.
>> Okay. Not gonna get this back if that's okay.
And one more volunteer.
>> [Inaudible]
>> All right.
All right these'll be very short demos.
All right, so we've got four of our volunteers here,
only two of whom I actually know.
So let's see your name is?
>> I'm Daniel.
>> Daniel.
David. All right this is Rob, Zmyla and.
. .
>> Lisa.
>> Lisa. David.
All right so I just so happened to go
to the supermarket before this example
and this was actually inspired by my fifth grade teacher
who at the time, I'm pretty sure did not intend this
to be any sort of demonstration in the pedagogy
of computer science and the ideas behind algorithms,
but really just how to teach 10 year olds how
to follow directions.
Well let's see if we can't go borrow the same spirit of this
since I was well equipped here to go and pick
up some loaves of bread.
So we've got some bread for each of you.
[bag rustling] All right.
[ Pause ]
We've got some jelly here and a knife as promised.
[ Pause ]
We've got knives for each of you.
And lastly, the final ingredient with which
to see how well these algorithms performed--
[ Pause ]
[laughter] All right, so let's see how our two volunteers
here did.
So I'll go ahead and be the advisor.
You all should be behaving in exactly the same manner
that a computer or a robot, let's say,
would actually interpret these as making no assumptions.
All right, step one, go to the Annenberg lunch table.
[laughter] Okay.
All right let's try, let's start with the other one
and see where this gets us.
[laughter] So, step one here is take two slices
of bread from the loaf.
[ Laughter ]
Incidentally, I should've said this before,
you have to be comfortable appearing on camera
and on the internet as we do this.
Okay. All right step two, apply two tablespoons
of jelly on both halves.
[ Laughter ]
Step three, apply two tablespoons
of peanut butter in the same way.
[ Laughter ]
[ Applause ]
Step four, join the two halves
[ Laughter ]
And step five, perhaps coupled with a round
of applause, have fun.
[ Applause ]
So, thank you very much to our volunteers.
The the sandwiches are yours.
So, suffice it to say that there's room for improvement
in something like this.
And this might seem like a ridiculous visual
but the reality is when it comes time this semester
to instruct a computer to do something,
you'll be surprised just how often and how bad you are
at that when you're doing this,
most likely for the very first time--
when you're doing this for the very first time.
And so among the lessons that will become ingrained
over time honestly is truly how to think more carefully,
how to think more precisely and in turn,
how to express yourself -- if you can just take the tables
with you-- how to express yourself more methodically
so that the person hearing your counsel, the person hearing
and taking your instructions can actually implement
them correctly.
Now let's come back to this notion of numbers
and this notion of solving things more efficiently,
and this notion of dividing and conquering and really the notion
of things taking more time or less time--
[laughter] all attention is clearly focused right here right
now isn't it?
[ Pause ]
Okay.
>> We have an algorithm too.
>> No problem.
Very nice.
All over the internet this is now.
All right thank you to the team.
So consider this, suppose you were asked,
and let's pick a volunteer up front here
since you just caught my eye.
So we can have this conversation right here.
I will hand you a million dollars,
I will write you a check right now for a million dollars
or instead you can have a penny today but two pennies tomorrow,
four pennies the next day but just for a month.
Which would you prefer?
>> [Inaudible]
>> Take the pennies.
>> All right so right, frankly, whenever asked in life
to make a choice between something that sounds good
and something that sounds stupid, take the stupid thing
because there's probably a hidden lesson
in there and indeed there is.
If we consider this-- oh I just reneged didn't I?
So consider this-- actually we did come prepared.
Can't quite cover it today, but this'll get me
through the week I think.
[laughter] So why do I suggest we can't quite cover that?
Well let me just open up something like Excel.
Let me say now and just once
that Excel is not computer science, but we'll use it simply
because it's a nice way of just doing some numbers real quickly.
So suppose that on day one I were given a single penny
and on day two I get twice as many and then twice as many.
Well I can do a silly little Excel formula here
where I just say times, times two,
and then I can just repeat this and repeat this and repeat this
and repeat this, and this is getting tedious
so let me just highlight all the way up to say 31 days in a month
and his paste, and by the time I get
up here you might very well have made the right choice.
In fact just to make this point ever so clear,
let's go up to formatting-- this too, not computer science--
let's go to currency, okay,
just so we can see this a bit more visually, and my god!
You banked 10 million dollars
from that deal so, three weeks ago.
So it's quite extraordinary what happens
and what's the relationship here?
Well the actual math behind all of this
and the actual thinking is actually the same;
whereas before we were dividing, dividing, dividing, and dividing
in half again and again and that allowed us
to solve something much faster than with some simple, if naive,
approach, the implications are the same in reverse.
So if you actually do something foolishly, or in this case
without thinking, the cost can certainly pile up over time.
And so one of the other themes in the course,
and in programming more generally is going to be
about the amount of time it actually takes
for your programs to solve problems.
Every one of us has probably gotten angry at our computers
at some point 'cause of the stupid spinning beach ball
or hour glass or something like that
that means it's thinking or doing something.
Well it's probably not doing it all that well, and once you get
to the point of implementing the next Facebook or Google.com,
you've got to be better than just linearly searching
through all possible pages on the internet in order
to find some search term of interest to you.
Well this sort of works in the s- in a similar way too,
and I mentioned here Facebook-- you're familiar with the notion
of the six degrees of Kevin Bacon perhaps whereby you are
probably connected to someone else via at least six friends.
So I might be friends with Alice, Alice with Bob,
Bob with Charlie and so forth and at some point,
one of those people in that relationship is going
to know Kevin Bacon of all people.
But what's the implication of that?
Well you can actually feel this all the more these days
with Facebook and the like because even
if I imagine something quite simple--
suppose I have just 100 friends.
Well that's actually in Facebook terms these days actually
relatively low right?
But we'll start at that particular point and I'll see
if I actually multiplied, let's say the previous cell up there
by 100 again, the idea being well if I have 100 friends,
those friends, let's assume for simplicity, have 100 friends
and their friends of friends have 100 friends,
how much does this blow up?
Well let's actually do this for six degrees, up to six
and my god, by the time you get six degrees away,
no wonder you know Kevin Bacon
because you have a trillion people in your social network.
Now back in the day a few years ago when Facebook belo-
began only at Harvard and was initially only available
to Harvard students and then nearby universities,
they actually had a neat feature
where they would show you a graph, a visualization
of your friends and your friends of friends and then they ripped
that out and removed it altogether
and at best these days maybe you have some kind of relationship
with friends of friends, because to actually transitively
continue this out, I mean my god you end up knowing everybody
on Facebook and more people than there actually are
in the world at this point.
And so these numbers start to build up,
both upwardly and downwardly.
Well along those lines, let me tease you with this.
So we have a lot of friends that Facebook being that it did
in fact have its origins here and I thought I would tease you
with a little image here.
What we thought we would do this year is invite some
of our friends from Facebook back to campus to some of,
CD50 TF's no less, to help us explore some things like this.
I won't leave this on the screen for too long.
It will be in a PDF online on the course's website if you'd
like to noodle through it further, but this is an example
of a puzzle, and it's hopefully non-obvious
and this too doesn't necessarily relate
to computer science per se but more generally
to the solving of problems.
And that really is what this course is about.
Though we will use programming as a tool to solve problems,
the course at the end of the day is about reasoning through,
taking inputs, producing outputs, and figuring
out the solutions there too.
Now what's the relevance here?
Well our friends at Facebook have kindly offered
to take us all out, or some subset of us,
out to dinner on Friday.
More on that in a little while via email this week,
but they'll also be joining us on Saturday.
And if of interest to you, from roughly 12
to 3 p.m. this Saturday will we have the first ever CS50 puzzle
day sponsored by Facebook.
If this is of interest to you, just go at some point today
to cs50.net/register and the way
in which this will work is you will arrive, you'll be fed,
you'll then be challenged with a handful of PDF's or printouts
of seven prod- p- puzzles similar in spirit to those
but each quite distinct that somehow spell
out a seven letter word that's in fact going
to be a seven letter word on campus.
And if you then go seek that out and do that quicker
than everyone else, you will win some fabulous prizes,
among the first prizes for teams will be some $50 gift
certificates, $25 gift certificates for the runners up,
and for anyone who participates will there be
on a raffle basis a wii given to anyone randomly who partakes,
irrespective of performance in the puzzles.
But, so that this is inherently a social activity
and not a whole bunch of individual people hunkered
down solving puzzles on their own, you'll be required to bring
at least one friend, ideally someone from outside this room,
outside taking CS50 this year,
but up to a maximum of four teammates.
So if you have some block group, blocking group friends
or some link-mates or the like with whom you would
like to do this, we'll post more details
on the course's home page at cs50.net, but do take care
to register because seats will be limited, and if an interest
in the idea of dining with me and some of the TF's
and CA's this Friday night, go to the cs50.net/rsvp
and we will, if necessary, lottery things off
so that you don't need to all be doing this now,
especially since there's not so great wi-fi in Sanders,
we'll actually follow up via the website
and randomize things as needed.
So more on that by Friday.
So speaking of Facebook,
a number of you found your way here
or to other classes today via this tool of ours,
the course's own shopping tool called Harvard courses
that lives at that URL there.
So this tool happens to be integrated with Facebook which,
to be honest, is remarkably easy to do these days.
And indeed, many of our own students do this toward term's
end so that you no longer have to implement the notion
of registering for accounts or remembering
yet another username and password.
You can integrate with Facebook and any other number
of providers like Google and use their own usernames
and passwords without you yourself seeing them.
Well the upside of this too is that we too get
to see network effects of shopping for courses
and hopefully you found it to be a little more efficient
than traditional approaches.
Now with that said, let me personally apologize to any
of you using the tool between 8 p.m. and midnight last night.
I was sitting down preparing for a lecture and got an IM from one
of our TF's, OMG Harvard Courses is down.
That then delayed the preparation for this lecture
by about four hours while we responded to the sudden spike
of interest the night before shoppi-
the night before classes began and actually figuring
out what courses you want to shop.
But we thought we would share some fun facts,
at the moment this particular tool, if familiar with it,
has some 2,500 Harvard undergraduates using it
over the last week alone.
The not- the total number of courses
across your shopping lists collectively as of this morning
at eight was about 25,000.
Particularly fun was to see statistics
like the average number of courses
that your friends are shopping is actually only around seven
but this is highly variant.
This, again, is the average number
of courses people are gonna try to check out this week and next.
The maximum this year
which broke last year's record is in fact, 125.
Now you might think that's an outlier worthy
of just dismissing, but rather, the runner-up was 123.
So you are in good company if you are that 125.
But not to dwell too long on Facebook but really to use it
as a point of departure for just how applicable how things
like computer science and programming more generally are,
oh and I did have one more fun fact I should probably share.
So turns out that if you look at the means
by which people are using the imbedded calendar
if using this tool, the most popular time to be busy is
between 3 p.m. and 7 p.m. presumably because of sports
and extracurriculars and the like,
but I daresay we looked cl- a little closer at the data
and the second most popular time to be busy is [laughter] note,
no 9 or 8 a.m. classes it seems are of interest.
So what are some of the opportunities here?
Well besides doing things and building things that relate
to the tools that you yourselves use,
you can actually still make things
that are just as, say technological.
And as you'll see over the semester,
with relatively little complexity, the margin of return
of spending just a few weeks and the months in a course
like this is that you learn how to build things that you take
for granted as using these days and you take for granted
as being accessible to you in your pocket, but it's remarkable
as those images suggest just how much your predecessors
accomplished over the course of just three months.
One of the tools we built out has a course for students
to use before the Harvard courses tool was this one,
a much simpler tool that simply took what traditionally was
in PDF and paper form alone, the Harvard shuttle schedule,
and allows you to look up things well, I'm in Mem Hall,
I'd like to go to the quad, so I might click there
and click there and now you can see the next shuttles
when they depart.
Now this is becoming underwhelming these days
but indeed this was a huge improvement
when the alternative was just paper.
But you can do cool things too, and as we look ahead
in this course to the final project,
know that you'll be able to make things like this.
If you don't mind, just have to make a quick call.
I've got my thing plugged into the overhead here.
[ Pause ]
>> This is CS50.
For Shuttleboy, press one.
To start over, press nine.
. .
>> So I've pressed one.
>> What is your origin?
For quad, press one.
[Inaudible], press two.
Boylston, press three.
Lamont, press four.
Mem Hall, press five.
To start over, press zero.
>> So I'll hit five.
>> What is your destination?
For quad, press one.
[Inaudible] press two.
To star-
>> Let's go to the quad.
>> The next shuttle leaves in seven minutes at 2 p.m. and then
at 2:10 p.m., 2:20 p.m. and 2:30 p.m.
>> So there's your exit strategy if you're getting bored already.
Well that number was 617-BUG-CS50,
and what's exciting about this is not so much that,
because Frankly you can use SMS, you can use a plastic piece
of card to look up numbers more quickly
than the phone might recite, but that service alone
that CS50 uses for that called CS50 voice is a tool
that you yourselves can use at semester's end if you would
like to build tools that actually make outbound calls,
and or receive inbound calls and respond to some input.
And that's all possible thanks to this notion
of what's generally called an API,
application programming interface.
And these have been entering now even the co- the public lexicon.
To use an API generally means to use data or to use functionality
that someone else has implemented
so that you yourself can stand on their shoulders
and integrate really helpful, really cool,
really useful functionality into your own program
without reinventing that wheel yourself.
You can liken it to the act of building a house.
You could go out and chop down trees.
You could go out and melt glass and make windows,
but what do you do instead?
You go to a store.
You go to Home Depot.
You buy planks of wood, you buy sheets of glass,
and you integrate those pre-fabricated components
into your own work so that your contribution
to the whole process is the final output and you care less
about the al- the underlying details of implementation.
Well, let me go ahead in just a moment here and bring
up our head teaching fellow Matt Chartier
and also our other head Rob Bowden to say a quick hello.
Rob you'll recall was the guy
with the special loaf of bread earlier.
You'll have to talk into my chest
over here [laughter] [inaudible].
[Inaudible] okay.
. .
>> Less awkward.
[laughter]
>> Yes, much better.
Hello everybody, my name is Matthew Chartier.
I'm a senior in Kirkland House
and a concentrator in computer science.
I've also TF'd CS50 for the last two years and am returning
for this year, this time in the role of head TF.
I'm very excited to be back with the course
in this capacity this year to help David organize everything
and to make a wonderful experience for all of you just
like the experience I was treated
to freshman year coming in.
My role as head TF is essentially going to be a point
of contact, both between David and the rest
of our teaching staff but also between the TF's
as a organization, as a staff, and all of you.
So if there are any point during the course
where you have any issues that you you don't really know how
to reach out to, I'm the person you want
to reach out to for that.
Contact me at heads@cs50.net.
You can also re- reach either David
or Rob here at that address.
Just to talk a little about the course
because I'm waxing nostalgic a bit now looking
out over our first lecture for I suppose the last time
and remembering when I came in freshman year
and took CS50 for the first time.
I came in without any prior experience.
I had no formal training in CS.
I'd maybe mucked around a little
in a couple languages just 'cause I was curious
but didn't really get anywhere with it.
And coming into CS50 at the time thinking about concentrating
in something maybe like physics or government,
I found a whole new world opened up to me.
I was exposed to exactly what computers could do
and how powerful these simple programming languages,
just typing statements in text files
and making them do something could really be,
and how exciting it could be to work in that sort of environment
and to really make things happen
with these machines we do every, we use every day.
I also found something else.
This isn't just an intro course, it's sort of an experience
and an institution, and if you don't think that yet,
I assure you that by semester's end you may have a new
perspective for what exactly happens here.
CS50 is one of those rare courses at Harvard College
that is challenging, populace, elaborate, and fun enough
to really create a sense
of community amongst the entire course
and to create something that's not only useful
for you, but memorable.
It's certainly been memorable for me and I can't wait
for one more ride with this great course,
and I hope that you have the same experience.
Thanks a lot and I'll pass the mic off to Rob.
[ Applause ]
>> I'm Rob from Kirkland House.
I'm a junior and this is my second year TFing CS50.
You know we've really tried to make this course
so that you don't really feel like you're doing work,
you feel like you're having fun.
You really get this sense of accomplishment
when you finish a problem set.
How often do you take a course
where when you finish a problem set you can show it
to your roommate and they can play a game,
or you can give a URL to a friend back home
and they can see what you've done.
So, like Matt, like Matt said, this course does have a culture
and I just want to encourage you to really get
into it 'cause it's so much more fun that way.
And especially for the largest chunk out, of you out there
who are less comfortable, there's no reason
to feel alone even if you get frustrated.
We do have this staff of 87 people.
We're all here to help you make this class the best it can be.
So I hope you have a fun semester.
>> Believe it or not-- thank you both--
believe it or not I started out in life as a, thank you.
[ Applause ]
So for what it's worth,
testament to just how fun this particular world can be,
I started out life here as an undergraduate in 1995
and was heads down into the government department thinking
I'd come in ha- having liked things like history
and [inaudible] in high school and such
and so I didn't really think
about exploring a bit beyond my own comfort zone.
And indeed, CS50 then and to some extent still now,
as well as computer science more generally, has this sort
of daunting reputation that it's not so much for the uninitiated,
but rather for those who've been doing it
since the beginning of their life.
But that's indeed not the case.
That 77% statistic has been quite consistent
and so it wasn't myself until sophomore year
that I finally got up the nerve to actually take the course
but I took it pass/fail.
I enrolled because I thought I'm on this track toward government
but I'm gonna finally get up the nerve
to actually dabble in this course.
And long story short, just the end
of that semester did I declare my concentration as CS,
that I end up, my god, doing this here today
for the same course I once took.
But that's not, to be clear, the goal in this course.
Most of the students, about oh just over half of the students
that take 50, it is for them a terminal course
in that they don't go on to take other courses
in computer science, but they parlay those skills
and the savvy they derive.
And of course like this, back into the social science,
the humanities, the physical sciences
where they have large data sets or large volumes of information
that they need to analyze or process.
Or even in the more familiar world of running student groups,
and you want to be able to send
out a mass mailing to 1,000 people.
My god, doing it manually isn't so fun using a tool
like Microsoft Word and Excel so you can do better than that
if you do it yourself and you have the savvy
with which to do so.
And that's ultimately too, some of the take-aways
of a course like this.
So a hello here to CS50 as to what to expect.
So in terms of expectations, they're fairly straightforward--
attending lectures and sections, submitting nine problem sets,
taking two quizzes, and a final project,
the images of which are conveyed by the fair and Hackathon alike.
In terms of grade, this is one that's particularly close
to my heart; I am not a fan in general of grades.
I think they tend to do more harm than good.
There is value in that they certainly help motivate,
but that of course can be to a crippling degree.
And so we've tried in recent years
to send the message quite ardently to do what I myself did
to put that toe in the water and to explore what for many
of you are indeed unfamiliar waters by taking it,
if you so choose, pass/fail.
You can do it letter grade or pass/fail.
We go so far as to provide you with these pink change
of grading status pass/fail forms at either end
of the lecture hall and I'm happy to sign study cards
for which you might like to do that.
Do ultimately consult the syllabus for some fine print
as to what courses can and cannot count
for concentration credit if you do take it pass/fail,
but undoubtedly if on the fence or a little bit nervous
about putting that toe in the water, taking a course
as I once did, pass/fail, and then having the opportunity
to change your mind up 'til the fifth Monday
of the term is a wonderful way of kind of getting past
that initial fear of failure, whether failure is an E or a B,
but to actually give you that comfort to try something new.
So toward that end of sending the message,
we actually have a tradition in the course of having cake
in just a few minutes.
We decided we'd print and emblazon on each cases,
on each cakes the message we'd like you to take.
We have one in chocolate, one in vanilla,
one with some vanilla and chocolate.
[laughter] Maybe don't eat the fourth cake,
but that one too will await you before long.
But what is the course ultimately about?
It's mostly about the hands-on aspects in lectures
where we present concepts and ideas and try as best I can,
to get you excited and in-
genuinely interested in some subject.
But undoubtedly the work and the experience
in this course derives from your working on the problem set.
But know that, so that's the appeal
to both those less comfortable and more comfortable alike,
most of the problem sets we issue in two different editions
so to speak; a standard edition that's targeted at 90%
of the students in the course,
and then typically a hacker edition
which ultimately covers the same sorts of material
but from a more sophisticated, a more challenging perspective.
Asks you to do a bit more in terms of sophistication
because those hacker editions assume more.
So realize too that though I might focus verbally
on this 77%, there is a non-trivial number of 12%
of the class that indeed have been programming
since they were, say, six years old, or just took one course
in AP computer science, or didn't even do that,
but just kind of feel that they're ready for something new.
So realize that there are these disparate tracks
within the course that appeal ideally to both.
Moreover does the course provide some number of late days
that you can spend during the semester.
Inevitably, life happens and you need to, for instance,
deal with some midterm or some other classes deadline,
so realize you'll have some flexibility whereby you can
spend late days on certain problem sets.
And moreover, there's also the circumstances
where life just really gets in the way
and just a week doesn't go so well
and so ultimately toward the end of the semester,
at the end of the semester will we drop your lowest score.
And again refer to the syllabus for any fine details.
And where can you go?
Well in this black box here CS50, and what's been exciting
for me having been here years ago studying the same subject is
that this chart, this flow chart whereby every arrow
from CS50 means what course you could take right after CS50
for which 50 is the only prerequisite, you can go off
in directions of more programming or theory or math
or graphics or networking or hardware or, with some bias,
iPhone programming this spring--
a new course that I myself will be teaching.
And so the only prereq for that too will be 50.
And so this is to, testament to just how much you can do
and that the marginal return of some knowledge and some savvy
in this world of computer science is indeed
quite empowering.
Now for those of you who might have shopped the course last
year or heard from some friends what's in the course,
we like to introduce every year as many new and exciting things
as possible and so for the first time this year will we be
transitioning away from what historically was a very server
side centralized architecture
where all CS50 students would run a program on their Mac
or PC, it doesn't matter what OS you use, you would connect
to some central server where software would await you there.
Well more fun these days now
that most everyone has particularly modern computers is
the ability for these computers, believe it or not,
to run not just Mac OS or Windows as you currently are,
but to run yet another operating system inside
of a window on your own computer.
And not this old school approach of like having
to reboot your computer and then it changes operating systems.
Double-click an icon and walla,
you're running an operating system called Linux
which is what we'll happen to use.
But it will look, the CS50 appliance in a window,
like just some other desktop.
You'll have a little CS50 menu instead of a start menu
in the bottom left-hand corner.
You'll be able to navigate
through the very user friendly type tools
that we'll introduce you to,
all of which can be found in the real world.
So nothing here is just simulated for the purposes
of academics in the course.
You will be equipped throughout the semester
with real-world sort of de facto standard tools that you'll use
in your own fields, whether computer science, humanities,
natural sciences, anytime you need a computer
to solve some problem.
We'll also, for those more familiar,
perhaps for those more comfortable, introduce you
to things like terminal windows and SSH
and we'll introduce you also to graphical editors with which
to write code and the odds are,
this looks completely cryptic right now, and indeed,
if you're among that 77%,
you might not have ever seen a program's source code,
the thing that the human writes
to make the computer do something.
This is one of the simplest programs a human might write
to just make the computer do something stupid,
like say hello world on the screen.
But this year too, for the first time, will we always introduce
for those familiar, what's called an IDE,
an integrated development environment,
so that if at term's end you actually do want
to be among those who goes off and interns at Microsoft
or Google or Facebook or in Wall Street,
to actually use some coding skills to apply them
to some real-world problems, know that this term more
so than ever, you will be very well equipped
with what's out there.
Another aspect that's changing this year
for the first time is office hours.
For 20 some odd years, office hours have gotten overwhelmed,
and this is back when the course was smaller
and when you would sign up for office hours,
one on one assistance with the TF's and CA's
by writing your name on a piece of paper that's tacked
to the wall in the science center.
Well, what we're going to do entirely is reboot these.
So if you've heard the reputation which was quite true
for some years, that office hours are slow and you end
up waiting some amount of time, we're hoping,
being computer scientists, that we can now fix this.
So one, we are going to exit what was once a very magical,
wonderful place to spend an evening, but move ourselves
from the basement of the science center
and it's fluorescent lights to four ho- to dining halls
on campus to coincide with brain break whereby this year's office
hours will be Mondays and Tuesdays and Wednesdays
and Thursdays, 9 p.m.
to midnight whereby we'll have not just half a dozen or so TF's
and CA's on duty at once, but 10 and 20 at a time.
And we've coordinated with the masters of Pfoho and Lowell
and Leverett so supplement brain break so that there's plenty
of food for you and the residents.
But, we can do better than that.
What we will also have done, thanks to one
of our TF's Tommy MacWilliam, over the summer,
is we've implemented our own version
of say the Apple Genius Bar tool.
For those of you who might own a Mac or have been
to an Apple store, you know that there's this bar of geniuses
that help you with your computer problems.
And so rather now than have students working
at these older work, computer terminals in the basement
of the science center, we'll all gather more socially if you
so choose to partake, with your laptops
in the dining halls working alongside your friends
who are not even taking computer science who are just there
for some food or to write some p set, but to raise your hand
when you need help on problem sets this year,
you'll instead not scribble your name on the board
but instead you'll log in to cs50.net.
You'll raise your hand by telling us what are you working
on and what's your question, and then you like Harry, Ron,
Hermione, Gilderoy and others here will appear
on the staff screen so that we know who now has questions,
and they're ranked in order of who raised their hand first,
but also they're color-coded.
And you'll find that this tool allows you to communicate
to others in the D hall what you're in fact working on.
And you'll see per the course's syllabus on academic honesty
which we'll discuss before long in weeks to come,
that you are allowed to collaborate
and to discuss problem sets with friends so long as the line
of here's my code, why don't you take a look
at it, is not crossed.
So more on that in the time to come but the hope here too is
to make the experience of taking computer science
and solving problems evermore sociable
so that you actually do learn from each other
and benefit in that way.
Now meanwhile, much like the Apple Genius Bar has a greeter,
so will we.
We, we know a little something about programming,
or at least Tommy does, and so we've bought ourselves an iPad
and so what you'll see at CS50 office hours this year is a
greeter, so to speak, who isn't gonna awkwardly say hello
to you upon entry at office hours,
but rather when you raise your hand virtually,
he or she on the CS50 staff will see that, oh,
Alice has a question and then Bob.
On the right-hand side of this same iPad app will the staff
member see that Professor McGonagall and Sprout
and Flitwick and Snape are currently on duty--
the TF's and CA's who are there waiting to help you one on one.
We will tap Alice on the left and Snape on the right.
Alice's computer screen, her own laptop will flash a message up,
will play a sound, and will communicate to Alice
that it's her time with Professor Snape.
So we thought we would completely overhaul office hours
toward an end of providing you
with the most support structure possible.
What about lectures?
Here we are today simply painting the trajectory
for the semester but joining us as well, albeit it virtually
with these cameras in the room,
are not only the Harvard extension students
who have been enrolled in the course for some time,
but for the first time this year will MBA students
at HBS be allowed to take CS50
as an [inaudible] course for credit.
So literally at this moment, we have,
well in 10 seconds the HBS students will see me waving my
hand because they're seated in a lecture hall
across the river taking now CS50 albeit from afar.
Similarly do we have students from Belmont High,
Watertown High, taking the course for the first time
so that they too can dive into a world
that their own schools might not necessarily offer
in the same form.
And similarly is this course available
as what's called open courseware
so that the entire world can indeed tune in,
use the CS50 appliance and learn at their own pace.
So what's in store for the next several weeks?
Well this week in particular we will introduce some
of the basics, the ideas of programming
and computer science itself.
We'll focus in particular
on a graphical language called scratch,
but more on that to come.
Next week will we dive into a language
which called C. It's the C language that I implemented
that silly little hello world program just a moment ago.
And even though it really might look like Greek to you now,
you very quickly-- trust me--
will acclimate to this environment.
And those common mistakes you'll make initially,
not quite typing the right commands,
will very quickly become old hat.
In week two will we transition to more domain specific topics,
not so much low level details
but how do we now use these skills
to solve real-world problems?
We'll talk about cryptography and encryption, the arn- the art
of scrambling information so that things like your name
and your social security number
and credit cards are all entirely secure.
The week after we'll talk more about algorithms
and these things called data structures.
I actually intentionally picked an algorithm
for counting students that doesn't require a huge amount
of sophistication, just requires a whole lot of brains,
a whole lot of CPU's to execute it once,
but it was still pretty simple.
But when you get to the point of implementing Facebook or Google
or any tool that's popular on your computer,
you need typically to muster more intelligent resources
for it and we'll introduce you with those particular tool sets.
In week four will we continue this conversation and talk
about things like memory management
and how computers actually do what we command them to do.
We'll talk in week five about another domain specific area:
forensics, the art of recovering
or making sure you cannot recover sensitive information
on your screen whether it is some financial information
or photos or documents or anything that you do
or do not want to be recovered.
In week seven will we introduce mo-
yet more sophisticated data structures
so that you're equipped to solve even more
sophisticated problems.
In week eight will we transition away from C
and to something more, let's say, modern.
Something more familiar that of the web world.
So by the end of the semester will you be able to make,
certainly your own websites, but not just with html and CSS,
the languages with which you just make static websites.
We'll talk about PHP and SQL and Javascript
so that you can actually make things more dynamic.
In week nine we'll continue that conversation as well
as in week 10, but it's really in the week's problem sets
that you will dive in.
In sections, will be this year, particularly more hands-on.
Sections are led by our team of some 40 teaching fellows
and there'll be any number of sections that won't start
until week three of the course, but more on that next week.
But realize they'll be a combination
of conceptual coverage as well as hands-on activities
with your own laptops.
But the p sets themselves are what make things
quite memorable.
On Friday will we look at this graphical language called
Scratch and you'll program for the very first time,
I bet quite intuitively, by dragging puzzle pieces,
little graphics that interlock only if it makes sense
to do this and then that.
And you'll be able to make, in just two days, your own graphics
and games and interactive art in the context
of this particular CAT based world.
Next week will we, in problem set one last year did students
then transition to that language called C
and implement the basics of programming,
talking about things like loops and functions and jargon
that will very quickly become familiar.
But once we have just a couple weeks
under our belt can we start to play thi-
with things like cryptography.
In week, problem set two last year did students have
to write their own cipher, an algorithm that encrypted
and decrypted information
so that you might indeed send a secret message
to someone across the room.
In problem set three last year did students implement the game
of 15, this otherwise silly party favor
that you might've gotten where you move those numbers up, down,
left, right within the context of a computer.
And in that week in particular
for our more comfortable students,
the hacker edition challenges you not to implement this
in such a way that a human can play,
but rather to implement the computer to play itself
and solve this problem no matter what the arrangement
of the board is initially.
In problem set four last year did students implement Sudoku
using a graphics library with which you could get colors
and lines and more interesting user interfaces.
In problem set five last year did I stroll across campus
and taking photos of people and places and things
and like a doofus I accidentally formatted my digital camera's
compact flash card.
But never fear, I made a forensic image
of my camera whereby we then gave every one
of those 494 students a file inside of which were all
of the bits, all of the 0's and 1's that composed the jpegs
that I had taken of things on campus.
We handed it out and they wrote software with which
to recover those photos.
And for brownie points, once they had recovered those photos,
they then went and recovered the people who'd been photographed
and we challenged students with a fabulous prize
that if you photographed yourself with each
of the faculty members who happen to be
in the otherwise deleted photos you would win some
fabulous prize.
So we had a couple of sections competing
for that prize in the end.
In problem set six last year we implemented a spell checker,
but a spell checker that was actually a bit competitive
whereby if you wanted, on an opt
in basis you could challenge the so-called CS50 big board,
and run your code in such a way that we ran it
through a whole bunch of tests and then reported
on the course's home page how much memory you were using
and how many seconds your program took to load
in 150,000 English words,
to spell check the King James bible,
the Austin Powers movie script, and a whole bunch
of other sample inputs and what was fascinating
about that particular p set that year is that because
of this optional competitive aspect,
we never had people working so hard.
Because folks would go to dinner, they'd be number two
on the big board or thereabouts, they'd come back
and their roommate had been toiling away
and now they'd been bumped down to place 10.
And so the sort of social aspect there enabled people,
sort of incentivized people to go back to the drawing board
to outdo their roommates.
In problem set seven last year did we have students implement
CS50 finance, their own version of like an E Trade
like website that's integrated
with nearly real-time stock quote data with Yahoo Finance
so that you could buy and sell stocks
and get nearly real-time stock quotes with your very own tool.
Now we also ran a simulated stock competition
where we gave all 500 students 10,000 virtual dollars
to play with.
I did not implement that big board all that well since m-
a couple of our students, who are now on staff, crafted out of
that 10,000 virtual dollars,
I think 20 billion a week or two later.
So there were some holes in the system.
In particular when you use something like Yahoo Finance,
which you're not paying for,
when I say nearly real-time I mean there's
like a five or a 15 minute delay.
Problem with that of course is that you can see the future
by just watching TV seeing what the stock price is
and you still have 15 minutes
to buy the stock that's about to go up.
[laughter] So there are some real-world issues
in at least our simulation there of fun.
And in problem set eight last year did we challenge students
to implement CS50 shuttle which integrated a website
that students wrote with a plug-in
by Google called Google Earth which allowed them
to implement their own shuttle service whereby you could take,
open a web browser here, you could then go to your keyboard
and start driving around campus like this, the goal being
to pick up the TF's and CA's whose heads are looming large
here in the distance, put them in your shuttle
and then bring them back to their particular house.
So there's the Inn at Harvard.
Let's see if we can make our way to the quad here.
All right [inaudible].
Take a l- right here, and a left here,
shortcut through the grass [laughter].
All right we're on Garden Street now.
Registrar.
And here we are, little shortcut to Pfoho [laugher] okay.
And there we are at Pforzheimer's House.
And so that was a tool that our own students implemented last
year for the climax of those, that year's problem sets.
So what resources exist to empower you yourself
to make sure you s- can succeed?
Know too, in addition to sections
and lectures there are these things called walk-throughs,
these optional sessions once a week that walk you through how
to get started on a problem set so that
when you read these PDF's and stare at the screen and you have
that very common question with any homework,
my god where do I begin?
Well these walk-throughs that are videotaped and led
by the staff will walk you
through the process of getting started.
And in terms of the community that Matt hinted at before,
know that very shortly you will have swipe access
to the CS50 lounge which looks a little something like this
and has such amenities as a Wii, and an Xbox and PS3,
some foosball tables there, a candy machine
and for those familiar, a cat in the ceiling.
So [laughter] know too that the course's website will become
your window into the course and rather than just put videos
of lectures up there on the screen we
like to do something a little different and transcribe all
of the words that might come out of my mouth
so that you can search these lectures and jump
around by clicking the transcripts
that appear there on CS50 TV.
But it's these images that you should keep in mind.
Of the CS50 fair and the CS50 Hackathon, the course culminates
in this final project that is entirely your own to devise,
and when you implement your final project it will then be
on display to-- last year, some 2,000 students and faculty
and staff across campus.
And these are the kinds
of images you saw just a moment ago.
This was the CS50 Hackathon which toward semester's end
and about a week before the final project is due,
we as a class will be invited to drive down in the CS50 shuttle,
literally, to Microsoft's campus at NERD.
N-E-R-D which is a brilliant acronym for New England Research
and Development and spend on evening from 8 p.m. until 7 a.m.
in a space that looks a little something like this.
Take away today that 77% of the people
around you have no prior experience
and you too can accomplish the sorts of things that you've seen
on display here so that your faces too will look a little
something like this over the next several months.
But for now, cake awaits you outside.
This is CS50 and we'll see you on Friday.
[ Applause ]