you
[Music]
alright this is cs50 and just eight
weeks ago two-thirds of you had never
studied any computer science before and
what we thought we'd begin with today is
really a look back of truly how far
you've come over just those several
weeks in fact it was just eight weeks
ago when you first started tinkering
with scratch this graphical programming
language by which you could drag and
drop puzzle pieces and making the
computer do what you want and then a
week later you might have struggled with
just getting Mario to ascend the pyramid
by way of hashes that you were printing
with at the time was perhaps quite
non-obvious but it's ever since has just
been what a pair of nested for-loops and
then the week after that you explored
cryptography among other fields and you
learned how to encrypt and you decrypted
information like this snippet here after
that you explored some electoral
processes and the implementation of
algorithms that you might be familiar
with from the real world but perhaps
didn't think about the trade-offs and
choosing one algorithm or another and
then ultimately implementing it in code
just a week later did we transition to
filters how instagram implementing
things like your own sepia filter so
then moving forward hopefully you won't
take for granted when you click that
button on the screen on your phone you
actually know or can presume or infer
what's going on underneath the hood as
it changes from one setting to another
and then of course big board where we
handed you some 140 thousand English
words in a really large file and you had
to implement your own spellcheck or a
dictionary so to speak with using as few
and was using as little amount of time
in as little space as you could
implementing ultimately your own hash
table thankfully since then we can now
take for granted that those things exist
but you indeed built that from scratch
just a week later we started handing you
large files like this and of all things
you were able to deduce by writing some
Python code that this is lavenders DNA
among others in the class of whose files
we handed you and then most recently or
perhaps quite soon when you learn to
apply another language in this case
sequel to questions like who has starred
in films with Kevin Bacon and so a
number of tools are now in your toolkit
and again I would just emphasize that
eight weeks ago two-thirds of you had
never done any of that before so even if
it's felt like it has never let up and
each week feels all the more challenging
than last consider the Delta and
consider what we promised in the first
week of the class that what ultimately
matters in this course is
so much where you up relative to your
classmates but where you end up relative
to yourself when you began and it is
indeed those eight weeks ago that you
began and it's today and then the course
is final weeks that you will ultimately
be able to compare yourself so in trying
to think today about what we hope your
own takeaways are from not only the
course but computer science more
generally I actually pulled up some of
my own notes you might recall from week
0 that I mentioned I took this course
myself back in 1996 and it would happen
to be the one that turned me from a
government major to a computer science
major and I didn't take many notes at
first it seems in that first class that
there were a couple of other pages and
so I started flipping through these and
in fact this was my second page of notes
and if you focus what's on what's up
here at the top apparently one of my
first notes to myself that a function
for those unfamiliar today are
instructions that do the work and indeed
if I you look down further on my notes
arguments we introduced that same first
day its info that's passed from one
function to another to have something
done by or performed on it all right so
that actually Maps wonderfully cleanly
to what it is we indeed started
ourselves doing those eight weeks ago
just talking about what CS is problem
solving in a problem it's just something
that's got input and the goal of course
is to produce something with output and
we had to agree from that very first
week how we're gonna represent these
inputs and outputs and so we might do it
symbolically with letters of the
alphabet we know since then with that we
might new do it numerically as with
decimal digits or under below that we
might just use binary a different based
system using only zeros and ones or we
could even represent that same capital a
just using some pattern of light bulbs
or switches that you turn on in some
order in fact if you think back then to
these first principles that we
introduced those weeks ago to many of
the students now in the audience what
does this say hi so it indeed says hi
why is that what we just agreed weeks
ago on what numbers map to what letters
and so long as all of the humans in the
world agree on that where they're
sending emails or text messages or the
like our computer systems can all
present information that we ultimately
understand another review question from
week zero what did this say way back
when if you need a hint it was it was in
decimal 128 thousand five hundred
fourteen
a little letter emoji this was the face
with tears of joy right taking all of
the fun out of sending emojis anytime
you receive or send an emoji really all
you're sending is a pattern of zeros and
ones or worse the number 120 8514 but
your computer or phone are presenting it
to you in a certain way based on that
context all based on just how we humans
are those before us decided how to
represent this information but of course
we don't have just those inputs and
outputs there are so another piece to
the puzzle and so I actually look back
at my own third page of notes here and
focused on my first line here back in
1996 an algorithm is apparently a
precise sequence of steps for getting
something done and programming more
generally is a process of taking an
algorithm and putting it into a language
a computer can process and indeed that
really was the additional puzzle piece
we first focused on in week 0 it was
what was inside the proverbial black box
the sort of secret sauce that you
provide your input to you get your
output from those are the algorithms
that we've been talking about ever since
now not just in pseudocode or in English
but in CNN Python and now sequel and
then in the coming weeks a few other
languages as well but of course we used
algorithms to solve problems and one
problem is reason was rather old-school
and we thought we'd reflect just a bit
and perhaps reinforce that same week
zero if by taking a couple of volunteers
perhaps a student and one of their
family members voluntarily or forcibly
with them you have to be comfortable
though appearing on stage and in turn
the Internet in perpetuity is the cat I
see ok I see a one volunteer and either
mom or dad fighting out who's not going
to go up ok
come on up a round of applause if we
could for our volunteers come on over
this way and what is your name Daniella
nice to meet you
come on over here and what is your name
Mariano and your dad I presume yes all
right well so nice to see you both um
you'll recall from week zero that one of
the first problems we solved was looking
up someone in a phone book well here I
have a pretty thick yellow pages wherein
there's a whole bunch of products and
services alphabetized from A to Z and we
can of course look up the number for
someone in this
book for instance suppose today we need
a plumber could we ask Mariano to find
us a plumber in this phone book flipping
through a few pages a lot of pages yeah
okay all right and we have a page full
of plumbers and now could your dad have
done better do you think could you I
think so so would you like to show dad
and other parents here what you might
have done instead I oh my goodness okay
thank you
and for those wondering let's continue
the algorithm if you will what's your
next step
nice and why are you doing this though
well Neetu is a little strong but you
can get rid yes indeed so if you keep
this process going halving and halving
and halving what should you be left with
ultimately just the letter P so a round
of applause if we could for both of our
volunteers here thank you
cs50 stretch ball for you both thank you
so much oh thank you Thanks so that was
one of the first lessons with which you
began focusing on algorithms in the
point back then recall was to really
emphasize the familiar right we might
not use that particular technology all
that much anymore but it really is
fundamentally the same thing that's now
in our iPhones and Android devices and
the life it just so happens that we
search for things by rolling with our
finger up and down but consider to even
these days in 2019 when you type into
the autocomplete to search for someone
by first name or last name how is your
phone finding that information it's
exactly like that now I'm quite as
physically as that but most likely for
efficiency your phone is looking roughly
in the middle of all of those names then
jumping up or down in the blink of an
eye in order to find that person for you
ever so quickly and so all of us might
have an intuitive understanding is just
like Mariano did for finding plumbers by
jumping to the P section but then you
came close to the P section but then
started flipping and I daresay you you
flip through far more pages than you
ultimately needed to using our more
efficient divide and conquer
if one-time-only al
instead so beyond algorithms recall I
recalled that I had just a few other
notes my last page of notes I also had
this here that what was apparently
important then and no less so now is
that in computer science and in turn
programming precision is important and
correctness is important and indeed one
of the things you perhaps gleaned in
programming whether in scratch or C or
Python or sequel over the past few weeks
is that the computers are really
unforgiving right they can't just infer
like we humans do and frankly I'm not
sure we would want our computers to just
infer sometimes what we mean if the goal
is precision and correctness you need to
be ever so precise so let's see perhaps
with one more demonstration just how
much this one has personal perhaps sunk
in if we could get perhaps two more
volunteers a students and family member
as well student and family member here
and I don't see a family members hand up
can you convince one okay come on up
wonderful a round of applause for our
other pair of volunteers here so now for
this one not everyone's off the hook if
all the students in the room if they
have a piece of paper and or pen or
pencil could take that out and share
with anyone next to you if you don't
have Emma and Brian are also going to
pass out some paper and pens if you
don't have a writing apparatus the goal
at hand is actually for all of us to
participate thanks to our two volunteers
and what's your name David David nice to
see you you too five nice to see you as
well come on over in here and this will
be a two-part exercise as well and the
first goal at hand is for you to choose
do you want to go first or a dad is it
would you like your dad to go first
you're gonna go first all right so come
on over here and what I'm going to show
David in just a moment is an image on
the screen that I'm going to ask that he
programmed you the audience to draw
giving verbal instructions only the goal
of which is for him to be as precise as
possible and as correct as possible to
compel the audience much like a computer
to follow his instructions and in turn
implement your algorithm so in just a
moment David is going to rattle off
step-by-step instructions
for having everyone in the audience draw
this you are the only one that can see
what's on the screen everyone in the
audience just about has a piece of paper
and a pen or pencil and I just need you
very confidently a clearly to recite
step by step instructions by which
everyone with their pen or pencil can
draw what you see on the screen here
makes sense yes you may use any verbal
instructions you like okay all right
just about ready to begin and the goal
precision correctness begin okay step
one draw a sideways square sideways off
45 degrees rotated yeah okay
from each the bottom three corners draw
a straight line down that's
approximately the length of each side of
the square
unfortunately programs cannot ask
questions a programmer or so we continue
on with next step and finally at the
between the first and second line draw a
line connecting the two at the end and
between the second and third line draw a
line connecting that end all right how
do you feel about your instructions
precise and correct wishy-washy okay all
right so let's go ahead hang on to the
mic for just a moment I'm gonna hop down
into the audience with our tips just to
grab a few representative solutions if
you wouldn't mind my grabbing a few
sheets of paper from folks who have
participated let me take a few over here
just a random sample
welcome to volunteer proactively or keep
it to yourself let me go in over here
okay thank you so much any takers over
here okay all right good good good
whoops thank you and all right the tips
are grabbing a couple - OH
see some over here all right that should
do
that's that should do let me grab these
from Brian over here and Emma oh those
are blank all right so I think we have
plenty over here so let's take a look
before we do part two of two if I may at
how well David programs the audience I'm
going to go ahead in just a moment
pull up a projection of some of these
drawings here that are the results of
these operations so let me flip through
get a sample here and I see a lot a lot
of good options here I see this picture
here which may look and I'm the only one
they can see you might see this picture
here which perhaps resembles what you
drew see this one here the top corner
very similar in spirit this one left a
lot of room for other things but this
one was a little more abstract if I may
and so let me go over to a spoiler to
show you what it is David was
programming you to draw and with some
suspense
he was compelling you to draw we hope
this here alright so close or not close
perhaps all right a round of applause
for David if we could thank you one law
and so you gave pretty you used if you
would abstractions right in discussing
this you said a side where a square used
45 degree angles hoping that folks would
presumably know what you mean by that
why did you not just say draw a cube for
instance okay well it would not have
been cheating but it would have been a
wonderful abstraction right if everyone
in the room assuming knows when in a
cube is you might then be compelled to
draw it quite quickly but that too
leaves ambiguity and lacks precision
well how is the cube oriented is it this
way is it that way is it curb this way
so sometimes these abstractions aren't
sufficiently helpful so I probably would
have done what you did as well now let's
do one other example here if we could
I'm going to go ahead in just a moment
and project an image onto the screen
that everyone in the audience can see
except you to let me go ahead and reang
--gel this a little bit and if father
and son would like to kid together or
solo draw a picture that the audience is
going to tell you how to draw so we're
gonna flip the rolls now you all will
see the drawing on the screen we ask
that you tell our volunteers what to
draw you can use any words that you want
but you cannot ask questions and no
physical gestures to explain alright
unfortunately it's a little hard
technologically here and that the
solution is going to be there the
solution is going to be there
so we're gonna have to kind of put some
visors on you if we could so that you
can only see straight forward and if you
don't mind
hugging the board as much as close as
possible but occasionally back up so
that people can see what you're drawing
but resist the temptation to look up
over left or right alright so for our
audience then the image is and if you
two could focus only on the board now
only on the board and definitely not
facing that screen okay
the audience is about to see the picture
in question and so we need a volunteer
first from the audience to call out an
instruction any step ones over here make
a circle - I heard draw a smaller circle
I didn't hear use the eraser but okay
okay okay and no looking at me no
looking at me all right so I'll take a
third step so let's go to someone else
yeah
draw a vertical line from the center of
the circle from the bottom of the circle
and down I hear an abstraction so we
were also given a fourth instruction
draw a stick figure that appears to be
walking if that helps but I think we're
gonna need to be more precise here
because I could imagine a stick figure
doing multiple things in multiple
with okay maybe Step five do we want to
make any tweaks it's drawn almost upside
down triangle I heard through the legs
for the legs okay
I heard erase the legs and get rid of
the arms okay and step five was from the
bottom of the body draw like a triangle
to represent the legs but but not that
way that's good let's move on to step 6
step 6 someone over here
from the bottom of the straight line
draw an upside down v I think we did
that can you step aside just so the
audience can see no we have a tripod
okay okay
okay so I think we're there I think
we're there one other instruction let's
see if we can take this home yes right
here draw a less than symbol from the
base of the middle of the end of the
circle on the left side less than symbol
yep
yes this is what we call a condition so
yes correct I hear okay I think we're
close two more steps maybe okay from the
top left of the head draw the words high
capital H lowercase I with I think did
you say aligned to it with the line to
it oh okay
and can you step aside just so the
audience can see I think we need just
one more step one more step okay back
here from the bottom of the circle on
the right hand side
touching the base of the circle in the
vertical line going down make the letter
L I'll I heard at a 15 degree angle sure
okay I think I think could we have you
take several steps back and look up and
a round of applause for our volunteers
that's pretty good thank you both so
much
please keep the Hat Congrats
so clearly abstractions can be useful
but they can also be challenging right
like programming is hard and even though
this one a bit off the rails here and
there verbally this really is just
programming and we're all trying to
agree on a common language or a common
syntax to use to have the computer or in
this case our human volunteers execute
those instructions and sometimes these
abstractions are great right draw a
stick figure who appears to be walking I
think we can all visualize what that is
unfortunately we're all probably
visualizing slightly different stick
figures and that's again where precision
comes into play and correctness too of
course sometimes with the the the chalk
went off in the wrong direction so we
might have to undo and of course we've
spent also the past eight weeks
debugging code as well and so I wish I
could say that this gets easier it
orjust gets absolutely easy but it never
does because the problems you'll aspire
to solve whether it's in the real world
or in the world of computer science and
programming are going to be
ever-changing and your aspirations are
going to increase and so this
frustration you might feel now never
really goes away if I can say as much
some 20 plus years after doing this
myself but the problems you're solving
with those same challenges and those
same hurdles get so much more powerful
so much more interesting and again it
all started from just a few weeks ago
when Mario's pyramid was perhaps the
first problem to solve well if we go
back to where we left off here we had of
course a few whoops if we go back to
where we were here we had of course our
drawings and then ultimately this
process this I daresay is computer
science you have inputs you have outputs
and algorithms in between but really
what are we talking about at the end of
the day well the creation of the output
of the management of information I mean
that really is what we've been talking
about for these past eight weeks is
information how do you process it how do
you represent it how do you transform it
into something more and ultimately solve
problems with it but with this
manipulation of this creation of this
storage of information ever more so
these days comes increasing
responsibility and I dare say one of the
things that we encourage you as you exit
a course like this it's not just what
you can do but frankly whether you
should do it and indeed all the more
relevant today in societies of course
stories horrifying stories of where our
data has ended up or what has happened
to our data or good intentions perhaps
gone awry because we haven't considered
implications and what we wanted to do
today is to point out a few examples of
opportunities to think harder about what
it is you do in the real world is just a
citizen and what you do in the on the
keyboard as a programmer and how you
might solve problems with one's privacy
and the security of one's data in mind
consider for instance passwords these of
course are perhaps the most familiar
thing that you and I use probably every
day to secure our accounts and in turn
maintain the privacy of our information
whether it's our photographs or
financial documents or emails or text
messages or the like unfortunately
passwords really aren't the best
mechanism and most of us in this room
probably should be more thoughtful when
it comes to making these kinds of
decisions as well for instance in 2019
already based on a very large data
breach and in the analysis thereof it
turns out that the top 10 passwords in
the world as of this year are number one
one two three four five six
apparently the result of some website or
applications requiring a password of at
least 6 characters and this is about the
least amount of effort you could do to
satisfy that goal number two password
was one two three four five six seven
eight nine slightly better slightly more
secure in insofar as it's longer number
three is QWERTY and if you don't know
what that means that actually describes
the type of keyboard but because if you
go to the top left-hand corner of your
keyboard and type one two three four
five six from left to right you will end
up spelling too wer T Y easy to remember
also pretty easy for other people to
remember as well a password is the
number four password out there and
number five is as if this year
six-one so another way of satisfying the
constraints that these people did but
with even less effort just hitting the
same key again and again and again one
two three four five six seven eight so
slightly behind the other two abc123
starting to get a little more
interesting that we're combining letters
and numbers one two three four five six
seven slips in there as well
number nine is password one clearly
satisfying websites that require that
you not use an English word but you
include at least one symbol or letter
here to daresay the bare minimum and
number ten as of this year is one two
three four five so it's easy to poke fun
at these and we won't call for a site a
show of hands but odds are some of us in
this room maybe don't make eye contact
have at least one of these passwords as
your own it's just all too easy then to
guess certainly these but even if you're
you're sort of practicing doing a
hearing to better practices than these
and you're not as simplistic as I'm
gonna pick an easy word or a very simple
number suppose you're actually being
more thoughtful doesn't really matter
these days right I'm gonna go ahead and
turn my attention to just a moment to a
text editing program here on my computer
the students in the room will recognize
this is just representative of a
programming environment and today this
has happens to be something called
Visual Studio code or vs code that you
can download on your own Mac or PC and
I'm gonna go ahead and just save a file
called pin PI right many of us have not
only passwords but pins personal
identification numbers that you're
supposed to keep secret and that are
usually say six digits long well even if
you've protected your financial account
or some other account with the six digit
code you know I might take a human quite
a while to guess all of the possible
codes that you might have chosen but
it's not terribly hard for a computer in
fact we'll do it even more simply like a
lot of ATMs with a four digit code I can
simply go in a program like this if I
know a bit of programming in Python and
I can say from time import sleep I can
say something like for I in range well
let's start from zero zero zero zero and
go all the way up to 9999 a four-digit
number but it turns out we need to
iterate up to 10,000 because those
students in the room will recall that we
iterate up to but not through that value
and then in here I'm going to go ahead
and say something like I am
checking this value I so this is to say
I'm proposing to write a program in
Python that will try to crack someone's
pin to show how easy it is to generate
as a computer all of the possible pins
in the world that are four digits long
so and just to demonstrate this I'm
gonna do it a little slowly by sleeping
for like one tenth of a second between
each iteration so I've gone ahead and
saved my file I'm gonna go ahead down
here now and run Python of I'm gonna go
down here and run python of pin pi and
I'll go ahead and make my screen a
little taller here so we can see more
whoops uh doc thank you yeah thank thank
you new here okay so here we go we've
now written a program that granted is
not cracking anything but it is
demonstrating how easily and how quickly
we can generate numbers from zero on up
to 9999 it's not quite right right these
aren't four digit codes because they're
being treated as numbers but there's
actually syntax with which we can solve
this and if you've never seen this
before you can actually just say
something like this : o 4 and that's
just going to reformat my output as
being four digits and it's gonna pad it
with zeros instead so boom I've written
a program that generates all possible
four digit codes of course I've been
deliberately sleeping that is pausing
each time I'm printing something out a
hacker is not going to do that they are
gonna try to do this as quickly as
possible no need for sleep whatsoever so
let me just rerun this code getting rid
of those lines boom that's every
possible four-digit code that you might
have on your bank account or on some
email counter the like assuming the
system allows you to have a relatively
short number like that you know you
might think okay well what's better than
four digits five digits let's just
increase it but I think that adversary
is gonna be able to crack that pin as
well I'm not even over at the screen yet
and it's done already right it is not
hard once you know how to program not
only to use these systems for good but
in this case for some form of evil
now maybe you're off the hook because
you're not as simplistic as I claimed as
to use only for instance in alphabetical
or rather a numeric code maybe you're
using a word and not a word as simple as
password you know it's a more arcane
from English or perhaps some other
language you know that's who doesn't
really matter let me go ahead and copy
from our source 8 direct from our source
8 directory today which for the students
is available online that large
dictionary that we had from problem sets
5 where and you loaded all these words
into dictionary your own there was a
hundred and forty thousand some odd
words here I'm going to go ahead and
create another file though this one
called password dot PI and recall from
some of our building blocks over the
past few weeks how easy it is to
similarly manipulate words from a
dictionary let me go ahead and again
initially import sleep just that we can
see this happening I'm then gonna say
with open large in read mode and I'm
gonna call this as file and over here
I'm going to go ahead and say now for
word in I want to say file and we've not
perhaps seen this one but it turns out
there's a really easy Python function
where you can say file dot read lines
and it's just gonna slurp in all of the
hundred and forty thousand words from
the file and allow you to iterate over
them one at a time and if I want to go
ahead and print this out I'll use print
again as before and I'm gonna go ahead
and claim that I'm checking for instance
that word dot dot dot just as I claim to
be checking a pin now again I'm not
checking anything I'm just demonstrating
that I could be checking this fast as by
simply printing out these words instead
and I'm gonna go ahead and as before
sleep for a tenth of a second on each
iteration but I'm also in anticipation
I'm gonna call this function which some
students will recall is to strip off any
white space at the end of the line
recall that in large or big dictionary
there was a newline character at the end
of every word so this line of code will
we'll get rid of this here yeah question
number here what's the significance of
the different colors this is happening
automatically in my text editor the
program I'm using to write code each
type of word or blocks of words that I
type have a different semantic meaning
to the computer and so the computer is
highlighting them in that way to draw my
attention to different types of words
here for instance we have this
preposition from that does something
like load someone else's code time
though in sleep or names of things that
other humans have actually invented so
I'm gonna go ahead now and run this as
Python of pass or Python of
run this as Python of password PI and
we'll see as the students will recall
all of the words in that dictionary
starting with the a words than the B
words than the C words and so forth all
the way down through F now of course I'm
sleeping unnecessarily but if during
this demonstration you see your own
password fly by the screen it's not that
hard for an adversary to be writing code
like this and not just printing out the
possible passwords but trying to log
into your account again and again and
again until they gain access to the
system and in fact if we deliberately
speed this up let's not bother sleeping
we'll get rid of all of the sleep
related lines as before and now run this
code now I I'm not even over at the
board and it's already done a hundred
and forty thousand words which is to say
if you're choosing a password that's
just a word in the dictionary whether
it's English or some other language
you're not off the hook you're not being
so clever because anyone with a computer
can check all of those codes now you
might think well this is why someone had
abc123 that's not in the dictionary
that's not just numbers that's not just
letters but come on if you give me a few
more minutes I bet we could write a
program together that starts with
letters and ends with numbers or vice
versa we could try to concoct these
patterns and grant it it's gonna get a
little slower a little slower the more
complicated it gets
but again the adversary if the goal is
to get your money gets your data might
have all the time in the world to
actually wage that attack and so I would
consider moving forward exactly what the
implications are of putting your data in
one place or another and not thinking to
actually secure it because in the best
case someone knows aleem I ended up
getting in a worse case more than that
whether its financial or personal might
be compromised
well when what other forms this
information come that might be our might
hint at potential threats for us to well
you've all probably heard of cookies
when it comes to the web and indeed if
you pursue our web track in a couple of
weeks time will you dive in deeper to
what these things can do but cookies are
little pieces of information that web
sites plants on your Mac or PC or your
phone any time you visit the web site
now that might seem a little creepy at
first glance and it can be used for
creepy purposes advertising and other
such tracking applications among them
but this is actually a very useful
primitive and
computer science in web programming in
that if you have the ability to plant a
little file on someone's computer it's
kind of like the digital version of a
hand stamp you can remember that you've
seen them before and that's actually
useful because when you log in to Gmail
or whatever email account you have you
don't really want to be typing in your
username and password every time you
look at a new message right Gmail or
Google would be a little obnoxious if
they kept asking you wait a minute who
are you wait a minute who are you these
cookies are stored on your computer so
that unbeknownst to you it's sent from
you the browser to them the server to
just remind them perpetually who you are
because you've already logged in and we
can actually see this let me actually go
over to my browser and you too might be
in the habit of using Chrome just as I
am here and I can go in in Chrome go to
view developer and go to developer tools
and you can do this too at home on your
own Mac or PC um you can do this with
Firefox or edge or other browsers as
well and you'll see among the various
things that just popped up or not
terribly user-friendly this is really
the domain of indeed developers or
programmers but I've clicked on this
network tab here because on my own Mac
or PC if I visit some URL like wwq cool
calm and hit enter I can actually see
inside of Chrome all of the requests my
computer has just made over the internet
for me to google.com and I'm gonna go
ahead and click on the very first of
these here and this too is gonna look
pretty arcane for today's purposes but
it's only meant to reveal what it is
that's going on here
let me scroll down down down down down
and you'll see a few things here request
headers these are little pieces of
information that my Mac and in term
Chrome just sent to Google com simply
because I visited the website and then
if I scroll down here we'll see response
headers this is what's coming back from
google.com to my own Mac or PC and this
is the line that's interesting if you've
ever heard about a cookie all it means
when I say a server is planting some
information or a file on your computer
it's really just doing this the response
you're getting from google.com simply
says literally in English set - cookie :
and then some value and to be fair that
value is pretty arcane looking it looks
a little weird apparently is going to
expire in December so I can infer from
this that Google wants to be able to
remember me at least for a couple more
months to the end of the year and this
value here collectively would seem to be
like a sort of hand stamp they've put on
my computer so that if I now proceed to
do searches if I proceed to login to
Gmail use Google Calendar or the like
they know who I am or they know that
it's me again and again so what does
this mean this means that any website
you visit can certainly be tracking what
it is you're doing and where it is
you're going and because big companies
like Google have advertising networks as
part of their portfolio if a website
that's not Google com is something else
com or something even else calm and they
are using Google's advertising well long
story short these cookies unfortunately
are sent these digital hand stamps are
presented not just to those individual
websites but also to Google again and
again and again because they are the
middleman in this story the advertising
network that's using ads on all of these
different websites so here are very
fundamentally useful and compelling
computer science principle can be used
certainly for wonderfully useful
applications just remembering that I'm
logged in but also if you don't think
twice about it or if you want to make
money off of it can be used for these
other purposes as well now we won't go
down this rabbit hole today of well this
is largely advertising what has helped
to make the Internet become what it is
so there are trade-offs certainly here
but that too is have been thematic but
again I would encourage you as you
discover more and more of these
principles these things you can do
through code that you consider whether
indeed you should be doing so as well
well what else might you do to mitigate
this well some of you might be in the
habit of using at work or at home
incognito mode or private mode which
most browsers today support well what is
that actually doing well according to
Google it says chrome won't same the
following information your browsing
history cookies and site data
information entered in forms and so
forth well that means literally that
even if Google or Facebook or some other
website sends you a set cookie value
saying please store this Chrome in this
case it's just going to throw it away
it's gonna empty the cookie jar so to
speak once you close that incognito
window however your browser is still
sending to Google or Facebook or
whatever website you're visiting those
values again and again and again
you're not private within
at window per se your only private
within that window with respect to
everything else you have opened so for
instance if I go now here and go to view
developer and developer tools and I have
my network tab open again and I visit
something like HTTP colon slash slash
dub-dub-dub Google comm and hit enter
you'll see that Google is indeed still
planting a cookie this time I got two
cookies from Google on my computer and
those cookies will exist for as long as
I have this incognito window open so
Google might be able to infer who I am
or that I am the same person based on
these cookies but they know even more
than that if I scroll back down to where
we began to these request headers the
information my browser is sending to the
server you'll notice that among these
values is something like this this one
too looks a little arcane let me go
ahead and zoom in on it here but it's
called user agent it's formatted in the
same way user - agent : and then an
arcane string here but it looks like for
whatever reason my computer is telling
google without my even asking it - that
I'm using a Mac that I'm running Mac OS
ten point fourteen point six at the
moment and if I keep scrolling it's
gonna tell it further that this is a
specific version of Google Chrome and
this is just some of the information
that is leaked deliberately and often
for good purposes but these are the
kinds of traces we all leave when we're
using the Internet and we won't even go
down this rabbit hole - but all of our
computers have unique addresses you
might have heard of things called IP
addresses you can't just get rid of
those much like you can't just remove
your postal address and expect mail to
still arrive all of us have unique
addresses that are still being presented
to these servers and so through computer
science through courses like this and
through reading up on these kinds of
topics here and after realise that in
understanding these print primitives
these things like cookies and how they
are set can you at least then we hope
make a more informed decision as to
whether to use them in that way or not
or to visit websites in some way that
you know to be using them for some
purpose well what do we have besides
this tool to perhaps worry about in the
world I daresay snapchat is pretty
popular these days and of course with
snapchat there's this notion that they
popularized of being able to delete
photos after one second or 10 seconds or
the like and in fact you all recover may
recall from problem set
for you implemented recover in this
language called C and you recovered
photos that had been deleted so clearly
already deleted doesn't necessarily have
to mean deleted and that's certainly the
case even for third party services now
to be fair we can only guess how it is
snapchat works underneath the hood they
claim to be deleting your photos after
some number of seconds but let's
consider for a moment what that might
actually mean because it's our
information we're putting out there in
this case in pictorial form you've never
used snapchat when taking a photo you're
able to see a screen like this and allow
your message to expire either never or
infinitely many seconds from now or 1 to
10 seconds somewhere in between after
which the photo is deleted well what
does that mean in the context of last
week those of you with now background in
sequel my hope that what snapchat is
doing on their servers is executing a
query like this delete from snaps where
ID equals something and the question
mark represents the ID of the snap you
just sent the photograph that you just
took but maybe they're doing that we as
Outsiders as users have no way to audit
this we can only trust what they say
what if there instead just doing
something like this update snaps set
deleted equals true where ID equals
question mark where that again is the
identifier of your snap now what is this
representative of well in the world of
computer science there's this notion of
hard deletion and soft deletion hard
delete means truly just delete the data
like throw the bits away so that they
really shouldn't be recoverable soft
delete is generally implemented like
this where you literally change a 0 to a
1 a false to a true in your database to
just remember oh the user deleted this
but that doesn't mean we have to throw
the data away this might have value for
marketing purposes for analytical
purposes business purposes or the like
so for all intents and purposes it's
deleted because you the user can't get
it back and no one else can see it but
perhaps one or more employees at snap
can see that data and perhaps that's the
kind of data that's at risk of being
leaked out longer-term and we've not
even discussed things like backups which
to have upsides you don't want your data
to get lost but you also don't want your
data to get stuck on some backup in
perpetuity as well so the lesson here we
would propose is just consider all right
don't just trust what some tool or some
application or developer says something
does decide for yourself just how much
weight to give those claims and whether
or not this kind of risk
is worth taking photos that you might
regret or wish to unsend because there
really is no notion of unsend
onomatopoeia - one last one that we saw
just a couple of weeks ago photo the
ability to tag photos using artificial
intelligence or machine learning these
days are just simple pattern matching
right was incredibly easy in a few lines
of Python code to pick me out for
instance out of all of cs50 staff based
on relatively little information right
this is enhanced the closest thereof
this is kind of a fuzzy picture didn't
represented really just by two you know
so two eyes a nose and a mouth that
apparently resembles my particular face
this was really easy to do and I don't
have to tell you these days that if
you're on social media all of us have
probably been uploading or have had
upload on our behalf photographs of us
that are then tagged and we have for
better for worse been just telling the
world what we look like from all sorts
of angles and here too can the data
perhaps be misused
yes it's wonderfully useful when you
upload an album because your friends can
see oh that was a great night out we can
now reminisce about those memories but
someone else can be scraping all that
data as we have read about having
happened in the past and someone else
might use that data to find you in a
crowd where you don't want to be found
or governments could do this too based
on driver's licenses photos or the like
here too just because the software can
do something doesn't necessarily mean we
should do that well one last demo
involving code if we may I'm gonna go
ahead and pull up on my computer cs50
zone websites which rest assured does
not use this feature but I can add it to
it in real time
here are cs50 s website at the moment
and just as I can view developer tools
before to see the network tab I can also
do this to visit what's called a console
so long story short there is an ability
in browsers to run code in a language
called JavaScript it's another
programming language similar in spirit
to Python and the like but it's very
commonly used in browsers today and this
little prompt here the little caret
symbol means I can type anything I want
now there's multiple ways to add code to
a website and if you pursue Co safety's
web track you'll see a number of these
ways but for now I'm going to go ahead
and just do a simple example by running
code to suggest just how easy it is for
a website to
ask the same question that you're about
to see that question being of course you
might have visited a website and seen
something like this a little pop-up
somewhat innocuously maybe top left hand
corner of the screen you click it and
then voila
some food ordering website knows where
you are and so they can give you the
menus in the location or some map might
thus appear it's actually pretty easy
frightening ly easy to do this let me go
ahead and write a little bit of code
down here and I'll zoom in and then I'll
hit enter to execute it I'm gonna go
ahead and type navigator which is a
variable available to me in JavaScript
in a browser that lets me access
something called geolocation - geo
locate something means to locate
something geographically and there's a
function or method in there called get
current position get per current
position is going to get your users your
visitors current position in the world
and the syntax for this is a little
different from what we're used to uses
what's called a callback function but
more on those in some of cs50 s tracks
but inside of this function I'm gonna
have just one line document which is a
special variable that refers to the
webpage the document itself the body
thereof represents the big rectangular
region where the content of a web page
ends up and specifically there's
something called inner HTML which for
those with some background in web
programming is the language in which web
pages are implemented I'm going to go
ahead and change the inner HTML of this
web page cs50 s to say this you are here
and I'm going to concatenate on to that
using plus which means join two things
left and right the answer to this
question what is the users positions
coordinates in latitude then let me go
ahead and just add a comma just for
aesthetics and then let me go ahead and
say position coordinates dot longitude
close parentheses here semicolon so what
I've done is written code took me a few
seconds could have spent less time if I
weren't talking over it
I'm gonna now go ahead and hit enter and
cross my fingers as always when doing a
live demo Timothy that I see what I did
I should not have had this parenthesis
because I did not have one opening enter
okay
so I've clearly very quickly triggered
this prompt now most of us I daresay in
the real world when we just want to get
some work done
are probably in the habit of saying
allow more often than we might so I'm
fine allow because I don't want to be
pestered Wow so it would seem that cs50
sweb site suddenly knows that I am here
well where is here
apparently 42 point three comma negative
seventy one point oh that I can actually
go to Google Maps now Google calm and
just type this in you don't have to
search by city state you can search by
GPS coordinates and interestingly it
thinks it's not where I am yeah hmm oh I
know what's happening live demo
apparently Harvard has internet
connectivity through perhaps a company
down the road named Akamai which is not
actually where we are but I think I can
fix can I fix this
give me one mom Oh live demos give me a
moment to try this once more if I may
come on come on come on come on
it's still the same all right so we're
gonna simulate what I wanted to have
happen so we are at Memorial Hall on
Quincy Street so long story short
Harvard has a more involved network
connection than we do in like my office
when I last tested this here in the
building here and so what's happening is
it appears that our internet traffic is
coming from a building down the road
that it's not actually in however had
that demonstration worked as I intended
we would have seen a little something
like this
which of course using satellite mode I
can zoom in on here here here here and
while I'm not in the tower of Memorial
Hall at the moment this indeed this
Kurtz portion is exactly where we all
are sitting in Sanders theater which is
to say at least within several hundred
meters can any website on the internet
apparently know exactly where you are
because your browser is revealing that
kind of information and let me try just
once more to see if I can recover from
this once more come on come on yeah but
I don't want to lose my eye yeah it's
not alright we're gonna fix this in post
if I may all right so let's go ahead
let's go ahead and take a look at where
we can actually go from here so a few
thanks first to the staff because
suffice it to say there's a whole team
behind the scenes that all of many of
the students here will know among them
certainly the folks who greeted you
outside the team that runs the audio in
here and all of the videography that's
being done and of course um sorry all
right we're gonna rewind and do this
properly so where do we go from here
so we have all of these building blocks
underneath our belts now from week zero
on to rope a we have a number of
languages under our belts and for the
final weeks of the class is the goal
ultimately to take off the last of the
training wheels in fact the training
wheels we literally took off just a few
weeks ago are sitting over there now and
now is there an opportunity for you in
the weeks ahead as the students in the
room to decide on your follow on tracks
all toward an end of cs50 s final
project and among the tracks for
instance that are on the horizon for
your web programming this is taking
primitives like we just saw there you
in JavaScript HTML CSS plus some more
Python in sequel which you've seen over
the past couple of weeks to build
applications this particular track will
be led by cs50 zone Brian and among the
projects you'll tackle over the coming
weeks are something like this cs50
finance so to speak which is a web-based
application via which you can buy coding
quo and sell quote-unquote stocks using
real time data from an actual API
application programming interface to get
the latest prices for stock symbols in
the world so you in this track will
build this application complete with the
ability to log in to log out to buy
stock sell stocks all using virtual
dollars and using a sequel database
underneath the hood to keep track of
that information if you pursue the
mobile track instead applying your past
eight weeks of skills and concepts to a
domain familiar to you and the phone you
have in your own pocket can you explore
programming on iOS or iPhones with a
language called Swift or if you're an
Android user exploring that domain
instead using a language called Java in
this track you'll be led by cs50 Sol and
Tommy MacWilliam who will guide you to a
number of projects one of which
implementing your own pokedex a sort of
rolodex for Pokemon characters including
all of the native user interface
elements they come with both iOS and
Android you'll be able to explore an
Instagram like application reminiscent
of some of the filters that you did in
problem set 4 but this one will be act
interactive and on your own device or an
ax simulator much closer to the app
whether it's Instagram or snapchat that
you yourself are familiar with and then
lastly in this track will you implement
your own notetaking application the
ability to add and remove information to
keep track of to do's whether it's a
grocery list class schedule or something
else altogether
and then lastly do you have the choice
of CS with these games track using a
language called Lua this is a language
that facilitates implementing games and
many other applications as well in cs50
zone Colton Ogden will introduce you to
a couple of applications some of which
are our parents in the room might recall
this was one of the first games ever
implemented on a computer for instance
not to date people in the room but this
is a game called pong and it's
relatively simple mechanically you move
these white paddles up-down up-down on
the left and on the right and this
little ball back in my day was
represented with a pixel if you will
that ball is going to bounce back and
forth against those paddles so you have
to figure out exactly how to do the
reflections and how to implement that
interface and
as is consistent with cs50 s theme of
beginning with Mario you can end the
semester with Mario again implementing
your own version of Super Mario Brothers
which is representative of a
two-dimensional side-scrolling game so
to speak
implementing this on your own Mac or PC
using your own computer indeed for each
of these tracks do you no longer need to
use cs50 IDE and while you're welcome to
for at least the web track you can now
use tools that are freely available and
are the types of tools you'll use after
this course in the real world the goal
of the final few weeks of the class is
indeed this final project the goal of
which is to apply these lessons learn
now to a project of your own design in
the coming weeks will you propose and
then design and then implement your
final project inspire perhaps by any of
those tracks you'll be able for instance
in the web track to download Python the
language and then turn the interpreter
onto your own Mac or PC and use it you
can use a popular tool like I used
briefly today Visual Studio code which
is a free and open-source tool that's
gaining momentum in industry because
it's relatively accessible and has lots
of features many more than cs50 zone ide
xcode by contrast is what you'll use if
you're using a Mac in developing an iOS
project for your iPhone because of that
being the software that apple provides
for that or in the worlds of Google's
Android studio a free tool that you can
use to build those Android applications
as well but how are we going to get
there and how will we support you along
the let well along the way so there's
this tradition in cs50 for the past
decade of a cs50 hackathon this is an
event that will begin at 7 p.m.
sometime in December and will end at 7
a.m. the next night but unlike most for
instance all night affairs this one will
be entirely focused on building
something and creating something
alongside all of your classmates and all
of your staff including some of our
friends from Yale as well upon arrival
will all cs50 staff greet you at the top
of the stairs will you check in get
settled for the night and ultimately
spend those 12 hours working
theoretically on your final project
perhaps even putting the finishing
touches on it here one of the rooms from
across the river where the event is held
this I think is shortly after a bug was
fixed late at that night but along the
way rule would be missed several meal
times as well we're in the habit of
providing hundreds of burritos from
Felipe's around 9 p.m.
Domino's kindly brings
a few hundred pizzas around 1 a.m. and
then if you're still awake at 5:00 a.m.
well some harboured shuttles take us to
and our therapy dog who will also be in
attendance will take us down the road to
IHOP for pancakes at 5:00 a.m. if you
would like to join us there and after
that is the final the one final capstone
to which everyone in this room parents
and families as well are invited as our
all faculty and staff across campus is
the cs50 fair campus-wide exhibition of
all students final projects at which
you'll to which you'll bring your laptop
will have music and popcorn and candy
and friends and alumni from industry and
it really is meant to be this this
exhibition of and celebration of the
final projects you by that point a month
hence will have created it's in central
Harvard Square and the Smith Center and
will you be greeted by such visuals as
these our friends at Yale will be doing
the same in parallel and it's just an
opportunity to see what you and your
friends have done to invite them as well
to see what you've accomplished this
term and to ultimately share in the
kinds of projects that you will have
created with a few passers-by here as
well and here is where I wanted to thank
the staff not only those who helped run
the show in the room here but also a few
of the courses heads literally heads
this here is cs50 staff here in
Cambridge this past year all of our
Teaching Fellows course assistants
producers and the like
these are our team members at Yale where
the courses indeed held in parallel and
there's a few faces we wanted to call it
in particular Rodrigo our head Teaching
Fellow who sadly is graduating but has
been with the course for so many years
Emma who is currently our head CA and
will take over as head Teaching Fellow
this coming year and of course Brian
many of whom you know as the courses
preceptor who himself held both of those
roles over the past couple of years but
this is where we'll end just as we began
two-thirds of you eight weeks ago had
never taken CS before and when we
surveyed you as to your comfort levels
you might recall this breakdown that
over some forty nine percent of you
described yourselves as among those less
comfortable just with the idea of taking
shopping let alone staying in a course
like cs50 16% of you described
yourselves as more comfortable and 35%
described yourselves as somewhere in
between is you now embark on your final
projects of your own choice I can
officially the create that you are all
now more
furtive all this ven was just the
beginning of your journey toward the end
of these final projects thank you all -
for coming today and for joining us this
semester this was cs50
[Applause]
you