Internet Courses

>> [music playing] [music - rossini, "ranz desvaches" from william tell] >> [music - the english beat, "marchof the swivel heads"] >> [applause and cheering] >> david malan: so this is cs50. my name is david malan. and 73% of you have no prior experiencewith computer science, contrary to what you might think.

so today we thought we would chip awayat that lack of familiarity, but also give you a sense of, for those of youwith more comfort, which directions you can go this semester. >> so let's start with this. i really have no idea what's inside ofa computer, even though, like you, i use it every day. but it's some kind of box, and there'snot many inputs into it. minimally, there's, what? probably a power cord.

>> and indeed with this one ingredient,electricity, we seem to be capable of doing quite a bit these days. but at the end of the day, wehave to represent the things that we care about. we have to represent informationin some form. and you're probably at least vaguelyfamiliar with the idea by binary or bits somehow or other, computersreduced to zeros and ones. but can we embrace that and at leastput a bit of light to that? >> so i have these littledesk lamps here.

i have an electrical outlet here. and i'm going to propose that insideof my computer is at least one of these things, something capableof being switched on or off. in this case, it's indeed a desk lamp,but at the lower level, it's something called a transistor. >> but in our world, it's a desk lamp, soi'm going to go ahead and plug this into my electricity here. and i claim that using this simple,simple device, this simple switch, i can represent information.

for instance, right now, i amrepresenting nothing, right? i'm representing what i'll call 0 orfalse, the opposite of something actually being present. but if i simply turn this switch,now i've represented a 1. so using this very simple piece ofmemory, if you will, i can represent information. >> now unfortunately, my computercan't do all that much. it can only represent two valuesin the whole world-- 0 or 1.

but what's an obvious solution, now,if we want to expand our computer's memory and represent morethan just 0 and 1? >> well, let's grab another such bit. let's grab another switch, anothertransistor, however you'd like to think about it. let me go ahead and plug thisinto my computer as well. and i'm going to claim, now, that byusing a bit more electricity and turning more of these switches on andoff, i can represent more such >> so right now, this is 1.

if i want to now represent2, i could do this. but typically, convention, as we'lleventually see, will have me do this. so this is 0, this is 1. this would be 2. and not surprisingly, this would be 3. >> so in this way, still, canwe count up even further? if i get a third bit, a third switch,what's the highest number i can now count up to from 0? so 6 if i'm starting at 0, right?

because if i turn this light on andactually plug this third and final light into my electrical socket here,then i have the ability to represent any of two values here, two valueshere, two values here-- and so i can represent 2 times 2 times2, or eight possible values. and if i start accounting at 0, sothat's 0, 1, 2, 3, 4, 5, 6, 7. >> so this binary. it really is as simple as that. and i'd argue that this is actuallyquite familiar to most everyone in this room.

let me go ahead and open alittle text editor here. >> and you might recall from grade schoolthat we had things like the hundreds place, the tens place,and the ones place. and recall that if you had some decimalnumber, like something random like 123, you would essentiallywrite that out in the form of these three columns. and why is 1, 2, 3 whatwe know as 123? well, in the leftmost column, we haveone 100 plus two 10s, so that's 120, plus three 1s, so that's 123.

>> now this world that we just illuminatedis exactly the same as you've been familiar with for years,except now, our columns aren't powers of 10. they're just powers of 2. so whereas that's the ones place, thisis going to be the twos place, this is going to be the fours place. >> and because i am only using the simplestof mechanisms to turn things on and off-- electricity is flowingor electricity is not flowing-- i don't quite have the same expressiverange as 0 through nine.

we're going to keep it super simplein this world of computers. i only have 0 or 1-- off or on, false or true. >> and so what i'm representing right nowis 1, 1, 1, because each of these lights is illuminated. well, that gives me one 4 plus one 2, sothat's 6, plus one 1, and that's 7. and ergo does this sequence of threebits represent the number 7. >> so all this time, inside of yourcomputer, have been any number of transistors, any number of bits.

but at the end of the day, wecan represent information as simply as that. now unfortunately, we've only countedup to 7 in cs50 thus far, but hopefully we can do a bitbetter than that. and indeed we can. >> suppose that we as humans justarbitrarily decided that we are going to associate numbers like 1 and 2, 3,4, 5, 6, 7, with specific letters of the alphabet. and for historical reasons, i'm going tostart somewhat arbitrarily, but i'm

going to say, humans, we are going todecide as a standard, globally, that 65 represents the number the letter a.66 will represent b. dot, dot, dot. 90 will represent the letter z. >> and let's suppose, if we really put somethought into it, we could come up with numbers for exclamation pointsand lowercase letters, and indeed, other people have done that for us. so now we had bits with which we canrepresent numbers, numbers with which we can represent letters, and withletters can we now start composing emails and printing characterson the screen.

>> so let me invite, if i could,eight brave volunteers-- who don't mind appearing not onlyon camera but on the internet-- to come up here and represent eight suchbits, rather than these three. so how about one, two? how about three? how about four in lightblue, five on the end? about someone over here? six in front, seven in front,and eight in front, as well. >> so i just so happened to come preparedwith a whole bunch of slips of paper.

and on these pieces of paper are numbersthat represent what columns you guys are going to represent. so you will be-- what's your name? >> student: anna leah. >> david malan: anna leah, youwill be the 128s column. you are? >> student: chris. >> david malan: chris willbe the 64s column. >> student: dan.

>> david malan: dan willbe the 32s column. >> student: pramit. >> david malan: pramit willbe the 16s column. >> student: lillian. >> david malan: lillian will be the 8s. >> student: jill. >> david malan: jill willbe the 4s column. >> student: mary. >> david malan: mary will be the 2s, and?

>> student: david. >> david malan: david willbe the 1s column. so if you guys could step a littleforward so that everyone can see. what you guys don't see is that on theback of these slips of paper is a little cheat sheet that's about toinstruct these eight bits to either raise their hand or notraise their hand. if their hand goes up, they'rerepresenting a 1. if their hand stays down, they'rerepresenting a 0. >> meanwhile, we the audience should beable to figure out, based on this

mapping, what three-letter word thesefolks are about to spell out. so in just a moment, you're going toread the first line off the back of your cheat sheet, and you're eithergoing to raise or not raise your hand. if you're a 1, you raise, ifyou're a 0, you stand there awkwardly, just like that. go. what number, first and foremost,are these guys representing? >> 66. 66, right?

we have a 1 in the 64s column,a 1 in the 2s column. that gives me 66, so that appearsto be representing b. so you guys have spelled-- ok, that's enough. b. >> so now let's move ontoour second letter. who's quickest at math here? so 79. again, if we add up all of the columnsin which there's a 1, currently, just

like we did before with the simplestof examples of 7, we now get the number 79. which according to our mapping is theletter o. so we're almost there. b, o. and lastly, go. >> what are they representing now? less consensus. that's just an absolute murmur. yes, it's in fact 87. good.

>> so if we now map that back up to-- let'sstart calling our ascii chart, american standard code forinformation interchange. that gives us the letter-- not "bo" but "bow." and that's a perfectcue for you guys to take a bow and head on back. thank you very much. >> [applause] >> david malan: you can keep them. though actually, would anyonelike a desk lamp, also?

>> [hoot from audience] >> david malan: desk lamp? >> [laughter] >> david malan: really? desk lamps for everyone? all right. so starting with the very simplest ofprinciples, we've now not only counted up from 0 all the way up to 7, we'veassumed that just by throwing more bits or more lights or more transistorsat this problem, we can

represent bigger and bigger numbers, andergo, bigger and bigger ranges of alphabets, like english. and just let's take on faith for todaythat similarly could we start to represent graphics and video and anynumber of other media with which we're familiar today. >> so this is cs50, and in this classalongside of you are, again, very many classmates who have as littleexperience as you. and i mention this only because quiteoften, including as recently as one of the freshman advising events and atlast spring's sophomore advising

event, we often hear students disclaimwhen coming up to the cs table, well, i've been thinking about taking thisintro class, but i'm not really a computer person. or, but everyone surelyknows more than me. and i put this in the biggest fontpossible, to convey this message that that's not in fact the case. >> and if you're wondering, shouldi, in fact, be here? realize that not only is this course'stitle introduction to computer science, it is introduction to computerscience i. so there is indeed

a second such introduction. so you're not, in fact,in the wrong place. and among the goals i have for today areto assuage any such concerns you might have, but also to paint apicture of what's in store for students less and more comfortablealike in this course. >> but first, a word on one of the handoutsyou have today, among which are a number of faqs. it's been a vision of ours for some timenow to introduce a new grading option into this course--namely, sat/unsat.

philosophically for me, it is much much,much more important that the students in this class engage with thematerial, be challenged by the material, and worry far, far less aboutthe mechanics of actual scores and letter grades at semester'send, but truly embrace the course and its material. and really this feels, more generally,for what's interesting to them, to feel challenged and rewarded butwithout fear of failure. >> and indeed, this too is a recurringtheme in this and other introductory courses in other fields, that you havethis trepidation when it comes to

putting one's toes inunfamiliar waters. i myself, back in 1995,was a freshman. i was very much focused on beinga gov concentrator here. and yet i'd always grown up with a bitof an interest in computer science. i was always curious. >> but back then, even, i had this fear ofeven stepping foot in cs50, so much so that i didn't even shopit freshman year. and the only reason i put a foot in thedoor sophomore year was because i was allowed to take it pass/fail.

but even pass/fail required that i getup the nerve to make an appointment with professor kernehan at the time,bring this big sheet of paper, and ask him for his signature and hispermission to explore these unfamiliar waters. >> and it hasn't helped in recent yearsthat when doing this in cs50, when we used to be pass/fail, similarly woulddozens or hundreds of your classmates have to come up, god forbid, at thefront of sanders with this form, that in some minds represents an inability,i dare say, to perform are your peers' level.

which is ridiculous, but i do thinkthere's that mentality. and there's never been in this cultureof sat/unsat, or pass/fail more generally, in this course,or really on this campus. >> so this year we changed that. i would be ecstatic half ofthis class or more ended up taking cs50 sat/unsat. in a year's time, it would be wonderfulif almost everyone is. thereafter perhaps we'll workon letter grades at harvard college more generally.

but for now, we'll do this within ourown sphere, and i would heartily encourage you to review those faqs andask questions as you see fit, so that hopefully you, unlike me, won't quitehave that same fear factor when exploring what's probablyan unfamiliar place. >> so what is cs50? it is an introduction to theintellectual enterprises of computer science and the art of programming. but what does that really mean? >> well, thus far, we talked very brieflyabout representing information.

but suppose that we actually wantto do something with it. we need to introduce the notion ofwhat we'll call an algorithm. an algorithm is a procedure, a process,a set of instructions for doing something. >> and an algorithm can be somethingsuper simple. for instance, an example with which someof you might be familiar is this thing here. so this book here is increasinglydated, but once upon a time, it contained a whole lot of namesand phone numbers.

and indeed, if i wanted to findsomeone in this phone book-- say, someone named mike smith-- i could find mike smith in any numberof fairly straightforward ways. i could start at the beginning andmove on to page 1, not there. page 2, not there. page 3. is that algorithm, is thatprocess, correct? >> so it is correct, right? i'm kind of an idiot for doing it inthat manner, but eventually i will

find the surname s, and hopefully mikeis in that section, and i will become done with my algorithm. but surely it's not intuitive. most every reasonable human in thisroom would not have done that. what would you have done? >> you'd have gone straightto the middle, right? roughly to the middle. and you realize, oh, these are the mike smith, last name being smith, is not, clearly, then in theleft half of the book.

he must be toward thes's in the right. and at this point, though most of usdon't do this in reality, we can literally tear this problem in half. >> [cheering and applause] >> david malan: thank you. >> david malan: you can literally tear thisproblem in half, leaving me with, literally, a problem half as big. so if this phone book was-- and itprobably was-- about 1,000 pages, now it's only 500.

if i do this again and i realize, oh,damn, i went too far, i'm in the ts section, i can similarly-- figuratively or literally-- rip the phone book-- it was actuallymuch easier that time. i can literally rip the phone bookin half, leaving me now with not 1,000, not 500-- 250 pages. and i can go 125, and half of that, andhalf of that, and half of that, until finally i'll be left withjust one single page.

>> david malan: that's thepart i fail on. one single page on whichmike hopefully is. now those different algorithms can besort of assessed or evaluated in different ways. the first one was very linear, right? turn page, look for mike. it's very linear. if there's one more page in the phonebook, it's probably going to take me one more second, one more unit of time,however we're computing time.

>> so i might draw like this this linehere, whereby as the size of the problem increases from left to right-- phone book gets smaller to bigger-- and time is going to increase onthe vertical axis, the bigger the phone book is. so n is just a general variable thatcomputer scientists use to represent some value, some number. so n is going to increase linearly. double the size of the phone book, it'sgoing to take me twice as much

time, most likely, to find mike. >> now i could have been smartabout this, right? i was getting bored quickly. could have done this by twos. so two pages, then four,then six, then eight. and i could start flying through it alittle faster, albeit at minor risk of overshooting mike, but that curve isn'tgoing to be all that different. it's still going to be a straightline, but slightly faster. >> but what did i do?

i actually did somethingfundamentally better. i achieved what we'll call logarithmictime, log of n, whereby this green line has a much, much, muchless straight edge to it. and rather, it suggests, as it sort ofapproaches infinity ever so gradually, that i could actually take a 1,000-pagephone book, double its size next year-- because suppose a lotmore people move into town. >> so now i've got 2,000 pages, but howmany more steps is that smarter algorithm going to take? just one.

i mean, that's a powerful thing. if we go to 4,000 pages next year,that's going to take me only two more steps. so you can throw bigger and biggerproblems at me, not unlike the web is throwing bigger and bigger problemsevery day at googles and facebooks of the world, and it's notsuch a big deal. because i put more thought and care intomy algorithm with which to solve problems efficiently. >> and indeed, that will be one ofthe goals of this course.

you will, along the way,learn how to program. you'll learn how to program inany number of languages. but at the end of the day, the course isabout solving problems and getting better at solving problems-- and, as incases like this, solving problems more efficiently. >> now thus far, we've done thisfairly intuitively. let's introduce something fairlygeneric called pseudocode. so we'll eventually get,in this course, to various programming languages.

but today we'll do it in english-likesyntax, where you just kind of say what you mean, but you're ever sosuccinct and you don't worry about grammar and complete sentences. you just express yourself asconcisely as possible. >> so pseudocode is english-likesyntax that represents a programming language. and toward that end, let me propose thatwe now model the process we just described of counting something a littledifferently, this time taking a look at this five-minute video producedby our friends at ted that

defines what pseudocode is, defines whatalgorithmic thinking is, and even though the example you're about to seeis, in of itself, super simple, it's going to start to give us the mentalmodel, the vocabulary, with which to do much, much more complexalgorithms quite quickly. >> [begin video playback] >> narrator: what's an algorithm? in computer science, an algorithm is aset of instructions for solving some problem step by step. typically, algorithms are executedby computers, but we humans have

algorithms, as well. for instance, how would you goabout counting the number of people in a room? well, if you're like me, you'd probablypoint at each person, one at a time, and count up from 0. 1, 2, 3, 4, and so forth. >> well, that's an algorithm. in fact, let's try to express it abit more formally in pseudocode-- english-like syntax that resemblesa programming language.

let n equal 0. for each person in room, setn equal to n plus 1. >> how to interpret this pseudocode? well, line one declares, so to speak,a variable called n and initializes its value to 0. this just means that at the beginning ofour algorithm, the thing with which we're counting has a value of 0. after all, before we start counting,we haven't counted anything yet. calling this variable nis just a convention.

i could have called it most anything. >> now line two demarks the start of aloop, a sequence of steps that will repeat some number of times. so in our example, the step we're takingis counting people in the room. beneath line two is line three,which describes exactly how we'll go about counting. the indentation implies that it'sline three that will repeat. >> so what the pseudocode is saying isthat after starting at 0, for each person in the room, we'llincrease n by 1.

now is this algorithm correct? well, let's bang on it a bit. does it work if there aretwo people in the room? let's see. >> in line one, we initialize n to 0. for each of these two people,we then increment n by 1. so on the first trip through theloop, we update n from 0 to 1. on the second trip through that sameloop, we update n from 1 to 2. and so by this algorithm's end, n is 2,which indeed matches the number of

people in the room. >> so far, so good. how about a corner case, though? suppose there are 0 peoplein the room-- besides me, who's doing the counting. in line one, we initialize n to 0. this time, though, line three doesn'texecute at all since there isn't a person in the room. and so n remains 0, which matches thenumber of people in the room.

pretty simple, right? >> but counting people one at a timeis pretty inefficient, too, no? surely we can do better. why not count two people at a time? instead of counting 1, 2, 3, 4, 5, 6, 7,8, and so forth, why not count, 2, 4, 6, 8, and so on? it even sounds faster,and it surely is. >> let's express this optimizationin pseudocode. for each pair of people in room,set n equal to n plus 2.

pretty simple change, right? rather than count people oneat a time, we instead count them two at a time. this algorithm's thus twiceas fast as the last. >> but is it correct? for that one pair of people,we then increment n by two. and so by this algorithm's end, n is 2,which indeed matches the number of >> suppose next that there are0 people in the room. as before, line three doesn't executeat all, since there aren't any pairs

of people in the room. and so n remains 0, which indeedmatches the number of >> but what if there are threepeople in the room? how does this algorithm fare? for a pair of those people,we then increment n by 2. but then what? there isn't another full pair of peoplein the room, so line two no longer applies. and so by this algorithm's end, nis still 2, which isn't correct.

>> indeed, this algorithm's said to bebuggy, because it has a mistake. lets redress with some new pseudocode. let n equal 0 for each pairof people in room. set n equal to n plus 2. if one person remains unpaired,set n equal to n plus 1. to solve this particular problem, we'veintroduced, in line four, a condition, otherwise known as a branchthat only executes if there's one person that we could notpair with another. and so now, whether there's one or threeor any odd number of people in

the room, this algorithmwill now count them. >> can we do even better? well, we could count in 3s or 4s or even5s and 10s, but beyond that, it's going to get a little bitdifficult to point. at the end of the day, whether executedby computers or humans, algorithms are just a setof instructions with which to solve problems. these were just three. what problem would you solvewith an algorithm?

>> [end video playback] >> david malan: that is the only timei will appear in cartoon form. but where that story leaves off,now, is how can we do better? threes and fours, we claim, we can countpeople much faster, but can we do fundamentally better than that? and i wager we can. >> if we introduce a bit of our ownpseudocode here, i'm going to propose that we can achieve a line like this. we're not going to count peopleone, two, three, four.

we're not going to go two,four, six, eight. we're going to do fundamentally betterby rethinking the problem, and in this case, leveraging an otherwiseunderutilized resource. >> in just a moment, i hope you'll forgiveand humor us by standing up in place, at which point we're going toask each of you to take on in your minds the number 1. you're then going to increasinglyawkwardly, as time passes, find someone else who is standing, combineyour numbers together by adding them up.

one of you is then going to race to sitdown first, and the other person is going to repeat. >> so in other words, by seeding all ofyou with the number 1, and then combining those 1s into 2s and those 2sinto 4s, with everyone increasingly sitting down, we should, at the end ofthis algorithm, have just one loan soul who didn't sit down fast enough butwho has the entire audiences count in his or her mind. >> so if you would, let's go ahead and--step one-- stand up in place. and execute.

>> [crowd murmuring] >> david malan: do you knowwhere lauren is? 729? >> david malan: all right? >> david malan: all right, we shouldbe nearing the end. we see one fellow standing here still. who else needs to be paired? if you guys want to pair off. someone up top.

why don't i lend a hand here. for the very few people who are stillstanding, what numbers do you have in your mind? >> student: 78. >> david malan: 78 plus-- who's standing down here? >> student: 39. >> david malan: plus 39. plus who else is still standing?

81? ok, who else? another 81? wow. and then what's in back? >> student: 49. >> david malan: 49, plus? >> student: 98. >> david malan: 98 plus?

is that someone else? 12? good job. >> david malan: oh, 112-- oh. good job! >> david malan: anyone elsestill standing? sorry? >> student: 99.

>> david malan: 99. anyone else still standing? and the total number of students hereis actually, according to-- do you have a number? oh, the actual number of people in theroom, according to the account that the teaching fellows were doingon everyone's way in, was 729. so out of a roomful of harvard studentswho counted themselves, the answer is 637. >> david malan: so close.

but still. ok, so that's a teachingmoment, right? this now is what we describe as a bug. somewhere along the way, we did somearithmetic wrong, or someone sat down, or left, or something went wrong. but that's fine. because even still, wegot pretty close. and i'd argue that we got to the wronganswer a lot faster than i would have using my more linear approach.

>> so let's assume we did in fact get thatcorrect, but think now about what was happening each time, versus myown naive pointing algorithm. one, two, three. if there are indeed 729 or 637 peoplehere, that would have taken me literally 637 or 729 pointingsof the finger and incrementing my total count. and i could do a little better bygoing two, four, six, eight, and double that speed, maybe even triple orquadruple, depending how well i can do that counting in my head.

>> but this approach that you guys tookwas fundamentally different. because at the beginning,all of you stood up. so all 729. and then literally halfof you sat down. and after that, anotherhalf of you sat down. >> and the total number of times that youguys could have sat down is roughly eight or nine or ten total times,depending on what our total count is. and we can sort of dothis the other way. if we had 1,024 people in the room, thetotal number of times you could

halve 1,024 people is 10. >> now think about it inthe other direction. suppose, ridiculously, that we had, sayfour billion people in this room, or a slightly larger room. how many times would we have gonethrough this algorithm, such that half of that class sits down? it's only going to take 32 suchoperations, even in a class of size four billion. why?

because four billion goes to twobillion, goes to one million, goes to 500 million, goes to 250million, dot, dot, dot. i can only do that division some 32times, at which point, everyone except one person would be left standing. >> and that, too, is sort of a powerfulidea that increasingly we'll try to leverage in this course, and inprogramming and computer science more generally, these germs of an idea withwhich we can then solve problems much, much more powerfully. so we started quite simple with thatpseudocode and a guy in a room, but

now with a whole room full of peoplehave we done fundamentally better. >> well, let's now transition frompseudocode to some actual code. this language you're about to see happento be called javascript, and we'll return to this towardsemester's end. it's a programming language that youuse to make websites and other such software these days. and we have used it, thanks to a friendof ours at stanford, to encode some hidden information here. this is the art of steganography,so to speak, where you can hide

information in what otherwise appears tobe noise or a completely different image altogether. but embedded in this particular imageis indeed a secret message of sorts. >> so let me go ahead and pull upthe same image here, this time in a web browser. and i'm going to wave my hand at some ofthe details for today, particularly for those of you who this looks likenot only javascript but greek, as a completely unfamiliar language. but this is an example ofa programming language.

>> and for now, take on faith thatthis first line of code-- and by code, i just mean text. text that i could have literally typedinto microsoft word, if i had the right software to thendo something with it. programming source code, programmingcode, is really just text, and it looks different based on what languageyou're using, not unlike english and spanish and russian all look differentwhen you type them at your keyboard. >> so this first line, for now take onfaith, simply opens a graphic from the internet, that noisy graphicwe just saw.

this next line here is an example of aloop, and we actually saw that same jargon in the ted video. a loop is something that happens againand again, and even though this absolutely looks cryptic, with thekeyword for, and some parentheses, and some semicolons. we'll come back to that before long,but that loop there essentially is telling the program, iterate over allof those noisy dots, from left to right, top to bottom. >> because at the end of the day, an imagelike this-- and you can actually

kind of see it on this projector-- is really just a grid of dots. so we can identify each of those dotsby a coordinate, x, y, and with this program, now can we begin todo something to those dots. >> so what i'm going to go ahead here anddo is i'm going to make some changes. first i'm going to go ahead and get ridof all of that greenish and bluish noise, and i'm going to go aheadand type the following admittedly cryptic syntax. im for image.

set blue at location x, comma,location y, to 0. in other words, i want to justturn off all of the blue dots in that picture. >> i'm going to go ahead now and clickthis run/save button, and you'll notice on the right-hand side,the resulting image appears. now its super green, but that's notsurprising, because i literally turned off, by making a 1 a 0, all ofthe blue in that picture. >> well, now let's do it a bit more. im for image, dot setgreen, x, y.

and that just means iterate from leftto right and then top to bottom. turn that off with a valueof 0, as well. save. and on the projector, you can't actuallyreally see anything at all. >> on my laptop screen, if i peer in justthe right way, i can see a bit of an image, because they're stillsome red in there. if you've ever heard the acronym rgb-- red, green, blue-- it's referring to this compositionof an image using

just those three colors. and right now, we've thrown awayall green, all blue, but there's not much red. >> so let me crank up the red. how can i do that? well, first, i'm going to askthis program a question. i'm going to go ahead and let's call ita variable, just like in algebra. you can have x or y or z. i'm going to declare a variableand say, put in this variable,

temporarily, the value of theimages getred value at x, y. >> and again, we'll come back to allof this detail in the future. but for now, just take on faith thatthis line is asking the program, what is the red value at x, y? at that particular dot? >> then i'm going to do something to it. then i'm going to do image dot set redat x, y, y but this time i'm going to boost it by doing red times,let's say, 10. so increase it by a factor of 10.

let me zoom out now andclick could run/save. and voila, that was there the entiretime, even though our human eyes couldn't quite see it. >> so again, this now is real code, anexample of a language that we'll come back to before long. but realize, particularly those of youwith no such experience, it's quite soon that we ourselves will bewriting code like that there. in fact, a tool with which you're allsomewhat familiar, perhaps, is cs50's own course-shopping tool, which wasactually rebooted this summer by some

of cs50's own former students,now turn tfs. >> so this happens to be a website builtin a language called php. it uses a database called mysql, thingswith which we'll get our hands dirty later in the semester. but believe it or not, even somethinglike this ultimately reduces to the simplest of loops and conditions andbranches, like those we saw just a moment ago in the ted video. >> what i thought i'd do now is share notjust something we the staff have made for the campus, but rather somethinga former student-- three

students, in fact-- made this past year, sierra, daniel, andsam, the last of whom had no prior programing experiencewhen he took cs50. and for their final project, theyexhibited, at the cs50 fair, an application called wrdly, which is aweb-based program for which they made this video that i thought i'd share togive you a sense of just what is possible by term's end. >> david malan: that's from week zeroto week 12 this past year. >> david malan: as a teaser, too, reallyto whet your appetite is to what's

possible, you may have seen already,or may soon see,, a new tool that the course's team hasbeen working on, this time in collaboration with harvard studentagencies, such that starting this year and continuing hopefully into thiscoming summer you'll have a standard opportunity on campus to buy andsell things of interest to you. and with partnership through hsa, you'llalso be able to drop items off in one of hsa's physical stores at somepoint in the future, so as to proxy things, particularly as yougraduate and don't necessarily want to discard things, but actually pay itforward to folks who might follow you

here on campus. so more on that to come. >> but a little more concretely, a toolthat's come out of cs50 in recent years, with which some of you might befamiliar and others of you might be googling now, at, you'llfind a link to a chrome extension which is demonstrative of how you canuse javascript, that same language we used with the eiffel tower a moment ago,to implement 2x playback speed for all harvard isites videos. this is something that's builtinto cs50's own video player.

but this, too, if you begin to diginto the source code, which we'll happily make available, you'll see howyou can even solve problems like that, accelerating widgets in websites withwhich you're already well familiar. >> so a word now on the course andexpectations and what lies ahead. in general, we'll indeed gather hereon mondays and wednesdays-- though this friday, we'll gather becauseof shopping week-- 1:00 to 2:00 pm, thoughsometimes until 2:30. given that you might therefore want orhave to take some class at 2:00 pm onward, or even before, do realize thecourse is supportive of what's called

simultaneous enrollment, whereby we'llsupport a petition to the ad board and your resident deans on your behalf ifyou have a conflict somewhere in this 1:00 to 2:30 range. head to that url online foradditional details. >> but in terms of the support structurethat characterizes cs50, for students more and less comfortable alike, weoffer distinct tracks of sections. and this is a couple of weeks off, butbefore long, you'll be asked as to your comfort level. are you among those less comfortable,more comfortable, or

somewhere in between? >> and we'll have three distincttracks that cater to precisely those audiences. so at no point in the term should youeven feel like you're competing against any student with moreor less background than you. indeed, the course is meant to bemuch more collaborative and much more open than that. >> in terms of the problem sets, you'llfind, too, that in addition to the standard edition of each week's problemset, there's often a "hacker

edition" that's meant to be targetedat the 5% to 10% or so of the demographic who's indeed among thosemore comfortable and would like more of a challenge than the standardedition of that pset expects. more details on those to befound in the syllabus. >> but also in there can be found detailson the courses late days. typically problem setsare due on thursdays. however, you can extend many of yourdeadlines this fall from thursdays to fridays simply by meeting us halfway,so to speak, answering a few warm-up questions in some of the week's problemsets, that will automatically

then give you an extra 24 hours. we will also drop your lowestscore, as per the syllabus. >> to give you a sense of what the problemsets are-- because it's indeed the course's problem sets thatultimately define almost every student's experience, more so thanlectures, more so than sections, more so than most any otheraspect of the course. last year, for instance, we began, aswe'll begin this year, with scratch. particularly this friday, we'll use, forjust one day's time, a graphical programming language, with which we'llstart programming by dragging and

dropping puzzle pieces that onlyassemble physically if it makes sense to do so logically. >> next week, we'll quickly transition toc, a fairly old but very small and simple language that will allow us toreally go from 0 to 60 over the course of just a few weeks, and then parlaythose same skills and knowledge of basic programming constructs intohigher-level languages like php, javascript, and yet others still. >> last year, the third pset in the coursewas that of cryptography, a domain-specific application whereby wechallenged students to implement any

number of ciphers, programs with whichto scramble or unscramble information, to encrypt it. for the hacker edition, by contrast,we gave the hacker students a file from a standard unix computer containinguser names and passwords, the latter of which were encrypted,and we challenged those hacker students to decrypt, as best they could,those passwords, still on that same domain. >> scramble, a game with which someof you are perhaps familiar. a forensics piece, where we ask studentsto recover data that had been

otherwise deleted from my own digitalcamera's compact flash card, by actually writing software to figure out,where were the zeroes and ones in that digital camera that previouslycomposed a jpeg graphic? >> a challenge of sorts last yearinvolving writing the fastest spell-checker possible, competingagainst friends and classmates if they'd like. implementing huff 'n puff,a compression program. and then ending the semester with cs50finance, a web-based application with which you create an etrade-like websiteto buy and sell stocks, so to

speak, by actually pulling nearlyreal-time quotes yahoo! finance. >> what we didn't do last year wasone problem set that remains nonetheless a favorite. if you've never gone, you'll see a user interface a little like this. but two years ago, the classimplemented, using google maps and the google earth plug-in and a little bitof savvy with driving around campus, so that the objective of this game was,as you can see some of the faces,

is to drive around campus looking forstaff, teaching fellows and cas, and when you do, putting themonto your shuttle bus. none of them actually seem to be here,so we're going to enter a cheat code. >> david malan: there we go. and here now is the stafflaced throughout campus. and as you can see, on the right-handside of the screen, the shuttle bus has empty seats. and the objective was to write thecode with which to simulate this driving and picking up and droppingoff of passengers.

that one, too, using a languagecalled javascript. so realize that programs like that willbe on our same trajectory this year, as well. >> in terms, now, of additional support,we have office hours. as you might have seen in your own housedining hall or in annenberg, we'll be in the house dininghalls four nights a week-- leverett, pfoho, eliot and annenbergthis year, 8:00 pm to 11:00 pm. and what we thought we'd do this yearis something a little different. >> if you heard rumblings last year thatit was a bit too stressful, this

year's office hours, as we'll describenext week, will be more organic, whereby upon arrival, you'll bedispatched to one particular table where multiple staff members await,and we'll do things much more organically. no more queue, no more ipad, butrather have more intimate conversations around a table of justeight or so students, so that we approximate the feel of what otherwisewould be a much smaller class. >> we offer, as well, these things wecalled walkthroughs, videos filmed in advance by one of the course's teachingfellows, zamyla, in which she

walks you through the week's problemsets, offering tips and tricks for the challenges that lay ahead. and conversely, after problem sets aredue, this year, we'll also release little clips call post-mortems thatactually walk you through representative solutions, both good andbad, via which you can infer how you could have or should haveimplemented your own solution. >> and what we'll offer for the first timethis year as well, particularly for those students who avail themselvesof the course's other resources but nonetheless are strugglingall too much, the course

itself will pair those students, asresources permit, with tutors so that you have a much more intimateopportunity than house dining halls allow for one-on-one assistance. >> now a final glimpse at someof the end games in sight. you might be familiar withthe cs50 hackathon. well, coming this december, from 8:00pm to 7:00 am, at the beginning of reading period, will be an opportunityto gather with classmates-- this would be around 9:00 pm-- during which you dive into your finalproject's implementation alongside

classmates, friends, and food. this would be around 1:00 am, whenthe first batch of food arrived. and this is about 4:00 am thatparticular year at the cs50 hackathon. >> but the true climax of the course ismeant to the cs50 fair, a campus-wide exhibition of your own final projects,to which family and friends are all invited, as our recruiters andour friends from industry. this, for instance, is a glimpse of the2,000-plus people who've attended past years. expressions like this are not uncommon,and similarly do your

classmates delight in thingsyou've accomplished. >> and actually, toward that end, we havea start-of-term event, as well. if things like this appeal to you, oryou're at least curious as to what this, know that a new tradition of thecourse is called cs50 puzzle day. and this was instituted a couple ofyears back to really signal to campus that computer science is not aboutprogramming, and it's certainly not about embracing only those studentswho have prior experience. it's really about problem-solvingmore generally. >> and so puzzle day, over the past fewyears now, has evolved into a nice

partnership with our friends atfacebook, whereby there'll be fabulous prizes and pizza across the river atthe i-lab this coming saturday. head to that url with two or threefriends if you would like to partake in this new tradition. >> so i'd like to ask that you keep onething in mind, and we've got just a two minute clip on whichto close today. 73% is the number to remember. cake, too, will await you outside thistransept as we adjourn in just a couple of moments, which is a traditionof the course, as well.

but this is the key quote from thecourse's syllabus to keep in mind. what ultimately matters in this courseis not so much where you end up relative to your classmates but whereyou, in week 12, end up relative to yourself in week 0. >> but the glimpse that we will leave youwith here today is this last one here by our same daniel, who did thewrdly video just a moment ago. i leave you with this glimpseof what lies ahead. and as we do this, if we could have cs50staff from the front of the room to come on up to the stage to paint allthe more of a visual picture as to

what awaits you this year-- getting awkward. we'll conclude with thishere on the screen. >> david malan: this is cs50. >> [music - matt & kim, "it's alright"] >> speaker 1: i love cs50 more than cats. >> speaker 2: whoaaaa! >> david malan: this, then, is cs50. we will see you on friday.

>> narrator: at the next cs50, an onstagedemo doesn't go as planned. >> david malan: we want to find mikesmith in this phone book. well, what are your instincts? i might jump roughly to the middle ofthe phone book, glance down, see that i'm at m, and i know now that mikesmith isn't to the left. he must be to the right. and so at this point, wecan literally tear-- at this point, we can literally tear-- at this point, we can figurativelytear the phone book in half.

>> [ukelele strumming]