For 240, now there wonft be. [Student:]I can sit in [inaudible]. Oh, thatfs fine. Hey, everyone, welcome, we are live on television. So this is cs107. My name is Jerry Cain. I have two handouts for you today. Theyfre the type of handouts that you expect to get on the first day of a course. As far as pertinent information about myself; my life synopsis is on the board right here. Therefs my email address, those are my office hours, and that is my office upstairs, just more or less, directly above this room. By far, the best way to get in touch with me is email via that address. Certainly if you have a question that you need to ask me specifically about then email is great, Ifm very good about checking email. Ifm the type of person that just clicks on send and receive every three seconds, so I know when your email comes in so Ifm always very good about responding. The office hours are early in the mornings on Mondays and Wednesday, I know thatfs not the best time in the world, but just for various reasons, thatfs the only time I can really have them, but in general, if Ifm in my office you are more than welcome to stop by and youfre always welcome to call my office to see if Ifm in during some other time in the week. Okay. Ifll try to make it a point to just casually be around the office as much as possible, but Monday and Wednesday, 9:00 to 10:30, is really the official time when Ifm around. Okay. I have a good number of staff members; I can have them just wave, you donft need to stand up, just wave, you can wave a little bit more enthusiastically, thank you. Okay. That actually only represents about a third of what the staff will be. Some people have a conflict today so theyfre not here. And I actually only figured out last night how large this class is. We expected a 130 - 140 students and I just checked at 10:55 that we have 241 signed up for the course, which is the largest that cs107 has ever been. Itfs really weird having this many people come and take and interest and listen when you talk. I feel a little bit like Barack Obama. Ifm delighted that this many people are taking it and so I certainly expect to have, on the order of 15 to 18 TAs and undergraduate section leaders working and theyfre very pertinent to the course. I almost require -- in fact, it is the case this quarter, that every single person Ifm gonna hire has taken 107 either as a undergraduate or as a first year graduate student, so they are great resources for questions and their office hours, with very little exception, theyfve all done all the various assignments that youfll be doing this quarter, so they already know what your questions are gonna be. Okay. As far as their office hours are concerned, they will have office hours and theyfll rotate through a grid of evening hours at the main computer cluster where youfll be expected, or at least invited, to do all of your online programming work. Okay. Those will start next week. Youfre not gonna have an assignment until this Friday, and I make that one as easy as possible as far as the coding assignment is concerned because you have to get used to Unix and this new development environment. A lot of you have probably never been there before, so I go soft on your on assignment one so you can actually not be intimidated by the whole Unix development process. We do have a discussion section. We had scheduled one for tomorrow -- Ifm not even gonna say the time because I donft want to confuse people -- but it turned out that it was terrible for three of my four head TAs so Ifm in the process of rescheduling that. Itfs not gonna be on Thursday, itfs probably gonna be on Tuesdays. Thatfs what Ifm shooting for now. At the time I had to take these handouts to press I just didnft have a time yet, but I will announce, certainly in lecture on Friday and probably prior to that via the emailing list. Youfre not required to go to discussion session, it is gonna be televised just like the lectures are -- there will always be section handouts and section solutions, so even if you just donft want to bother watching it, not that Ifm recommending that, but you certainly have the resources to figure out what they went over during that section because Ifll be very good about putting up section handouts and section solutions so you know exactly what topics they were discussing. Okay. Whatever the time is next week, itfll probably be Tuesday sometime in the afternoon. The first section, if you go to one section off quarter and go to one live section off quarter, next weeks is probably the one to go to if youfve never really dealt with Unix before. Theyfll invest some energy coming up with some slides and some examples to show you what itfs like to open an [inaudible] in Emax and to actually code there and then to use a command line to compile the program and see how you actually compile and execute and debug programs in a Unix world. Okay. And itfs a little weird at first, you kind of hate it for three or four days then you start to like it because itfs really light weight and very fast. So thatfs another reason why I make the first assignment less about coding and more about just getting used to Unix. Okay. Not next week, but the week after when we start having discussion sessions again, and having more of them, thatfll adopt a more traditional format where we bring section problems and we talk and everybody raises their hand and asks questions and things like that. Okay. As far as reading material is concerned, in the handout I specify three books that I think are really great books. Two of them are on C++; theyfre actually quite advanced books. Therefs also one book on a language called Scheme, which Ifll talk about in a second. These are by no means required and I donft even want to say that I recommend them in a sense that those who are really fastidious about going and buying every book they think is gonna help them, Ifm not really even saying that you should go buy it, I just want them to be on your radar so that if after you get through the C and C+ segment of the course, you can see yourself doing more serious C++ programming later on, then you might want to go and get these book. But donft spend money on books yet because this class has more or less been taught with the same type of structure over the past 15 years so wefve compiled pages and pages of handouts. This is just the tip of the iceberg. Anything youfre gonna be responsible for is covered either in lecture of in the handouts. Ifm not gonna have any external reading from text books so just worry about the handouts. The handouts are very polished. I think theyfre in really good shape. Youfll average one to two handouts every single lecture and probably Friday and Monday, youfre gonna get four or five each day. As far as the exams are concerned -- let me talk a little bit about that. Midterm, there is one, and it is Wednesday, May 7. Okay. I schedule it for 7:00 to 10:00 P.M. People roll their eyes when they see a three-hour window set aside for a midterm. Ifm not gonna write the midterm with the intent of you needing every single minute of those three hours. I genuinely make an effort to make the exam so that it can be completed, patiently, in 60 to 90 minutes, okay, and occasionally, Ifm off. When that happens, you have this buffer of an extra hour and a half to really work through it. Okay. I just give people three hours with the intent of giving the illusion of an infinite amount of time so that they donft feel that theyfre pressured to get through it. That may sound like Ifm being really nice, but Ifm actually being slight cruel by giving you three hours because if you do badly on it, then you have one less reason to blame me. You actually have to work through the problems and you really have to know the material, and you canft blame time pressure as being a factor as to why the exam didnft go well. So thatfs why I want to give people as much time as I can reasonably give them without going into 2:00 A.M., 3:00 A.M. Okay. I recognize that because this is scheduled outside of lecture that many of you may have classes, orchestra meets at night, people have various activities they have to do at night, I want to displace you from those because I decide to have my exam outside of lecture so if you canft make that time, thatfs fine, just let me know soon and plan on taking the exam during some three hour window that fits between 10:00 A.M. and 6:00 P.M. Okay. So most people that works with. If thatfs not gonna work out, then let me know now. Ifll make sure you take the exam sometime, but Ifll be around more or less or TAs will be more or less all day Wednesday to make sure that you can take an exam when you need to. Ifll accommodate any reasonable requests. As far as the final is concerned, I offer the final exam twice. Our dedicated slot is Monday, June 9 and the official time is 8:30 A.M. Now, because wefre on TV and because Stanford students -- therefs just not that many times to offer classes, a lot of people have conflicts, a lot of people are taking two classes, sometimes even three classes Monday, Wednesday, Friday at 11:00, and if thatfs the case, then you have two or three finals on Monday, June 9th at 8:30. If you want to take all three then, youfre more than welcome to, but I assume youfre not gonna want to do that so if you canft make this time, it is fine, provided you can make an alternate slot of 3:30 P.M. that day. If you cannot make either of those times, please let me know now so I can take care of that. As far as the breakdown of assignments versus exams, this is how it all pieces together in the end. You have assignments, you have the midterm, you have the final, these contribute 40 percent of your grade. The midterm is the least of the three and the rest is the final. Okay. Thatfs a pretty sizable chunk is dedicated to the assignments. People, in general, do very well in the assignments. They might struggle to figure out what kind of things wefre expecting on assignment one, but eventually, people figure out what Ifm expecting and they get the programs to work and they write nice clean code, so we see a lot of Afs and A-s on the programs. We just do. And I imagine 80 percent of you will be getting Afs and A-s on some of the later programs because youfll just start figuring things out. And thatfs not to say that grades will be much lower prior to that, but just toward the end everybody seems to be doing very well on the assignments. Therefs probably gonna be six or seven assignments. One of them will not be handed in, itfll be a written problem set where the deadline will, more or less, be at the time you take the midterm because itfll be a series of written problems that serve as practice for the midterm. Youfre certainly responsible for that, but all the other assignments take a programming assignment approach where you actually code up stuff and you electronically submit it and one of the section leaders or the TAs grade your work and they electronically or they email you back feedback. I donft need any paper copies at all. Everything is dealt with electronically. Wefre gonna really put a lot of effort into trying to turn the assignments around very, very quickly. In order to do that, I do allow you to turn work in late. I have the same type of late day policy that 106b does. I actually give you the ability to grant yourself little extensions in 24-hour units. I give you five of those little days. And if you want, you can use one or two or all five later days on any particular assignment, but after five days, whether using free late days or extra ones that actually cost you a little bit, I need all the assignments within five days of the deadline so that I know that the TAs can start grading them and crank out grades and crank out feedback and get them back to you. Does that all make sense to everybody? Okay. As far as the midterm or final will go I actually try to make this -- I donft want to say that I make it easy, I think, of the two exams, the final is a little bit more difficult because I think the midterm actually deals with the more difficult material so I go soft on you here knowing that Ifm gonna revisit some of that material on the final. Okay. Now, when I say, gSoft,h I donft mean easy, I just meant softer, comparative. Okay. Then I would normally go, but nonetheless, thatfs why I have the breakdown of 25 to 35 -- really, all the material is equally represented on the final exam. Ifm trying to think what else is going on. Oh, of course, as far as resources for keeping in touch with us, if you have a question specifically for me, then by all means email that address right there, but if youfre asking a question about an assignment or lecture material that you know or suspect any section leader or TA would be able to answer, then youfre gonna benefit by sending mail to this address. Cs107@cs.stanford.edu. Thatfs precisely the address that you would assume would be attached to a staff emailing list for this class. When you do that, youfre sending mail to an account that all 15 or 18 or 19 of us whole on a fairly regular basis and so youfre that much more likely to get a quick response. Maybe not so much on a Saturday morning, but certainly on a weeknight when everybodyfs coding and deadlines are approaching. Wefre very good about pulling that and getting responses out as quickly as possible. Okay. If you donft hear back from this within, like say, 12 or 24 hours -- letfs say 12 hours in a weekday and 24 hours on the weekend, then itfs okay to email me directly and say, gHey, Ifm not getting my answers, can you answer this question for me?h But be patient with that. Wefre actually very good -- very often, we get back to people within minutes. A lot of times the TAs are sitting in front of the computer right next to you in the term or cluster where youfre working, you just donft know what they look like so they respond to your question very, very quickly. Ifm also gonna try to experiment -- I have no idea what Ifm planning to do with this, but I have a Facebook group. The URL is for cs107 -- the URL is in the handout. You do have to be a member of Facebook. Ifm not trying to evangelist Facebook just because I work there as well, but if you have a Facebook account already and want to go join this Facebook group, just visit the URL thatfs posted in the handout or just do a search for cs107 and Ifm sure itfll come up. I also have a Twitter account for 107. If you want to follow cs107 -- I think this is an interesting idea because I could send little announcements, these very lightweight, noninvasive announcements to everybody whofs paying attention to cs107 on Twitter saying, gWebpage has been update or exam cancelled,h or something like that. Okay. And you can all follow whatfs going on there. I donft want you to think that you have to pay attention to these. Anything thatfs truly important about assignment deadlines or things that need clarification, I will actually use the mailing list and post to it. That will be the official forum for things that really matter but these are intended to be lighthearted. As far as that mailing list is concerned, I have 241 people signed up for the course already. That means that most of you, if not all of you, are automatically enrolled in the mailing list for the course, so when I send mail to cs107-spr0708-students@list.stanford.edu, you automatically get that email provided youfre registered for the class. If you havenft registered for the class yet, let me pester you a little bit to go and sign up for the class even if youfre not sure if youfre gonna take it because, probably, I send more announcements in the first week of the course than I do anytime later on because just a lot has to happen and we have to up ramp a lot in the first few days so Ifm certainly gonna send an email out as soon as I found when section time is. A lot of you have signed up for the course may not realize this, but sometimes you can inadvertently set some privacy settings so that youfre email is not put on that list -- do you know what Ifm talking about? Okay. So go to Stanfordu.com or u.stanford.com, I forget what it is or wdu where you just go make sure that your email is public just to the Stanford community so that you can get on that emailing list. If you have a problem with that, I understand that you donft want your email address advertised, but then just make it a point to email me and say that youfre not that so I can put your email address on some sub list that I always include with the announcements. Does that make sense to everybody? Let me just talk a little bit about the syllabus. Letfs make sure therefs nothing in here. Is there anyone in the room who has not taken 106b or 106x, a couple people Ifm assuming, okay. Ifm just taking a pulse on this. I donft necessarily require 106x or 106b, specifically, but I do kind of expect that youfve done some C++ programming, that the notion of a linked list or a hash table is familiar to you, a binary search tree, a function point or all of those things that are covered in our 106 courses are familiar to you. If that isnft the case or you donft know C++ all that well, then Ifm a little worried because the first half of 107 is all about advanced C and C++, so if you donft have the basics down or you havenft been exposed to that stuff yet, it makes the first two weeks of the course, which is normally actually quite fun because youfre learning all about the inside, under the hood machinery of the C language, it can make it pretty miserable unless you actually anticipate spending a little bit more time getting up and running. So if you donft know C or C++ and youfve never written an assignment for a course in C or C++ then talk to me after lecture so I can kind of gauge as to whether 106b or 107 is better for you. Okay. Here is, in a nutshell, a reduced version of whatfs presented in handout two. This is the syllabus. I have several languages that Ifm gonna put on the board and one concept. C, Assembly, C++, Concurrent programming -- thatfs not a language, thatfs just a paradigm, Scheme and then it is official, Ifm actually gonna cover Python from now on in 107. People look at this and they go, gWow, Ifm gonna be able to legitimately put all of these languages on my resume,h and itfs from a separate list at the bottom and it feels really good. It isnft so much about that. Certainly we want to give you some mileage in some very relevant languages that are very good for both research and for industry, but the real intellectual value in learning all of these languages is to really study the paradigms that they represent, and Ifll explain what that means in a second. I think a lot of C++ programmers really program in C and just incidentally use the objects within the classes that are available to them, okay, which is a perfectly reasonable way to program. Most people learned how to program in C, at least the people I know in the industry, know C very, very well, and in spite of the fact that therefs 50 million newer languages that are better in many regards, they still stick with what they know and thatfs why C and C++ are still such popular languages. Therefs nothing wrong with programming in C if you know it very well and you write clean, readable code, itfs just more difficult. I donft really care so much about teaching you how to program an assembly, I use it as a vehicle for showing you how C and C++ programs compile to dot 0 and to object files and to binaries and that become executables and show you how a line like I = seven or J++ or FU of X and Y is a function call, how that all translates to assembly code. Okay. Does that make sense? You know when you write C++ code that when you execute the program, itfs not C++ anymore, itfs assembly code. Itfs all zeros and ones eventually. I want to give you some insight as to how C is translated to assembly code, how all these variables and your functions and your objects and all of that, eventually, get boiled down and hashed down to a collection of zeros and ones and I want to do a little bit of the same thing for C++. It turns out that -- well, C++ and C represent different paradigms, that they really compile the zeros and one, and after you get enough experience with this assembly and the manual compilation process that wefre gonna learn about and how to look at C code and figure out what the assembly code would look like, youfre really gonna see that C++ and C almost look like the same language as far as the zeros and ones are concerned. Ifm gonna be able to do something like **&**P arrow ***=7 and youfre gonna know exactly what it means. Okay. So it takes a little bit of work and itfs almost laughable how arbitrary you can be with formulas, but if it compiles, it means something so when it runs it actually does something. Itfs probably not good if you have a lot of asterisks and ampersands, but nonetheless, you can have some idea as to why itfs crushing, not just that it is crushing. Okay. I spend a good amount of energy talking about concurrent programming. We actually -- at the moment, do that type of programming in C, but all the programs youfve written in the past two quarters, if youfve just taken the 106A and 106b courses here or 106x, all the programs youfve written at Stanford, prior to 107, have been sequential programs. That means that whether itfs object oriented or procedurally oriented, you have this outline of steps that happen one after another. Nothing is done in parallel or pipelined or done side-by-side, everything happens in one clean stream of instructions. Okay. Well, what concurrent programming is about is within a single program trying to get two functions to seemingly run simultaneously. If you can get two functions to seemingly run simultaneously then you can extend that and get 10 functions to run simultaneously or 20 functions to run simultaneously or seemingly simultaneously. I say it that because, technically, they donft run at the same time. When I go over assembly code, and I think you can intuit enough about what assembly code is like, but if you have this one function, okay, my hand is a function, this hand is another function, okay and you concern yourself with the execution of one of them and then when I do this you can just think about it reading the code and executing it for side effects. Does that make sense to people? When you deal with concurrent programming you have two or more functions, just two right here because I only have two hands, to do this and they both seemingly run at the same time, but what really happens is itfs like watching two movies at the same time where -- because therefs only one processor on those machines, it doesnft really run like this, it runs like this and switches back and forth between the two functions, but it happens so fast that you just canft see the difference. Okay. Itfs more than 24 transfer seconds, itfs, like, a million. There are a lot of situations where concurrent programming is not very useful, but there are several situations, particularly networking, whenever thatfs involved, where concurrent programming is actually very useful. There are some problems that come up when you deal with concurrent programming that you might not think about. The example I always go over the first day of class is just that it uses two Wells Fargo ATM machines. Okay. Think about you have a Wells Fargo checking account, you may not have to think about it because you probably do, so just imagine your checking account is in danger because two people are using ATM machines and you have a $100 in it and you share your PIN with your best friend and you go up to a neighboring ATM machines and you make as much progress as possible to withdraw that $100 and then you both, on the count of three, press okay to try and get $200 collected. Does that make sense? That is not a sense sensible example because both of those machines are basically very simple computers, okay, that ultimately need to access the same master account balance to confirm that $100 is available and in this transactional -- transactional makes sense both in terms of money and also in the sense of concurrent programming -- you have to make sure that the $100, being identified as the account balance, is maintained with some atomic flavor so that if you have two people trying to withdraw $100 at the same time that only one person gets away with it. That $100 account balance is the shared resource that two different processes have access to. Does that make sense to people? Okay. So there has to be directives that are put in place to make sure that the account balance check and the withdrawal are basically done, either not at all, or in full so that it really does function, truly, as a transaction, both in the finance and the concurrent programming sense. Okay. As far as this Scheme and Python are concerned, once we get through concurrent programming we really switch gears and we start looking at this language called Scheme. You may not have heard of this. If you havenft heard of this, you may have heard of a language called LISP, which itfs certainly related to. This is a representative of what is called the functional paradigm. Okay. Therefs two things about Scheme and functional languages -- purely functional languages that are interesting in contrast to C and C++. When you program using the functional paradigm you always rely on the return value of a function to move forward. Okay. And you program without side effects. Now, thatfs a very weird thing to hear as an expression when youfve only coded for a year, but when you code in C and C++, itfs very often all about side effects. The return value doesnft always tell you very much. Itfs a number or itfs a bouillon, but when you pass in a data structure by reference to a function and you update it so that when the function returns, the original data structure has been changed, right, does that make sense? Thatfs programming by side effects. Well, the idea with Scheme and particularly the functional paradigm is that you donft program with side effects. You donft have that at all. You always synthesize the results or partial results that become larger partial results that eventually become the result that youfre interested in and only then are you allowed to print it to the screen to see what the answer to the problem was. Okay. Itfs very difficult to explain Scheme if youfve never seen it before in a five minute segment of a full introduction, but when you get there, we have tons of examples of the paradigm. Itfs a very fun, neat little language to work in. This language called Python -- Ifm suspecting that most people have heard of it even if theyfve never seen it. It seems to be the rage language at a lot of significant companies in the Bay Area. Theyfre very smart people with these companies so when they use a language and they like it, therefs usually a very good reason for them liking it. Youfve probably heard of a language called Pearl. Okay. Itfs not a very pretty language. You can just think about, in some sense, Python being a more modern, object oriented version of Pearl. Okay. Now, if you donft know Pearl and you donft know Python it doesnft mean anything to you, but just understand that this sexy little language thatfs been around for probably 16, 17 years thatfs really established itself as a popular language since year 2000, 2001. I know a lot of people who work at Google that program in Python on a daily basis. Therefs a subset of us at Facebook that program in Python every day. It actually has a lot of good libraries for dealing with web programming. Web programming can seem really boring to a lot of people because it just seems like itfs just HTML and web pages and things like that. Real web programming is more sophisticated than that. You dynamically generate web pages based on content and databases and things like that and Python, being a scripting language, which means its interpretive and you can type in stuff as you go, it recognizes and reads and executes the stuff as you type, itfs very good for that type of thing, and if all goes well, meaning I have time to develop this assignment idea I have, youfre gonna write a little miniature dynamic web server in Python for your final project. It wonft be that sophisticated. Youfre not gonna write all of apache, but you are gonna probably write some little thing where you really do have a web server behind the scenes making decisions about how to construct an HTML page and serve that over to a client. So itfll be an opportunity to learn Python, to learn with libraries, to see that as a language because itfs fairly young, it has the advantage of not bothering to include C and C++fs and Javafs mistakes. It says, gNo, Ifll leave that part out and Ifll go with this more interesting, well formed core,h it has great libraries, it has object orientation, you can program procedurally if you want to and just program like youfre in C, but using Python syntax. There are even functional programming aspects in the language so even though the syntax is different from Scheme, conceptually, you can use Scheme like ideas in Python coding if you want to. Okay. Ifll be able to illustrate the client server paradigm and how itfs different from traditional programming. Thatfs not so much a Python thing, but Python is a good vehicle for learning that stuff. There are a few other paradigms that arenft represented here, but I think I really cover all the ones that youfre likely to see for the next 15 years and youfre a coder. Okay. There are a couple of the languages that I may briefly mention the last night that are just fun, but they all have some overlap with some languages represented right here. Okay. You guys are good? Okay. So I donft like starting in on any real material when I only have 10 minutes left, so Ifm actually gonna let you go, but recognize that Friday Ifm gonna have tons of handouts for you, Ifm gonna have an assignment, okay, wefre gonna dive right into the low level pointer stuff of C and C++. Okay. So have a good week.