Instructor (Julie Zelenski): Hi. Welcome to CS106B, programming [inaudible]. The website was probably the most important thing to take away from here, right, is where can you find information about the class? Weíre going to talk today and give some overview and stuff like that, but this is kind of the home base for all the material. If you managed to get the handouts on the way in, youíre golden. Otherwise, you can grab them from the website. Thereís a lot of background information, staff information, office hours, all sorts of stuff gathered there. Itís kind of one stop shopping for figuring things out about our course.

Let me tell you what Iím going to do today. The first day, I know a lot of you are shopping and trying to figure out whatís the right fit for you, so hopefully today, Iím going to try to give you some information that will help you make a good decision. I want to tell you a little bit of what our course is about, tell you about the administration and logistics Ė most of that stuff is pretty ordinary, and you can read about it. Of course, I have to do a little bit of marketing. I get to give you my unbiased opinions of why this is the absolute best class you could possibly take.

I get paid per student, you know. Thatís not true. Maybe weíll even have time to check out a little bit of the C++ language before weíre done. Let me tell you about CS106. CS106 is the introductory programming sequence here at Stanford. Itís our version of CS1, where you start at the beginning when you are interested in learning more about programming. We have a two-quarter sequence, A and B, that kind of follow together. Theyíre not particularly tightly coupled, which is to say if you took A and you took a break, you could come back to B.

We also have an alternate form of B, the CS106X, which is kind of an honors version of that second course. So after youíve taken that first course and youíre feeling really jazzed up, there is an alternative more intense way to get through the second course thatís offered. Itís offered this quarter, in fact, so if youíre thinking about that, that is an option for you as well as sticking with us.

What do we do in 106A? The official title is programming methodology. It is starting at the very beginning and assuming you have no background in programming. Itís teaching you how it works, what the languages look like, what the syntax is like, what things you need to know about how to solve problems using a computer. It covers a lot of the fundamentals about logic control and in general, I think the big issues of 106A have less to do with any particular syntax or feature that you learn about a language but about how do you solve problems on a computer?

Somebody gives you a specification of you need to write a program that does X, and you have to figure out how to make that happen, how to break it down, how to step through it, how to develop it, how to test it, how to iterate on it, how to make changes in it later, how to debug it when itís not working well, and those things, I think, transcend any particular language. W e happen to use the Java programming language in our 106A course because itís a great tool for introductory programming, but I donít think of that as being really critical.

In fact, if your introductory course was in some other fairly modern, high level language Ė letís say you learned in Python, C, Scheme, or something other than Java, youíre probably still fine, Ďcause what weíre really counting on in B is that you know how to program and think like a computer scientist. Not a lot of the details of the syntax are going to be important to us. B picks up from there, saying okay, youíve got some fundamentals. Letís start really learning some of the techniques that extend the range of problems you can solve.

We look at recursion, which is one of the fundamental problem solving techniques that involves using something akin to mathematical induction to solve problems in terms of themselves. Looking at a lot of algorithms for sorting and searching and hashing and doing things efficiently, knowing how to compare and contrast alternatives in algorithms, having some formalisms by which to discuss those things, and learn some of the classics that are out there for solving these problems.

The dynamic data structure, which involves use of pointers to construct things like lists, trees and heaps, graphs that model certain structures that are very effective in solving certain kinds of problems Ė weíll work through those. A large part of our time is spent on this concept of data extraction, which is why extraction shows up as the main word in our title. As we start to solve more and more complex problems, the code itself can kind of become overwhelming if we donít have some technique for managing that complexity.

One of the big themes for 106B is how we can use this idea of extraction, building something and dealing with the low level details but then closing up the box and treating it as kind of a fixed entity and building on top of that and then closing another layer around that as a way of working on something, finishing it and moving on to some larger piece without having those details cloud our way. Itís a very powerful technique for solving larger problems.

In that context, weíll be looking at some of the classic data structures, like stacks, cubes, lists, maps and sets as part of the domain for that. We do happen to use the C++ programming language, but this is not a C++ course, so to be clear about what youíre getting versus what you wanted, we use Java here. We use C++ here. We happen to think theyíre good reasons to actually expose you to both languages. In particular, C++ is an enormous language. It has a lot of language features as well as a very large standard library, and our goal is not at all to turn you into this industrial strength knows every detail about quirks and ins and outs of C++.

There is another class, 193D, that does attempt to do that. In fact, if thatís what youíre looking for, I suggest you take a look at that. What weíre here about is learning advanced programming techniques Ė taking those foundations and building on them to be able to solve more interesting problems. We happen to use C++. You will learn some C++, but I almost consider it a side effect of what weíre doing.

Just a little note on placement Ė if youíre kind of in between and not really sure, these are the very rough guidelines, but they give you some idea of which groups gravitate where. If you are new to programming or youíre not confident about your background Ė maybe it was a long time ago. Maybe it was self-taught. Maybe it was in a course that you felt was not as good as it could have been or you didnít do as well in it, 106A is a great place to start. It actually is by all accounts an extremely popular course at Stanford and services a wide group of people with a little bit of background or no background.

If you do have something like a solid first course experience Ė you did well in 106A or took a similar course or perhaps even self-taught your way through a lot of those materials and you feel ready to move on, 106B. An AP course in high school Ė the A curriculum is a pretty good match for 106A here, so youíre in a great place.

If you have this and youíve got a little bit more going for you or youíre super enthused and you have a lot of extra time this quarter and want to sit in the company of only the uber geeks, you can check out 106X, which covers the same kind of topical ground but at a different level intensity. It amps up a little bit of the assignments, covers some of the material that we wonít get a chance to cover, and just pushes the envelope a little bit there.

If you have experience comparable to the first two courses Ė youíve done all the things that weíre talking about here in B and you feel comfortable with it, it might be that the right place for you is 107, which is the third course in our sequence. Thatís somewhat rare, so if youíre thinking about that, I encourage you to talk to me a little bit to make sure that you wonít be missing out on something important in doing so, but certainly there are students who have Ė for example, the APCSAD curriculum is pretty comparable to this course here, and so depending on how high quality the course you had was, it might very well be that 107 is right.

In some situations where that course was a little bit lacking, there may be some ways that we can help reinforce the things youíve learned and build a stronger foundation to move forward from rather than jumping ahead. Any questions about placement?

Letís talk philosophy. I think thereís a statement about what we officially are, but I also think that 106 has a long tradition at Stanford that comes back from student motivation, which is interesting. I was here as an undergrad in the 80s when the 106s were just getting off the ground, and at the time, Stanford only had a graduate computer science department, and the belief in the ancient period for computer science was you should get a math degree, and only then would you be mature enough to learn about computers.

There was a groundswell of Stanford students who said we want access to programming. We want it. Part of the 106 was a really careful thought about what the 106 would be a Stanford and what we want them to be in a philosophical sense. One is that we welcome students of all majors and backgrounds. We donít have a version of 106 thatís for the majors or potential majors and a version thatís for the non-majors and a version thatís for terminals. We really think that we can bring you all together and design a course that addresses this wide disparate group but still serves it well.

Iím going to turn you into a CS major. Thatís my plan. At Stanford right now, not having to make that choice about a major until junior year is a gift to allow you to explore and to feel unencumbered by having made some decision when you applied, and I think itís important to respect that gift that Stanford gave you by trying to make sure our courses donít funnel you one way or the other before you figure it out. You are all welcome here. We try to make it accessible to everyone. We have certain plans that help to make that work.

We do try to provide a solid, practical foundation in programming that given our placement at Stanford in the middle of the Silicon Valley, thereís kind of a strong influence for us to try to produce students who from the get go are learning things that are actually quite useful outside of the classroom rather than teach you a very academic and mathematical language like Scheme that is very rarely used outside of the classroom. Weíre trying to teach you on the tools, languages and techniques that are actually in active practice.

We are using Java and C++, two of the most prevalent languages out in the industry, and we do a lot of learn by doing. We assign challenging, full-fledged programs that you work on and you build, and so itís not designed to be academic exercises. You really are building skills that have applicability here and outside of the class. We have a big emphasis on truth and beauty. This is one area in which some of the substitute courses that we have seen students come in with have a little bit more trouble with is tackling this part of it, which is that there are a lot of ways you can get a program to work. Many of them are not pretty.

You can just type and type and type and eventually, you can get your way to something that works. That, in the end, might produce a program that from external appearances works. It plays hangman or whatever was the desired goal, but that internally is a mess. Itís not well structured. Itís not well [inaudible]. Itís not easy to understand. It wouldnít be easy to modify. It makes a lot of decision that are really sub optimal, and weíre really interested in producing engineers that have a good sense of design and really appreciate what is involved in writing good, well designed software, not just working software.

We will be giving you feedback on both the correctness and functionality of your code but as important if not more so, also on how well we think you did at designing and implementing and writing code that is of a high quality. We make a big deal out of that. That is something that is not always shared by other classes, and so in particular, someone who is self taught or in a class that didnít emphasize this might feel that thereís a little bit of a gap there where we need to make that up with you, and we can work with you.

This is a very individual thing, because thereís not one good example of the perfect style in the way that a lot of different people express themselves in written communication very well but differently. The same thing is true about programs. You will have your own unique style, and weíll work with you to coach you on getting your style to come through and be beautiful and elegant.

This kind of comes back to point one as well is that we make heavy use of undergraduate section leaders as mentors in this program. We have a staff of 50 or so undergraduates who work with the 106A, B and X courses as a team. They have specific responsibilities with their section, so mentoring and grading and meeting with sections to give individualized feedback on their programs as well as answering questions, solving problems, being in the lair 30 plus hours.

Theyíre most weekday nights about six hours and often well past the midnight when itís supposed to cut off solving peopleís problems, helping when you get stuck, answering your questions and making sure youíre all making forward progress. That comes back to point one. In some universities where theyíre choosing to use their intro course as a weeder, itís like letís separate the weak from the [inaudible] early and letís make it really hard and not provide too much support, and that way weíll make sure we get the people we want.

We have a different idea. Programming is hard, especially when youíre learning. Thereís a lot of complexity to master, and there are a lot of details that can interfere with moving forward, and we donít want you to get stuck on something that we can very easily resolve for you. So make sure you have accessible staff members in person, in email and regularly in session to help get through the roadblocks and keep you moving forward.

What do you need to know to be sure youíre going to do well? There are people who think to be a good computer programmer, you need to be good at math, logic, and drinking Jolt. I think it comes down to more personality traits than any particular technique or skill. You donít need to be good at math. How much calculus and trig shows up in this? Not very much. A little bit of logic Ė that helps. I think it comes down to traits like curiosity and determination and hard work. Starting early, asking questions when you donít understand something, trying to solve the problem by logic Ė why does this case work and why does that case not work?

I think these are the skills that serve you the best in this class and probably every other thing youíd want to tackle. There is a lot of time that will be spent here to master this. I can talk about programming all I want, and you can go oh, yeah, that makes a lot of sense. But when you go to write it yourself, itís a very different experience. Thatís where being focused and staying on task and getting help when you get stuck can help you move through that.

My unbiased opinion about why 106B is one of the best courses at Stanford Ė itís going to be totally obvious when I say these things, and you guys are going to have to go along with it. Iím actually a big time geek, and I happen to love programming. Thatís why Iím a perfect fit for teaching this course. I have taught 106 B or X more than Iíve taught any other class that Iíve taught at Stanford in my time here, and thatís because each quarter when weíre setting the schedule, I say give me B. Give me X. Thereís no better course to teach.

Programming is just awesome. If you love programming, I think thereís almost nothing better to do in the world. You have this task. Youíre trying to get there. Youíre coding. Youíre making stuff happen. Youíre testing, iterating and running. You see stuff. You build things. When youíre done, you know it works. When a program works, you know it.

It does what itís supposed to do. It gets the right answer. It plays the game. It solves the problem. Finding and fixing that last bug Ė although debugging is one of the last aspects of programming a lot of people bemoan about, I happen to think that if you are driven by debugging, that is one of the most awesome detective stories ever.

Trying to figure out why it happened when you did this, why it went this way when you moved that and what this effect caused and understanding once you make the fix how it fixes it Ė staying up late. I have stayed up late more nights debugging than anything else in my life, and Iím not sad about that at all. That means Iím in the right place. Hopefully, some of that resonates with you. If that sounds really awful to you, hopefully we can change your mind a bit. That is, in some ways, part of what drives computer science is this wanting to build things.

We are engineers. We have this computer science name. Just remember Ė any subject thatís name is something science is not a science. Weíre trying to puff ourselves up a bit. We do a lot of really great work, and there are a lot of neat scientific principles and theories that underpin what we do, but in the end, I think what drives a lot of us is just the engineering Ė building stuff that is really neat.

It kind of reminds me that my husbandís a mechanical engineer, and so I used to be envious, because he would always build things. Heís always toting foam core around the campus on their paper bicycles and stuff, and itís like they build all these things. Now, having watched all the things he builds, itís like [inaudible] really hard. You need all these materials. You need all these tools. In computer science, you donít need anything. You need a compiler and you need a computer. You need your thought. Itís like an abstraction we built out of our brains.

Thereís this relatively small set of things that you need to master and then you can combine them in these very sophisticated and interesting ways to solve all sorts of problems. Thereís a very low overhead, and the range of things you can attack with the same set of skills is huge. Every domain out there can benefit from somebody applying computers in a useful way without fail. Thereís all sorts of problems where technology is part of the answer Ė not the only answer, but certainly something that you can take whatever interest you have and combine it with computer science and construct something cool.

I happen to think that what happens in the second course is amazing. The first course, youíve kind of got to get up to speed, and thereís a lot of basic material that needs to get covered, and it does set you on the right path, but in this course, we really get to blossom beyond the basic things.

There are a bunch of really neat and very accessible techniques that a second quarter student can understand and master and do really cool things with. You can learn how to do something like create a database that has a million entries and then ask for somebody by name and be able to instantaneously be able to find the name. Change the size of it. Make it ten million, a billion, and still be able to provide that kind of instantaneous access. Youíre going to learn how to do that.

The technique is not some superhuman thing. Itís something very clever, admittedly, but itís very accessible. Taking that same million thing and learning how to sort it efficiently. What if you happen to know things about how itís almost sorted but just a little but out of sorts? Are there ways you can actually make it even faster to put it in sorted order? There are techniques, for example, like recursion that take on problems that you might not have any idea when you first look at the problem how to solve, but once youíve got your head around recursion, you can look at that and say I can write a five line function that will solve that problem.

This is the kind of power weíre going to give you with our quarter together. Thereís a bunch of really amazing theoretical and algorithmic stuff to explore that really increases the kind of things you can do with programming. Iím particularly fond of it. As always, I think the section leading program that we have created and built at Stanford is a huge part of what makes our 106 courses so successful, and so having somebody whoís individually working with you, meeting with you weekly and giving you that feedback thatís individualized and personalized for you and helping you get through the rough spots is a lot of what helps to make the experience very fun and very personal, too.

What section leaders do I have here? Not a one. Where are those section leaders? We havenít yet identified whoís going to what class, so maybe theyíre all thinking theyíre going to go somewhere else, but theyíre wrong. Weíll get some. 106B Ė great. You agree? Have I convinced you? Is anybody still hesitant? Is it a lot of work? Oh, no.

Let me tell you a little bit about logistics. There are some random things you may want to know about how the class works. Weíre going to meet here Monday, Wednesday, Friday 2:50 to 3:05. It looks like we almost exactly fit in our classroom, which means weíre all going to be very friendly and cozy. The lectures are being taped and are available online, and so that has the neat side effect that you can watch them and review them later. You could watch them lots of times.

It also means that if it were pouring rain and you were sitting at home in your bunny slippers, you could just say hey, Iím not going outside and you could turn on your computer and watch. Iím a big fan of having you come in person. Thatís because I donít want to lecture to an empty room. I also think thereís an interaction there that Iím fond of, and so I hope that you will make every effort to attend in person as much as you can. It is nice to know that if you do miss a lecture or you get caught up with something, youíll have a chance to review it later online.

We will have sections that will meet once a week, just like 106A. The section leader who meets with you is the one who will be grading your programs and sitting with you and doing the conferences. What you need to do to get yourself into a section Ė there are several section times listed. Ignore them.

What you do is you go to the online Ė if you go to our class webpage, thereís a link that tells you how to sign up for a section. The section times arenít up right now, but they will go up tomorrow, and theyíll be up through the weekend. You go in and put in your preferences about what times fit your schedule or not, and thereís this big computer program that gets everybody into a section that fits into their schedule.

The signups will be up from Thursday at 5:00 until Sunday at 5:00. If by Sunday at 5:00 youíve got your schedule fixed, then youíre fine. If you happen to change after Sunday at 5:00 and after the assignments have been made, at that point, itís a little bit harder. We can make adjustments, but itís on a very case-by-case basis. The best thing you can do is by Sunday at 5:00 have a pretty firm idea about what you can and canít do. Thereís a list of preferences, so maybe what you can do is pick things that you know will work no matter what happens.

The workload Ė everybody wants to know how much work. Itís a five-unit class, and itís a five unit engineering class. You get your five units worth, I would say, so donít worry about that. I wonít shortchange you. We have programming assignments not quite weekly. I think there are seven of them across ten weeks, so you can calculate it out. Itís about a week and a third for any particular one. The students report that itís about a 15-20 hour project, each of them. Some people get them done in less than that. Some people take a little bit more. I would say thatís kind of the mode range for what people are reporting.

I do think that of the people who report less, some of those are people who are naturally gifted, but a lot of it has to do with your habits about how you work and how you make progress, so if you are one of the people who feels you might be more likely to be on the other end, you can come and talk to me and I can give you some suggestions.

Choosing to work in the lair where the helpers are on duty has really positive effects in that when you get stuck, you have easy access to somebody helping you work through it rather than spending an hour or two fighting something that turns out to be simple but required knowing something that you didnít yet know.

Iím a big fan of learning things yourself. Thereís also a time when a well-placed bit of advice from somebody can save you a lot of time. There will be a midterm and a final exam. Theyíll both be in class, open book, open notes. The midterm is actually technically out of class. Weíre going to have it at night because we need more than a 50-minute period to get any coverage of that. Our final exam is scheduled in our university-scheduled slot. Sadly, that is at the very end of the exam week, but thatís when the registrar put us, and thatís when we need to go. You may want to take a look at that before you head off for spring break.

Unfortunately, our publisher will not allow me to distribute the course reader electronically. Theyíre not exactly very in the modern age on this. Yeah, Iím working on it is the truth. By the time the world sees this, hopefully, we will have some other strategy. We currently are in negotiations. The nice thing about the course reader is that we have not changed it in the last year. If you know somebody who has it from last fall or last spring, it has some minor edits and typos that were fixed, so if you can get a hold of an old one, itís good.

We are getting no royalties on it. Weíre publishing it at production cost, so where it would have been a $100.00 textbook had it been bound and snappy, youíre just getting what it cost to photocopy and bind the thing, and Eric and I are eating ramen. Itís hopefully cheap enough that you can find a way to get to one or get an old one without it being too much of an obstacle.

People in general find the course reader to be an asset. We do say itís required reading. It does have a lot of material thatís very useful in understanding the course. There are other people who donít make as big a use of it, but there are some sections that are really very valuable and other ones that may be more or less depending on your learning style. Thereís also a lot of good sample problems and review questions in it that help to test your understanding.

You know, itís tricky, because the university in general discourages you from giving alternate exams because of Ė you can imagine the issues of having an exam that has been seen by some number of students before some other number of students take it. Even though weíre all bound by the honor code, it does create a situation where there is some temptation. Itís possible it could be a little bit early without a lot of gap, but I donít think early enough to make a lot of help is the truth. We can talk about it. The current plan is not, I would say.

A little bit about compilers. We use C++ and we also use some custom libraries, which limits us to distributing on a certain number of platforms weíve had a good chance to test on and work with. The compilers that we have support for is X Code on the Macintosh. Anybody who has Mac OS10 can freely download that and install it.

Weíre using Microsoftís Visual Studio Version 2005 on Windows, and we have an arrangement with Microsoft where they have distributed the software free of charge to students, so if you would like to install that on your own Windows computer, weíll give you some handouts on Friday that tell you what to do to get the compiler and get it installed on your computer.

Our cluster computers in the dorms and the libraries and the lair have both the compilers and libraries installed, so if you work in a cluster, you donít have to do anything special. You just walk up and itís got the stuff ready to go. Iím a Mac person. Iíve been a Mac person forever. I canít get over the fact that you go to the start menu to shut the machine down. That makes Windows impossible for me to use. I would say campus wide, there are more Windows machines than Macs on campus, so if you want to take a popular vote, you could do that. If you want to be on the side of the Mac bigot, you can come and be with me in X Code.

Iíve got ten minutes to tell you a little bit about C++. That is the next journey that weíre going to go on together. The first question is why are we doing this to you? I just got comfortable with Java and now youíre telling me to throw away my Java and start over. Letís generate a little bit of love for C++. The advantages of early multilingualism Ė I have two small children at home that are two and four, and I read a lot about bilingualism. Itís very clear that for natural languages, when youíre acquiring a language at those young ages that that is the best time to introduce a second or third language.

Itís been looked at in terms of programming languages as well, that when you are learning a programming language, there are certain kind of ruts your mind gets into about the way a language is that is based on your early experiences. If you spend a very long time working only in one language, those ruts get deeper, and you have a certain way of thinking. Youíre a little bit stuck in that paradigm and its approach. Whatís easy to do in that language, whatís hard to do in that language tends to make a stronger impression on you in a way that makes it harder as you grow and explore the languages to kind of get out of those ruts and shake yourself out of it.

Thereís been some pretty good evidence that somewhere between one and two is a good time to think about branching out and starting to think about different ways of doing stuff and seeing some different syntax and some different ideas to help build in the flexibility from an early age in your career to buy you some strength later. Thatís part of what weíre doing.

Another part of it is actually that a lot of our upper division courses rely on a knowledge of C and C++, that family of languages, and that the longer we postpone it, the more painful it becomes. In the later courses where youíre learning about compilers or graphics or networking, they donít have the time in those classes to stop and teach you C or C++. They need you to know C++ to get the work done. Moving the foundation into a programming class seems to make the most sense in the context of our curriculum.

We do switch you over here. The good news is that itís not as big a change as it might sound at first glance. Java is actually highly derivative of C++ for a start. Theyíre kind of cousins in the scheme of language design. They have a lot of syntax. How much C++ do you need to know to start? The answer is zero. You donít even need to know what the word means. In fact, you actually probably know a surprising amount about C++ just by virtue of what you already know just translated a little bit.

Things like the four loop of Java or the way you declare variables or the way parameters are passed into a function is exhibited in Java in very much the same way it is in C++. There are a bunch of things you already know and you donít even realize. It is not assumed that you know C or C++. If you happen to already know those things, youíre ahead of the game. If you have not, then not to worry.

How much C++ are you going to learn? We will spend the first three or four lectures just talking about how things get expressed differently in C++ and mostly talking about the differences in the libraries. The syntax itself is quite similar. Some of the more extensive changes have to do with how the C++ string is operated on versus the Java string.

How you do file input and output reading in C++ is a little bit different than the way itís done in Java. Weíll spend some time saying here are some things you know how to express in one language. Weíre going to teach you how to express them in another language. Itís just mapping from your previous vocabulary onto a new one.

Along the way, we will actually introduce some of the C++ features that we need to support our pedagogical goals. Weíll be talking about how classes get designed in C++. Weíll see how to use classes. Weíll see how to define those classes, and weíll look at things like templates, which is the C++ construct for doing generics that you seen in Java Ė how you can build containers that are type unspecific and things like that.

We will learn a little bit of some of the fancier features of C++ like the pass by reference parameter, but thereís actually a very large amount of C++ thatís just off the table for us. We will not make extensive use of the standard template library or the fancier features of static and [inaudible] and a bunch of key words that mean nothing to you and should mean nothing to you. You will learn enough to have reading familiarity with C++ and to be able to express yourself quite well in the subset weíre using, but it is a subset of C++ that youíre being exposed to.

If you find yourself really wanting to master C++, we are offering CS106L. CS106L is a lab companion course that is open to students enrolled in 106B or 106X. It meets twice a week. Itís actually on Monday and Wednesday late afternoon. Itís 4:15 in Hewlett 103.

Itís being taught by a veteran section leader who is very well versed in C++ and who of his own volition volunteered and created this course because he himself was a little frustrated as a prior 106 student in wanting to get at some of those C++ things that werenít fitting with our goals. It is a place where you can get more exposure to standard C++, do some exercises that help you to test out those things and see how those things are expressed and get another unit. Itís a pass/fail lab course.

You can also just attend or grab the materials if you just want to look at them. Itís a great way to broaden that knowledge of C++ beyond whatís useful for us in terms of our goals. Iím going to ask you some questions, because I donít get to do all the talking. How much C++ do you need to know? Some of you may know nothing about it, and that is perfectly fine. Some of you probably know something about it or at least have heard something about it. Iím going to have you guys tell me what it is that people tell you about C++ that makes you either excited to learn it or frightened to learn it or interested in how it works.

Student: Itís what Java is based off of.

Instructor (Julie Zelenski): It is what Java is based off of. That should be a little reassuring that there is a syntax there that got adopted with some minor changes. It should feel more familiar than different when you look at it. It was very strongly influenced by a generation of programmers who C++ was their native language who designed the Java language. Thatís a good thing to know. What else do you know about C++?

Student: Itís extended C.

Instructor (Julie Zelenski): Yes. Itís extended C. Hereís how it fits in the spectrum. C is kind of a 1970s creation. C++ is a decade later. C is the language which it is based on. It is an extended C. Itís called a superset. Everything that compiles and works in C still exists in C++, but then they added a bunch of features. Not only did they add a bunch of features but they tried to fix some of the things about C++ by replacing existing things.

For example, thereís some string handling in C thatís kind of very primitive. They added a string object with much cleaner handling and safer semantics into the C++, but they kind of left the old one around. Some parts of C++ feel a little strange because of this history to it Ė the legacy of incorporating everything C was plus the stuff means at times thereís a little bit of weirdness there. It also means that the language, as a result, is very large. Cís safety and runtime features were extended by what got added in C++.

Student: A friend of mine told me that [inaudible].

Instructor (Julie Zelenski): Thatís a good thing to know. C++ might be a little bit more dangerous than Java. That is true. Java is very concerned with safety, in particular since Java was designed for web delivery of content. It was very important that the program have very constrained features on what it can and canít do, and so as a result, Java tends to be very parental. When you forget to initialize a variable or forget to return from a function, Javaís very aggressive about saying hey, youíve got to fix this.

C++ is a little less parental. Hereís the overly protective mom, helicopter mom, the ones who stand. Thatís Java. Javaís making sure Ė oh, are you okay, sweetie? Let me stand here in case you fall. C++ is crack mom. Sheís like yeah, Iím over here with my friends. Donít play with the kitchen knives. Itís a professionalís tool, and professionals donít want to feel encumbered. There are certain things they want to do that require some of this low-level access, and safety usually comes at a cost.

Any sort of feature where the language is double-checking for you is taking time and efficiency. Thereís a cost associated with that. Every time you want to get something out of an array, itís checked to make sure that that number was not off either end. Every array access costs you a little bit more. C++ says Iím not going to charge everybody that penalty. If you actually have the bad sense to write a program that does those things, you deserve to be punished. As a result, you will at some point in this quarter get to experience some of that firsthand.

Some of it is a growth experience. Some of it can be frustrating. It is part of what professional tools often look like. They are making these tradeoffs of efficiency over safety that put more of the work back on you as the programmer to be a little more attentive on those things. You can write programs that crash in very spectacular ways much more interesting and varied and dangerous than the kind of things you can do in Java. Good to know.

Instructor (Julie Zelenski): You want to use pointers. Youíre going to get to use pointers. Pointers are really neat, and theyíre also very challenging. Pointers are these ways of building these very flexible and amazing data structures Ė the kind of things that weíre going to try to build. At some point, they are going to be the only way to achieve those things well, so building these things called trees, graphs and lifts rely on understanding a mastery of the pointer type.

The pointer type is complicated, and itís part of that danger thing, which is having access to rearranging memory by virtue of addresses opens up a lot of opportunity for there to be mistakes. Mistakes can be made in the passive voice that have consequences. Youíll get to experience firsthand what thatís like. Thereís joy in it, because getting it right is awesome, and there are things that you can achieve that are really extraordinary with pointers, but when itís not working, it can be frustrating. Youíre getting a little bit of both.

It turns out C++ does not have a graphics system built into it. Java is actually distinguished from previous languages. Java tries to solve all problems. Traditionally, a programming language tends to have a set of libraries that have facilities for data management, reading and writing files and sometimes some networking, but they donít tend to actually solve application layer problems. That tended to be a different piece of technology. The Mac OS might offer a graphics library that was written in C++, but C++ the language didnít have a windowing system or graphics system.

C++ does not have those features itself, so any C++ compiler you get comes with these basic things about handling files and managing these types of data structures, but it does not come a priori with a bunch of graphics routines. That said, Windows and Mac and Linux and all these things have graphics routines that are written in C++, but theyíre all different. To say what are they like relative to Java? Theyíre all different relative to Java. Itís not standardized.

Thereís a wide variety of them out there, and they tend to have a lot of very impressive and different solved problems, because C++ has a longer history than Java that a lot of problems have been solved in C++ that are available to you, too. Thereís a lot of existing code other than what you might think is standard. I will see you on Friday, and weíll be seeing some C++. If you have questions about your situation, come and talk to me now.

[End of Audio]

Duration: 43 minutes