Return to Video

Lecture 1 | Programming Abstractions (Stanford)

  • 0:13 - 0:17
    This presentation is delivered by the
    Stanford Center for Professional Development
  • 0:26 - 0:30
    Hi! Welcome, welcome to CS106B,
    Programming Abstractions.
  • 0:30 - 0:33
    (maybe now our mic is on? Oh, that's iteresting.)
  • 0:34 - 0:37
    The website was probably the most important
    thing to take away from here,
  • 0:37 - 0:38
    where can you find information about the class
  • 0:38 - 0:40
    for the talk today and give some
    overview and stuff like that,
  • 0:40 - 0:42
    but this is the home base for all the material.
  • 0:42 - 0:45
    If you managed to get the handouts
    on the way in, you're golden.
  • 0:45 - 0:47
    Otherwise, you can grab them from the website.
  • 0:47 - 0:49
    There's a lot of background information,
    staff information,
  • 0:49 - 0:52
    office hours, all sorts of stuff gathered there.
  • 0:52 - 0:53
    It's kind of one stop shopping for
  • 0:53 - 0:56
    figuring things out about our course.
  • 0:56 - 0:57
    Let me tell you what I'm going to do today.
  • 0:58 - 1:00
    The first day of, I know a lot of you are shopping
  • 1:00 - 1:01
    trying to figure out what's the right fit for you,
  • 1:01 - 1:04
    so hopefully today, I'm going to
    try to give you some information that will
  • 1:04 - 1:05
    help you make a good decision.
  • 1:05 - 1:07
    I want to tell you a little bit
    of what our course is about,
  • 1:07 - 1:09
    tell you a little bit about the
    administration and logistics
  • 1:09 - 1:12
    most of that stuff is pretty ordinary,
    and you can read about it.
  • 1:12 - 1:13
    Of course, I have to do a little bit of marketing.
  • 1:13 - 1:15
    I get to give you my unbiased opinions
  • 1:15 - 1:17
    of why this is the absolute
    best class you could possibly take.
  • 1:17 - 1:20
    (I get paid per student, you know.)
  • 1:20 - 1:22
    (That's not true.)
  • 1:23 - 1:25
    Maybe we'll even have time to check out
  • 1:25 - 1:27
    a little bit of the C++ language
    before we're done and set today.
  • 1:27 - 1:30
    (and this needs to go away)
  • 1:31 - 1:33
    Let me tell you about CS106.
  • 1:33 - 1:37
    CS106 is the introductory programming
    sequence here at Stanford.
  • 1:37 - 1:40
    It's our version of CS1,
    where you start at the beginning
  • 1:40 - 1:43
    when you are interested in
    learning more about programming.
  • 1:43 - 1:46
    We have a two-quarter sequence,
    A and B, that kind of follow together.
  • 1:46 - 1:48
    They're not particularly tightly coupled, which is to say
  • 1:48 - 1:51
    if you took A and you took little a break, you could come back to B.
  • 1:51 - 1:54
    Or maybe you you actually took a variant of 106a type course
  • 1:54 - 1:59
    that is similar at another institution,
    you're probably in a fine place for starting mid stream.
  • 1:59 - 2:04
    We also have an alternate form of B, the CS106X, which is kind of an honors version of that second course.
  • 2:04 - 2:07
    So after you've taken that first course and you're feeling really jazzed up,
  • 2:07 - 2:11
    there is an alternative more intense way to get through the second course that's
  • 2:11 - 2:14
    offered. It's offered this quarter, in fact, so if you're
  • 2:14 - 2:17
    thinking actually about that, that is an option for you as well as
  • 2:17 - 2:18
    sticking with us.
  • 2:18 - 2:20
    What do we do in 106A?
  • 2:20 - 2:22
    'A's official title is programming methodology.
  • 2:23 - 2:25
    It is starting at the very beginning
  • 2:25 - 2:26
    and assuming you have no background in programming.
  • 2:26 - 2:29
    It's teaching you how it works,
  • 2:29 - 2:32
    what the languages look like, what the syntax is like, what things you need
  • 2:32 - 2:35
    to know about how to solve problems using a computer.
  • 2:35 - 2:38
    It covers a lot of the fundamentals about logic control
  • 2:38 - 2:41
    and in general, I think the big issues of 106A
  • 2:41 - 2:44
    have less to do with any particular syntax or
  • 2:44 - 2:46
    feature that you learn about a language but
  • 2:46 - 2:48
    about how do you solve problems on a computer?
  • 2:48 - 2:49
    Somebody gives you a specification of
  • 2:49 - 2:50
    you need to write a program that does X,
  • 2:50 - 2:52
    and you have to figure out how to make that happen,
  • 2:52 - 2:54
    how to break it down,
  • 2:54 - 2:57
    how to step through it, how to develop it, how to test it,
  • 2:57 - 3:00
    how to iterate on it, how to make changes in it later,
  • 3:00 - 3:04
    how to debug it when it's not working well,
  • 3:04 - 3:07
    and those things, (I think), transcend any particular language.
  • 3:07 - 3:09
    We happen to use the Java programming language in our 106A course
  • 3:09 - 3:13
    because it's a great tool for introductory programming,
  • 3:13 - 3:15
    but I don't think of that as being really critical.
  • 3:15 - 3:17
    In fact, if your introductory course was in some other language,
  • 3:17 - 3:19
    some other fairly modern, high level language
  • 3:19 - 3:20
    - let's say
  • 3:20 - 3:25
    you've learned in Python, C, Scheme, or something other than Java,
  • 3:25 - 3:28
    you're probably still fine, 'cause what we're really counting on in B is that you know how to
  • 3:28 - 3:30
    program and think like a computer scientist
  • 3:30 - 3:32
    know how to solve problems
  • 3:32 - 3:34
    Not a lot of the details of the syntax
  • 3:34 - 3:37
    are going to be important to us.
  • 3:37 - 3:40
    "B" picks up from there, saying okay, you've got some fundamentals.
  • 3:40 - 3:43
    Let's start really learning some of the techniques that extend the range of
  • 3:43 - 3:45
    problems you can solve.
  • 3:45 - 3:48
    We look at recursion, which is one of the fundamental
  • 3:48 - 3:50
    problem solving techniques that involves using
  • 3:50 - 3:52
    something akin to mathematical induction
  • 3:52 - 3:54
    to solve problems in terms of themselves.
  • 3:54 - 3:56
    Looking at a lot of algorithms for sorting
  • 3:56 - 3:57
    and searching and hashing and doing
  • 3:57 - 3:58
    things efficiently, knowing how to compare
  • 3:58 - 4:01
    and contrast alternatives in algorithms,
  • 4:01 - 4:04
    having some formalisms by which to discuss those things,
  • 4:04 - 4:08
    and learn some of the classics that are out there for solving these problems.
  • 4:08 - 4:11
    The dynamic data structure, which involves use of pointers to construct things
  • 4:11 - 4:14
    like lists, trees and heaps, graphs that
  • 4:15 - 4:18
    model certain structures that are very effective in solving certain kinds of
  • 4:18 - 4:20
    problems - we'll work through those.
  • 4:20 - 4:22
    A large part of our time is spent on this concept
  • 4:22 - 4:24
    of data abstraction, which is why
  • 4:24 - 4:27
    abstraction shows up as the main word in our title.
  • 4:29 - 4:31
    As we start to solve more and more complex problems,
  • 4:31 - 4:34
    the code itself can kind of become overwhelming if we don't have some
  • 4:34 - 4:36
    technique for managing that complexity.
  • 4:36 - 4:40
    One of the big themes for 106B is how we can use this idea of abstraction,
  • 4:40 - 4:42
    building something and dealing with the low level details but then
  • 4:42 - 4:44
    closing up the box and now treating it as a
  • 4:44 - 4:48
    a fixed entity and building on top of that
  • 4:48 - 4:49
    and then closing another layer around that
  • 4:49 - 4:52
    as a way of working on something, finishing it
  • 4:52 - 4:53
    moving on to some larger piece without
  • 4:53 - 4:56
    having those details clouding our way.
  • 4:56 - 4:59
    It's a very powerful technique for solving larger problems.
  • 4:59 - 5:00
    In that context,
  • 5:00 - 5:04
    we'll be looking at some of the classic data structures,
  • 5:04 - 5:06
    like stacks, queues, lists, maps and sets
  • 5:06 - 5:08
    as part of the domain for that.
  • 5:08 - 5:11
    We do happen to use the C++ programming language,
  • 5:11 - 5:14
    but this is not a C++ course, so to be clear about what you're
  • 5:14 - 5:16
    getting versus what you wanted,
  • 5:16 - 5:18
    we use Java here (as a vehicle) [a].
  • 5:18 - 5:20
    We use C++ here (as a vehicle) [b].
  • 5:20 - 5:23
    We happen to think there are good reasons
  • 5:23 - 5:24
    to actually expose you to both languages.
  • 5:24 - 5:26
    (ill talk about that more later)
  • 5:26 - 5:29
    In particular, C++ is an enormous language.
  • 5:29 - 5:31
    It has a lot of language features as well as
  • 5:31 - 5:32
    a very very large standard library,
  • 5:32 - 5:34
    and our goal is not at all
  • 5:34 - 5:36
    to turn you into this industrial strength
  • 5:36 - 5:37
    knows every detail about quirks
  • 5:37 - 5:38
    and ins and outs of C++.
  • 5:39 - 5:41
    There is another class, 193D, that
  • 5:41 - 5:43
    does attempt to do that.
  • 5:43 - 5:45
    In fact, if that's what you're looking for,
  • 5:45 - 5:47
    I suggest you take a look at that.
  • 5:47 - 5:48
    What we're here about is learning
  • 5:48 - 5:50
    advanced programming techniques
  • 5:50 - 5:52
    taking those foundations and building on them
  • 5:52 - 5:54
    to be able to solve more interesting problems.
  • 5:54 - 5:55
    We happen to use C++.
  • 5:55 - 5:56
    You will learn some C++, but I almost
  • 5:56 - 5:58
    consider it a side effect
  • 5:58 - 6:00
    of what we're doing.
  • 6:04 - 6:06
    Just a little note on placement
  • 6:06 - 6:09
    if you're kind of in between and not really sure,
  • 6:09 - 6:13
    these are the very very rough guidelines, but they give you
  • 6:13 - 6:17
    some idea of which groups gravitate where.
  • 6:17 - 6:18
    If you are new to programming or
  • 6:18 - 6:20
    you're not confident about your background
  • 6:20 - 6:22
    - maybe it was a long time ago, if it was self-taught.
  • 6:22 - 6:23
    Maybe it was in a course that you
  • 6:23 - 6:25
    felt was not as good as it could have been
  • 6:26 - 6:27
    or you didn't do as well in it,
  • 6:27 - 6:29
    106A is a great place to start.
  • 6:29 - 6:31
    It actually is by all accounts
  • 6:31 - 6:34
    an extremely popular course at Stanford
  • 6:34 - 6:36
    and services a wide group of people
  • 6:36 - 6:39
    with a little bit of background or no background.
  • 6:39 - 6:42
    All very well getting them up to speed.
  • 6:42 - 6:45
    If you do have something like a solid first course experience
  • 6:45 - 6:47
    So you did well in 106A or took a similar course
  • 6:47 - 6:49
    or perhaps even self-taught your way
  • 6:49 - 6:53
    through a lot of those materials and you feel ready to move on, 106B.
  • 6:53 - 6:55
    An AP course in high school -
  • 6:55 - 6:59
    the A curriculum is a pretty good match for 106A here
  • 6:59 - 7:00
    so you're in a great place.
  • 7:00 - 7:02
    If you have this and you've got a little bit more going for you
  • 7:02 - 7:04
    or you're super enthused and you have a
  • 7:04 - 7:06
    lot of extra time this quarter
  • 7:06 - 7:09
    and want to sit in the company of only
  • 7:09 - 7:11
    the uber geeks,
  • 7:11 - 7:13
    you can check out 106X,
  • 7:13 - 7:15
    Which is a varient of B
  • 7:15 - 7:17
    which covers the same kind of topical ground
  • 7:17 - 7:18
    but at a different level intensity.
  • 7:18 - 7:20
    It amps up a little bit of the assignments,
  • 7:20 - 7:23
    covers some of the material that we won't get a chance to cover,
  • 7:24 - 7:25
    and
  • 7:25 - 7:27
    just pushes the envelope a little bit there.
  • 7:27 - 7:30
    If you have experience comparable to the first two courses
  • 7:30 - 7:31
    - you've
  • 7:32 - 7:34
    done all the things that we're talking about here in B
  • 7:34 - 7:35
    and you feel comfortable with it,
  • 7:35 - 7:37
    it might be that the right place for you is 107,
  • 7:37 - 7:40
    which is the third course in our sequence.
  • 7:40 - 7:43
    And just skipping over our 106 courses entirely
  • 7:44 - 7:46
    That's somewhat rare,
  • 7:46 - 7:47
    so if you're thinking about that, I encourage you to
  • 7:47 - 7:49
    talk to me a little bit to make sure
  • 7:49 - 7:51
    that you won't be missing out on something important
  • 7:51 - 7:54
    in doing so, but certainly there are students who have
  • 7:55 - 7:57
    for example, the AP CS A-B curriculum
  • 7:57 - 7:59
    is pretty comparable to this course here,
  • 7:59 - 8:03
    and so depending on how high quality the course you had was,
  • 8:03 - 8:04
    it might very well be that 107 is right.
  • 8:04 - 8:06
    In some situations where that course was a little bit lacking,
  • 8:06 - 8:09
    there may be some ways that we can help reinforce
  • 8:09 - 8:11
    the things you've learned and build a stronger foundation
  • 8:11 - 8:14
    to move forward from rather than jumping ahead.
  • 8:15 - 8:18
    Any questions about placement?
  • 8:20 - 8:22
    That sort of thing.
  • 8:22 - 8:24
    (Am I talking too fast?)
  • 8:24 - 8:27
    (good, I like that, you can sit in the front whenever you want)
  • 8:28 - 8:30
    Lets talk philosophy
  • 8:30 - 8:34
    I think there's a statement about what we officially are,
  • 8:34 - 8:38
    but I also think that 106 has a long tradition at Stanford
  • 8:38 - 8:40
    that comes back from student motivation.
  • 8:41 - 8:43
    I was here as an undergrad in the 80s
  • 8:43 - 8:45
    when 106s were just getting off the ground,
  • 8:45 - 8:47
    and at the time, Stanford only had a graduate
  • 8:47 - 8:49
    computer science department, and
  • 8:49 - 8:52
    the belief in the nsaid period for computer science
  • 8:52 - 8:54
    was you should get a math degree,
  • 8:54 - 8:55
    and only then would you be mature enough
  • 8:55 - 8:57
    to learn about computers.
  • 8:57 - 9:00
    You weren't ready as a freshman.
  • 9:00 - 9:02
    was a groundswell of Stanford students
  • 9:02 - 9:05
    were like said 'We want access to programming. We want it.'
  • 9:05 - 9:06
    That made it happen.
  • 9:06 - 9:09
    and so part of the 106 was a really careful thought about what the 106's
  • 9:09 - 9:12
    would be a Stanford and what we want them to be
  • 9:12 - 9:14
    in a philosophical sense.
  • 9:14 - 9:16
    One is that we welcome students of
    all majors and backgrounds.
  • 9:16 - 9:19
    We don't have a version of 106 that's for the majors or
  • 9:19 - 9:21
    potential majors and a version that's for the non-majors
  • 9:21 - 9:24
    and a version that's terminal (you just want to get out of here).
  • 9:24 - 9:27
    We really think that we can bring you all together
  • 9:27 - 9:31
    and design a course that addresses this wide
  • 9:31 - 9:33
    disparate group but still service that well.
  • 9:33 - 9:36
    Partly because you don't know that
    you are a CS major yet.
  • 9:36 - 9:39
    I'm going to turn you into a CS major.
    That's my plan.
  • 9:39 - 9:42
    At Stanford right,
    not having to make that choice about a major
  • 9:42 - 9:44
    until into junior year is a gift
  • 9:45 - 9:49
    to allow you to explore
    and to feel unencumbered by having made some
  • 9:49 - 9:51
    decision when you applied,
    and I think it's important to respect that
  • 9:51 - 9:54
    gift that Stanford gave you by
    trying to make sure our courses don't
  • 9:54 - 9:56
    funnel you one way or
    the other before you figure it out.
  • 9:57 - 9:58
    You are all welcome here.
  • 9:58 - 10:00
    We try to make it accessible to everyone.
  • 10:00 - 10:03
    We have certain plans
    that help to make that work.
  • 10:03 - 10:07
    We do try to provide a solid,
    practical foundation in programming
  • 10:07 - 10:11
    that given our placement at Stanford
    in the middle of the Silicon Valley,
  • 10:11 - 10:14
    there's kind of a strong influence
    for us to try to produce students
  • 10:14 - 10:16
    who from the get go are
  • 10:16 - 10:18
    learning things that are actually quite useful
  • 10:18 - 10:19
    outside of the classroom
  • 10:19 - 10:22
    rather than teach you a very academic
  • 10:22 - 10:24
    interesting and mathematical
    language like Scheme
  • 10:24 - 10:27
    that is very
  • 10:27 - 10:29
    rarely used outside of the classroom.
  • 10:29 - 10:31
    We're trying to teach you on the tools,
  • 10:31 - 10:34
    languages and techniques that are actually in active practice.
  • 10:34 - 10:38
    We are using Java and C++,
    two of the most prevalent languages
  • 10:38 - 10:40
    out in the industry, and
    we do a lot of learn by doing.
  • 10:40 - 10:42
    We assign challenging, full-fledged
    programs that you work on and you build
  • 10:42 - 10:47
    and so it's not designed to be
    academic exercises.
  • 10:47 - 10:54
    You really are building skills
    that have applicability here and
    outside of the class.
  • 10:55 - 10:58
    We have a big emphasis on
  • 10:58 - 10:59
    truth and beauty.
  • 11:01 - 11:04
    This is one area in which some of the
    substitute courses
  • 11:04 - 11:07
    that we have seen students come in with
    have a little bit more trouble with
  • 11:07 - 11:10
    is tackling this part of it,
    which is that there are
  • 11:10 - 11:12
    a lot of ways you can get a program to work.
  • 11:12 - 11:14
    Many of them are not pretty.
  • 11:14 - 11:17
    You can just type and type and type and
    (Monkies shakespeare, whatnot)
  • 11:17 - 11:19
    eventually, you can get your way to
    something that works.
  • 11:19 - 11:23
    Well +1, -1, what if I move it here
    what if I copy and paste this there
  • 11:23 - 11:25
    what if I change that name?
  • 11:25 - 11:27
    That, in the end,
    might produce a program that from
  • 11:27 - 11:28
    external appearances works.
  • 11:28 - 11:34
    It plays hangman, or whatever was the
    desired goal, but that internally is a mess.
  • 11:34 - 11:37
    It's not well structured.
    It's not well commented.
  • 11:37 - 11:40
    It's not easy to understand.
    It wouldn't be easy to modify.
  • 11:40 - 11:42
    It makes a lot of decision that are really sub optimal,
  • 11:42 - 11:48
    and we're really interested in producing
    engineers
  • 11:48 - 11:52
    that have a good sense of design and
    really appreciate what is involved in writing
  • 11:52 - 11:56
    good, well designed software,
    not just working software.
  • 11:56 - 11:57
    We will be giving you feedback on
  • 11:57 - 12:00
    both the correctness and
    functionality of your code
  • 12:02 - 12:05
    as important if not more so,
  • 12:05 - 12:08
    also on how well we think you did
    at designing and implementing and
  • 12:08 - 12:11
    writing code that is of
    a high quality.
  • 12:11 - 12:12
    We make a big deal out of that.
  • 12:12 - 12:14
    That is something that is not
    always shared by other classes,
  • 12:14 - 12:17
    and so in particular, someone who is self-taught
  • 12:17 - 12:20
    or in a class that didn't emphasize this
    might feel that there's a little bit of a gap there
  • 12:20 - 12:21
    we need to make
    that up with you,
  • 12:21 - 12:23
    and we can work with you.
  • 12:23 - 12:26
    This is a very individual thing,
    because there's not one good example of
  • 12:26 - 12:28
    the perfect style
  • 12:28 - 12:31
    in the way that a lot of different people
  • 12:31 - 12:34
    express themselves in written communication
  • 12:34 - 12:35
    very well but differently.
  • 12:35 - 12:36
    The same thing is true about programs.
  • 12:36 - 12:40
    You will have your own unique style,
    and we'll work with you to coach you on getting your
  • 12:40 - 12:44
    style to come through and
    be beautiful and elegant.
  • 12:46 - 12:50
    This kind of comes back to point 1
    we make heavy use of undergraduate
  • 12:50 - 12:53
    section leaders as mentors in this program.
  • 12:53 - 12:59
    We have a staff of 50 or so, undergraduates
    who work with the 106A, B and X courses as a team.
  • 12:59 - 13:02
    They have specific responsibilities with their section,
  • 13:02 - 13:06
    so mentoring and grading and meeting with
  • 13:06 - 13:09
    sectionees to give individualized
    feedback on their programs
  • 13:09 - 13:10
    as well as
  • 13:10 - 13:14
    answering questions, solving problems,
    being in the lair 30 plus hours.
  • 13:14 - 13:16
    They're most weekday nights about six hours
  • 13:16 - 13:17
    and often
  • 13:17 - 13:20
    well past the midnight when it's supposed to cut off
    solving people's problems,
  • 13:20 - 13:23
    helping when you get stuck,
    answering your questions
  • 13:23 - 13:26
    and making sure you're all
    making forward progress.
  • 13:26 - 13:29
    That comes back to point 1.
  • 13:29 - 13:31
    In some universities where they're
    choosing to use their intro course as a weeder,
  • 13:31 - 13:34
    it's like let's separate the wheat
    from the chaff early
  • 13:34 - 13:35
    and let's make it really hard and not
  • 13:35 - 13:38
    provide too much support,
    and that way we'll make sure we get the people we want.
  • 13:38 - 13:41
    We have a different idea.
  • 13:41 - 13:42
    Programming is hard,
    especially when you're learning.
  • 13:42 - 13:46
    There's a lot of complexity to master,
    and there are a lot of details that can
  • 13:46 - 13:49
    interfere with moving forward,
    and we don't want you
  • 13:49 - 13:52
    to get stuck on something that
    we can very easily resolve for you.
  • 13:52 - 13:56
    So make sure you have accessible
    staff members in person, in email
  • 13:56 - 13:58
    and regularly in section
  • 13:58 - 14:04
    to help get through the roadblocks
    and keep you moving forward.
  • 14:04 - 14:08
    What do you need to know to be
    sure you're going to do well?
  • 14:08 - 14:12
    There are people who think to
    be a good computer programmer,
  • 14:12 - 14:16
    you need to be good at math,
    logic, and drinking Jolt.
  • 14:16 - 14:22
    I think it it comes down to
    personality traits than any
  • 14:22 - 14:24
    particular technique or skill.
  • 14:24 - 14:26
    You don't need to be good at math.
  • 14:26 - 14:29
    How much calculus and trig shows up in this?
  • 14:29 - 14:32
    Not very much.
    A little bit of logic - that helps.
  • 14:32 - 14:37
    I think it comes down to traits like
    curiosity and determination and hard work.
  • 14:37 - 14:38
    Starting early,
  • 14:38 - 14:41
    asking questions
    when you don't understand something,
  • 14:41 - 14:44
    trying to solve the problem by logic
    I think is very valuable
  • 14:44 - 14:45
    Knowing how to think,
    how to make steps
  • 14:45 - 14:48
    why this case works and
    why that case doesn't work
  • 14:48 - 14:52
    thinking about that logically
  • 14:52 - 14:56
    (well its like the movie theater now you guys will all go to sleep)
    (oh look they came back) [lights]
  • 14:57 - 15:01
    I think these are the skills
    that serve you the best in this class
  • 15:01 - 15:04
    And probably
    every other thing you'd want to tackle.
  • 15:04 - 15:08
    There is a lot of time that will be spent
    to master this.
  • 15:08 - 15:11
    I can talk about programming all I want,
    (bla, bla, bla)
  • 15:11 - 15:13
    and you can go oh, yeah, that makes a
    lot of sense.
  • 15:13 - 15:16
    But when you go to write it yourself,
    it's a very different experience.
  • 15:16 - 15:20
    That's where being
    focused and staying on task
  • 15:20 - 15:25
    and getting help when you get stuck
    can help you move through that
  • 15:25 - 15:28
    (Any questions about 106?)
    (What we do,)
  • 15:28 - 15:32
    (Why we do what we do.)
    (You guys have nothing to say)
  • 15:32 - 15:34
    (your afraid of having your)
    (voice recorded aren't you?)
  • 15:34 - 15:39
    (For all time your parents will come and see)
    (that you come to class you can prove it)
  • 15:40 - 15:44
    My unbiased opinion about why 106B is
    one of the best courses at Stanford
  • 15:44 - 15:47
    (of course I am not at all unbiased)
  • 15:47 - 15:50
    it's going to be
  • 15:50 - 15:53
    totally obvious when I say these things,
    and you guys are going to have to go
  • 15:53 - 15:55
    along with it.
    I'm actually a
  • 15:55 - 15:58
    geek, really big time,
    and I happen to love programming.
  • 15:58 - 16:00
    That's why I'm a perfect fit for teaching this class.
  • 16:00 - 16:01
    I have taught 106 B or X more than I've taught
  • 16:01 - 16:04
    any other class that I've taught at
    Stanford in my time here,
  • 16:04 - 16:06
    and that's because each quarter
    when we're setting the schedule,
  • 16:06 - 16:08
    I say give me B.
    Give me X.
  • 16:08 - 16:09
    Because there's no better course to teach.
  • 16:09 - 16:12
    Programming is just awesome.
  • 16:12 - 16:15
    If you love programming,
    I think there's almost nothing better to do in the world.
  • 16:15 - 16:18
    You have this task.
    You're trying to get there.
  • 16:18 - 16:19
    You're coding.
    You're making stuff happen.
  • 16:19 - 16:22
    You're testing, iterating you're running.
    You see stuff.
  • 16:22 - 16:25
    You build things.
    When you're done, you know it works.
  • 16:25 - 16:28
    That feeling when you write a paper and go
    "was it good enough?"
  • 16:28 - 16:30
    "well I dont know"
    you could probably go bolster up this argument
  • 16:30 - 16:32
    When a program works,
    you know it.
  • 16:32 - 16:36
    It does what it's supposed to do.
    It gets the right answer.
  • 16:36 - 16:38
    It plays the game.
    It solves the problem.
  • 16:38 - 16:42
    Finding and fixing that last bug
    - although debugging is one of the last
  • 16:42 - 16:45
    aspects of programming a lot of people bemoan about;
    I happen to think that if you
  • 16:45 - 16:49
    are driven by debugging,
    that is one of the most awesome detective stories
  • 16:49 - 16:54
    Trying to figure out why it happened when you did this,
    when you moved that why it went this way
  • 16:54 - 16:57
    and what this effect caused
    and understanding once you make the fix how it fixes it
  • 16:57 - 16:59
    staying up late.
  • 16:59 - 17:02
    I have stayed up late more nights debugging
    than anything else in my life,
  • 17:02 - 17:04
    and I'm not sad about that at all.
  • 17:04 - 17:08
    That means I'm in the right place.
    Hopefully, some of that resonates with you.
  • 17:09 - 17:12
    If that sounds really awful to you,
  • 17:12 - 17:14
    hopefully we can change your mind a bit.
  • 17:14 - 17:18
    That is, in some ways,
    part of what drives computer science is this
  • 17:18 - 17:21
    wanting to build things.
    We are engineers.
  • 17:21 - 17:24
    We have this computer science name.
    Just remember
  • 17:24 - 17:29
    - any subject
    that's name is something science is not a science.
  • 17:29 - 17:32
    We're trying to puff ourselves up a bit.
  • 17:32 - 17:34
    We do a lot of really great work,
  • 17:34 - 17:37
    and there are a lot of neat scientific
    principles and theories that
  • 17:37 - 17:38
    underpin what we do,
  • 17:38 - 17:41
    but in the end,
    I think what drives a lot of us is just
  • 17:41 - 17:45
    the engineering
    - building stuff that is really neat.
  • 17:45 - 17:49
    It kind of reminds me that my
    husband's a mechanical engineer, and so I
  • 17:49 - 17:52
    used to be envious, because
    he would always build things.
  • 17:52 - 17:57
    M.E.'s always toting foam core around the campus
    on their paper bicycles and stuff, and it's like
  • 17:57 - 18:00
    they build all these things.
    Now, having watched all the things he builds, it's like
  • 18:00 - 18:02
    mechan-e is really hard.
    You need all these materials.
  • 18:02 - 18:05
    You need all these tools.
    You need this mill, you need this lathe
  • 18:05 - 18:07
    You need the hotmelt glue gun,
    which burns the heck out of your fingers
  • 18:07 - 18:08
    anytime you touch it.
  • 18:08 - 18:11
    To build anything.
  • 18:11 - 18:13
    In computer science, you don't need anything.
  • 18:13 - 18:14
    You need a compiler and you need a computer.
  • 18:14 - 18:15
    You need your thought.
  • 18:15 - 18:18
    It's like an abstraction we built out of our brains.
  • 18:18 - 18:20
    There's this relatively small set of things
    that you need to master
  • 18:20 - 18:24
    and then you can combine them in these very
    sophisticated and interesting ways to solve all sorts of problems.
  • 18:24 - 18:26
    There's a very low overhead,
  • 18:26 - 18:30
    and the range of things you can attack
    with the same set of skills is huge.
  • 18:30 - 18:36
    Every domain out there can benefit from somebody
    applying computers in a useful way without fail.
  • 18:36 - 18:39
    There's all sorts of problems
    where technology is part of the answer
  • 18:39 - 18:41
    not the only answer,
    but certainly something that you can take
  • 18:41 - 18:44
    whatever interest you have
    and combine it with computer science
  • 18:44 - 18:47
    and construct something cool.
  • 18:47 - 18:51
    I happen to think that what
    happens in the second course is amazing.
  • 18:51 - 18:54
    The first course,
    you've kind of got to get up to speed,
  • 18:54 - 18:57
    and there's a lot of basic material
    that needs to get covered,
  • 18:57 - 19:00
    and it does set you on the right path,
    but in this course, we really
  • 19:00 - 19:04
    get to blossom beyond the basic things.
  • 19:04 - 19:07
    There are a bunch of really neat
    and very accessible techniques
  • 19:07 - 19:11
    that a second quarter student can understand
    and master and do really cool things with.
  • 19:11 - 19:14
    You can learn how to do something like
    create a database
  • 19:14 - 19:17
    that has a million entries
  • 19:17 - 19:21
    and then ask for somebody by name and be able to
    instantaneously be able to find that name.
  • 19:21 - 19:23
    Not by looking through a million
    entries trying to find that name
  • 19:23 - 19:26
    Change the size of it.
    Make it ten million, a billion, and still be able to
  • 19:26 - 19:29
    provide that kind of instantaneous access.
    You're going to learn how to do that.
  • 19:29 - 19:32
    The technique is not some superhuman thing.
  • 19:32 - 19:34
    It's something very clever, admittedly,
  • 19:34 - 19:36
    but it's very accessible.
  • 19:36 - 19:40
    Taking that same million thing and
    learning how to sort it efficiently.
  • 19:40 - 19:42
    What if you happen to know things about how it's
    almost sorted but just a little but out of sorts?
  • 19:42 - 19:47
    Are there ways you can actually make it
    even faster to put it in sorted order?
  • 19:47 - 19:50
    There are techniques, for example,
    like recursion that take on problems that
  • 19:50 - 19:53
    you might not have any idea when you
    first look at the problem how to solve
  • 19:53 - 19:57
    but once you've got your head around recursion,
    you can look at that and say
  • 19:57 - 20:01
    "I can write a five line function
    that will solve that problem."
  • 20:01 - 20:06
    This is the kind of power we're going to
    give you with our quarter together.
  • 20:06 - 20:10
    There's a bunch of really amazing
    theoretical and algorithmic stuff to explore.
  • 20:10 - 20:14
    That really increases the kind of things
    you can do with programming.
  • 20:14 - 20:18
    I'm particularly fond of it.
  • 20:18 - 20:20

    As always, I think
  • 20:20 - 20:23
    the section leading program that we have
    created and built at Stanford
  • 20:23 - 20:27
    Is a huge part of what makes our 106
    courses so successful,
  • 20:27 - 20:28
    and so
  • 20:28 - 20:33
    having somebody who's individually
    working with you, meeting with you weekly
  • 20:34 - 20:37
    and giving you that feedback that's
    individualized and personalized for you
  • 20:37 - 20:41
    and helping you get through the rough spots
    is a lot of what helps to make the experience
  • 20:41 - 20:44
    very fun and very personal, too.
  • 20:44 - 20:49
    What section leaders do I have here?
    Any? Not a one.
  • 20:49 - 20:52
    Those fabulous section leaders.
    Where are they again? section leaders?
  • 20:52 - 20:54
    Did i say they were fabulous?
    I meant. laughs Uhh no.
  • 20:54 - 20:57
    We haven't yet identified who's going
    to what class, so maybe they're all
  • 20:57 - 21:01
    thinking they're going to go somewhere else,
    but they're wrong. We'll get some.
  • 21:04 - 21:05
    106B - great. You agree?
  • 21:05 - 21:07
    Have I convinced you?
  • 21:07 - 21:10
    Is anybody still hesitant?
  • 21:13 - 21:16
    Is it a lot of work?
    Oh, no. laughs
  • 21:16 - 21:19
    I just exude it. Osmosis. you learn it.
  • 21:22 - 21:25
    Let me tell you a little bit about logistics.
  • 21:26 - 21:30
    There are some random things you may want
    to know about how the class works.
  • 21:30 - 21:34
    That the first day I am supposed to do.
  • 21:34 - 21:38
    We're going to meet here
    Monday, Wednesday, Friday 2:15 to 3:05.
  • 21:38 - 21:42
    In glorious download
    [ FIXME ] audiotorium
  • 21:42 - 21:45
    It looks like we almost
    exactly fit in our classroom,
  • 21:45 - 21:48
    which means we're all
    going to be very friendly and cozy.
  • 21:48 - 21:51
    The lectures are being taped
    and are available online,
  • 21:51 - 21:57
    and so that has the neat side effect that
    you can watch them and review them later.
  • 21:57 - 21:58
    You could watch them lots of times.
  • 21:58 - 22:01
    It also means that if it were pouring rain and
    you were sitting at home in your bunny slippers,
  • 22:01 - 22:04
    you could just say hey,
    I'm not going outside and you could
  • 22:04 - 22:06
    turn on your computer and watch.
  • 22:06 - 22:09
    I'm a big fan of having you come in person.
    That's because I don't want to
  • 22:09 - 22:11
    lecture to an empty room.
  • 22:11 - 22:14
    I also think there's an interaction there
  • 22:14 - 22:19
    that I'm fond of, and so I hope that you
    will make every effort to attend in person
    as much as you can.
  • 22:22 - 22:27
    It is nice to know that if you do miss a lecture or you
  • 22:27 - 22:30
    get caught up with something, you'll have a chance to review it later online.
  • 22:30 - 22:32
    We will have sections that will meet once a week,
  • 22:32 - 22:35
    just like 106A.
  • 22:35 - 22:38
    The section leader who meets with you is the one
  • 22:38 - 22:41
    who will be grading your programs and sitting with you
    and doing the conferences.
  • 22:41 - 22:46
    What you need to do to get yourself
    into a section - there are several section times listed.
  • 22:46 - 22:48
    They are totally bogus. (so ignore that)
  • 22:51 - 22:53
    What you do is you go to the online
    - if you go to our class webpage, there's a link that tells
  • 22:53 - 22:56
    you how to sign up for a section.
    The section times aren't up right now, but they will go up tomorrow,
  • 22:56 - 22:58
    and they'll be up through the weekend.
    You go in and put in your preferences
  • 22:58 - 23:04
    about what times fit your schedule or not,
    and there's this big computer program
  • 23:04 - 23:09
    that does this magic matching that gets
    everyone into a section that fits their schedule.
  • 23:09 - 23:12
    That will happen early next week.
  • 23:14 - 23:19
    The signups will be up from Thursday at 5:00
    until Sunday at 5:00.
  • 23:19 - 23:22
    If by Sunday at 5:00
    you've got your schedule fixed, then you're fine.
  • 23:22 - 23:25
    If you happen to change after Sunday at 5:00 and after the assignments have been made,
  • 23:25 - 23:27
    at that point, it's a little bit harder.
  • 23:27 - 23:28
    We can make adjustments, but it's on a very case-by-case basis.
  • 23:28 - 23:31
    Where we have space and where we can accomodate you.
  • 23:31 - 23:33
    The best thing you can do
  • 23:33 - 23:36
    is by Sunday at 5:00 have a pretty firm idea
    about what you can and can't do.
  • 23:36 - 23:37
    There's a list of preferences,
    so maybe what you can do
  • 23:37 - 23:40
    is pick things that you know will work no matter
  • 23:40 - 23:41
    what happens.
  • 23:41 - 23:44
    for antyhing that is variable if you just dont offer things that you know might
  • 23:44 - 23:45
    go away
  • 23:45 - 23:50
    so there is a list of 20 times and you say I can make these 5
  • 23:50 - 23:52
    And that way you wont get yourselves in trouble
  • 23:52 - 23:55
    in things that might change.
  • 23:55 - 23:59
    The workload - everybody wants
    to know how much work.
  • 23:59 - 24:02
    It's a five-unit class, and
    it's a five unit engineering class.
  • 24:04 - 24:06
    You get your five units worth,
  • 24:06 - 24:10
    I would say, so don't worry about that. I won't shortchange you.
  • 24:11 - 24:15
    We have programming assignments not quite weekly.
    I think there are seven of them across
  • 24:15 - 24:19
    ten weeks, so you can calculate it out.
    It's about a week and a third
  • 24:19 - 24:20
    for any particular one.
  • 24:20 - 24:22
    The students report
  • 24:22 - 24:25
    that it's about a 15-20 hour project, each of them.
  • 24:25 - 24:28
    Some people get them done in less than that.
    Some people take a little bit more.
  • 24:28 - 24:33
    I would say that's kind of the
    mode range for what people are reporting.
  • 24:33 - 24:37
    I do think that of the people who report less,
    some of those are
  • 24:37 - 24:41
    people who are naturally gifted,
    but a lot of it has to do with your habits
  • 24:41 - 24:43
    about how you work and
    how you make progress, so
  • 24:43 - 24:46
    if you are one of the people who feels
    you might be more likely to be on the other
  • 24:46 - 24:49
    end, you can come and talk to
    me and I can give you some suggestions.
  • 24:49 - 24:56
    Choosing to work in the lair where the
    helpers are on duty has really positive effects
  • 24:56 - 24:58
    effects in that when you get stuck,
    you have easy access to
  • 24:58 - 24:59
    somebody helping you work through it
  • 24:59 - 25:02
    rather than spending an hour or two
    fighting something that turns out to be
  • 25:02 - 25:05
    simple but required knowing something
    that you didn't yet know.
  • 25:05 - 25:10
    I'm a big fan of learning things yourself.
    There's also a time when a well-placed
  • 25:11 - 25:14
    bit of advice from somebody
    can save you a lot of time.
  • 25:15 - 25:22
    There will be a midterm and a final exam.
    They'll both be in class, open book, open notes.
  • 25:22 - 25:24
    The midterm is actually technically out of class.
  • 25:24 - 25:29
    have it at night because we need more than
    a 50-minute period to get any coverage of that.
  • 25:29 - 25:31
    Our final exam is scheduled in
    our university-scheduled slot.
  • 25:31 - 25:36
    Sadly, that is at the very
    end of the exam week,
  • 25:36 - 25:38
    but that's when the registrar put us,
    and that's when we need to go.
  • 25:38 - 25:44
    You may want to take a look at that before
    you head off to Acapulco for spring break.
  • 25:44 - 25:45
    you need to make sure
    you are here for the exam.
  • 25:45 - 25:49
    Male audience: Is the course leader available online?
  • 25:49 - 25:53
    Unfortunately, our publisher will not allow me to distribute the course leader electronically.
  • 25:54 - 25:57
    They're not exactly very in the modern age on this.
  • 26:00 - 26:02
    I'm working on it is the truth.
  • 26:02 - 26:06
    By the time the world sees this, hopefully, we will have some other strategy.
  • 26:06 - 26:09
    We currently are in negotiations.
  • 26:09 - 26:11
    The nice thing about the course reader is that
    we have not changed it in the last year.
  • 26:11 - 26:14
    If you know somebody who has
    it from last fall or last spring.
  • 26:14 - 26:18
    it has some minor edits and typos that were fixed,
  • 26:18 - 26:20
    so if you can get a hold of an old one, it's good.
  • 26:20 - 26:23
    We are getting no royalties on it.
  • 26:23 - 26:27
    We're publishing it at production cost, so where it
  • 26:27 - 26:32
    would have been a $100.00 textbook
    had it been bound and all snappy.
  • 26:32 - 26:36
    you're just getting what it cost to photocopy and bind the thing, and Eric and
  • 26:36 - 26:40
    I are eating ramen.
  • 26:40 - 26:42
    It's hopefully cheap enough that
  • 26:42 - 26:44
    you can find a way to get to one
  • 26:44 - 26:48
    or get an old one without it being
    too much of an obstacle.
  • 26:49 - 26:53
    People in general find the course
    reader to be an asset.
  • 26:53 - 26:54
    We do say it's required reading.
  • 26:54 - 26:59
    It does have a lot of material that's very
    useful in understanding the course.
  • 26:59 - 27:02
    There are other people who
    don't make as big a use of it,
  • 27:02 - 27:05
    but there are some sections that
    are really very valuable
  • 27:05 - 27:08
    and other ones that may be more
    or less depending on your learning style.
  • 27:08 - 27:12
    Whether you appreciate more of a chance to
    read background material and more examples.
  • 27:12 - 27:15
    There's also a lot of good sample problems in it
  • 27:15 - 27:19
    and review questions in it that help to test your understanding.
  • 27:22 - 27:23
    You know, it's tricky, because the university
    in general discourages you from giving
  • 27:26 - 27:29
    alternate exams because of
  • 27:29 - 27:33
    - you can imagine the issues
    of having an exam that has been
  • 27:33 - 27:35
    seen by some number of students before
    some other number of students take it.
  • 27:35 - 27:38
    Even though we're all bound by the honor code,
    it does create a situation where
  • 27:38 - 27:39
    there is some temptation.
  • 27:39 - 27:43
    It's possible it could be a little bit
    early without a lot of gap, but I
  • 27:43 - 27:46
    don't think early enough to make alot
    of help is the truth.
  • 27:46 - 27:49
    We can talk about it.
    The current plan is not, I would say.
  • 28:03 - 28:08
    A little bit about compilers.
    We use C++.
  • 28:08 - 28:09
    and we also use
  • 28:09 - 28:11
    some custom libraries, which limits us
    to distributing on a certain number of platforms
  • 28:11 - 28:15
    we've had a good chance to
    test on and work with
  • 28:15 - 28:19
    The compilers that we have
    support for is X Code on the Macintosh.
  • 28:19 - 28:22
    xcode is apples free developer tools so
  • 28:22 - 28:25
    Anybody who has Mac OS 10 can freely
    download that, and install our libraries.
  • 28:25 - 28:29
    We're using Microsoft's
    Visual Studio Version 2005 on Windows,
  • 28:29 - 28:32
    we have an arrangement with Microsoft
    where they have distributed the software
  • 28:32 - 28:36
    free of charge to students, so if you would
    like to install that on your own Windows computer,
  • 28:36 - 28:38
    we'll give you some handouts on Friday that tell you
  • 28:38 - 28:44
    what to do to get the compiler
    and get it installed on your systems.
  • 28:44 - 28:48
    Our cluster computers in the dorms
    and the libraries and
  • 28:48 - 28:53
    the lair both operating systems have both
    the compilers and libraries installed,
  • 28:54 - 28:57
    so if you work in a cluster,
    you don't have to do anything special.
  • 28:57 - 29:04
    You just walk up and it's got the
    stuff ready to go.
  • 29:07 - 29:11
    I'm a Mac person. I've been a Mac
    person forever.
  • 29:11 - 29:13
    I can't get over the fact that you go to
    the start menu to shut the machine down.
  • 29:13 - 29:17
    That makes Windows impossible for me to use.
  • 29:19 - 29:25
    I would say campus wide, there are more
    Windows machines than Macs on campus,
  • 29:25 - 29:29
    So if you want to take a popular vote,
    You could do that.
  • 29:29 - 29:34
    If you want to be on the side of the Mac bigot,
    you can come and be with me in X Code.
  • 29:45 - 29:49
    I've got ten minutes to tell you a little
    bit about C++.
  • 29:49 - 29:54
    That is the next journey that we're
    going to go on together.
  • 29:54 - 29:57
    The first question is:
    Why are we doing this to you?
  • 29:57 - 30:02
    I just got comfortable with Java and now
    you're telling me to throw away my Java
    and start over.
  • 30:03 - 30:08
    Let's generate a little bit of love for C++.
  • 30:08 - 30:11
    The advantages of early multilingualism.
  • 30:11 - 30:14
    - I have two small children at home
    that are two and four,
  • 30:14 - 30:18
    and I read a lot about bilingualism.
  • 30:19 - 30:22
    It's very clear that for natural
    languages, when you're
  • 30:22 - 30:25
    acquiring a language at those
    young ages that that is the
  • 30:25 - 30:28
    best time to introduce a second
    or third language.
  • 30:28 - 30:31
    Where you are building the
    pathways and the neurons.
  • 30:32 - 30:35
    It's been looked at in terms of programming
    languages as well,
  • 30:35 - 30:38
    that when you are learning a programming
    language, there are certain kind
  • 30:38 - 30:41
    of ruts your mind gets into about
    the way a language is
  • 30:41 - 30:45
    that is based on your early experiences.
  • 30:45 - 30:49
    If you spend a very long time working
    only in one language, those ruts get deeper,
  • 30:49 - 30:52
    and you have a certain way of thinking.
    You're a little bit stuck in that paradigm and its approach.
  • 30:52 - 30:56
    What's easy to do in that language,
    what's hard to do in that language
  • 30:56 - 31:00
    tends to make a stronger impression on
    you in a way that makes it harder as you
  • 31:00 - 31:04
    grow and explore the languages to kind of get
    out of those ruts and shake yourself out of it.
  • 31:04 - 31:08
    There's been some pretty good evidence
    that somewhere between one
  • 31:08 - 31:11
    and two is a good time to think
    about branching out
  • 31:11 - 31:14
    and starting to think about different
    ways of doing stuff and seeing some
  • 31:14 - 31:20
    different syntax and some different ideas
    to help build in the flexibility from
  • 31:20 - 31:26
    an early age in your career to buy you
    some strength later.
  • 31:27 - 31:31
    That's part of what we're doing.
    Another part of it is actually that a lot of our upper division
  • 31:31 - 31:36
    courses rely on a knowledge of
    C and C++, that family of languages,
  • 31:36 - 31:39
    and that the longer we postpone it,
    the more painful it becomes.
  • 31:39 - 31:44
    In the later courses where you're learning
    about compilers or graphics or networking,
  • 31:44 - 31:48
    they don't have the time in those classes to stop and teach you C or C++.
  • 31:48 - 31:51
    They need you to know C++ to get the work done.
  • 31:51 - 31:55
    Moving the foundation into a programming class
  • 31:55 - 31:57
    seems to make the most sense in the context of our curriculum.
  • 31:57 - 32:00
    We do switch you over here.
  • 32:00 - 32:04
    The good news is that it's not as big a change as it might sound at first glance.
  • 32:04 - 32:07
    Java is actually highly derivative of C++ for a start.
  • 32:07 - 32:10
    They're kind of cousins in the scheme of language design.
  • 32:10 - 32:12
  • 32:12 - 32:14
    They have a lot of syntax.
  • 32:14 - 32:18
    How much C++ do you need to know to start?
    The answer is zero.
  • 32:18 - 32:21
    You don't even need to know what the word means.
  • 32:21 - 32:22
    In fact,
  • 32:22 - 32:25
    you actually probably know a surprising
    amount about C++ just by virtue of what
  • 32:25 - 32:28
    you already know just translated a little bit.
  • 32:28 - 32:32
    Things like the four loop of Java or the way you declare variables or
  • 32:32 - 32:35
    the way parameters are passed into a function
  • 32:35 - 32:39
    is exhibited in Java in very much the same way it is in C++.
  • 32:39 - 32:42
    There are a bunch of things you already know and you don't even realize.
  • 32:42 - 32:45
    It is not assumed that you know C or C++.
  • 32:46 - 32:49
    If you happen to already know those things,
    you're ahead of the game.
  • 32:50 - 32:52
    If you have not,
  • 32:52 - 32:54
    then not to worry.
  • 32:54 - 32:57
    How much C++ are you going to learn?
  • 32:58 - 33:00
    We will spend the first
  • 33:00 - 33:02
    three or four lectures
  • 33:02 - 33:05
    just talking about how things get expressed differently in C++
  • 33:05 - 33:07
    and mostly talking about
  • 33:07 - 33:12
    the differences in the libraries.
    The syntax itself is quite similar.
  • 33:12 - 33:15
    Some of the more extensive changes have to do with how the C++
  • 33:15 - 33:18
    string is operated on versus the Java string.
  • 33:18 - 33:20
    How you do file input and output reading
  • 33:20 - 33:23
    in C++ is a little bit different than the way it's done in Java.
  • 33:23 - 33:26
    We'll spend some time saying here are some things you know how to express in one language.
  • 33:26 - 33:29
    We're going to teach you how to express them in another language.
  • 33:29 - 33:31
    It's just mapping from your previous vocabulary onto a new one.
  • 33:32 - 33:35
    Along the way, we will actually introduce some of the C++
  • 33:35 - 33:38
    features that we need to support our pedagogical goals.
  • 33:38 - 33:42
    We'll be talking about how classes get designed in C++.
    We'll see how to use classes.
  • 33:44 - 33:45
    those classes, We'll see how to define
  • 33:45 - 33:49
    and we'll look at things like templates, which is the C++
  • 33:49 - 33:52
    construct for doing generics that you seen in Java - how you can build
  • 33:52 - 33:56
    containers that are type unspecific and things like that. We
  • 33:56 - 34:01
    will learn a little bit of some of the fancier features of C++ like
  • 34:01 - 34:02
    the pass by reference parameter,
  • 34:02 - 34:05
    but there's actually a very large amount of C++ that's just off the
  • 34:05 - 34:07
    table for us.
  • 34:07 - 34:11
    We will not make extensive use of the standard template library or
  • 34:11 - 34:13
    the
  • 34:13 - 34:17
    fancier features of 'static' and 'const' and a bunch of key words that
  • 34:17 - 34:20
    mean nothing to you and should mean nothing to you.
  • 34:20 - 34:23
    You will learn enough to have reading familiarity with
  • 34:23 - 34:26
    C++ and to be able to express yourself quite well in the subset we're using, but
  • 34:26 - 34:29
    it is a subset of C++ that you're being exposed
  • 34:32 - 34:35
    to.
  • 34:35 - 34:39
    If you find yourself really wanting to
  • 34:39 - 34:42
    master C++,
  • 34:46 - 34:48
    we are offering
  • 34:48 - 34:52
    CS106L. CS106L is a lab companion course that is
  • 34:52 - 34:55
    open to students enrolled in 106B or 106X.
  • 34:55 - 34:57
    It meets twice a week.
  • 34:57 - 34:59
    It's actually on Monday and Wednesday late afternoon.
  • 34:59 - 35:02
    It's 4:15 in Hewlett
  • 35:02 - 35:04
    103. It's being taught by a veteran section leader
  • 35:04 - 35:09
    who is very well versed in C++ and who of his own
  • 35:09 - 35:13
    volition volunteered and created this course because
  • 35:13 - 35:16
    he himself was a little frustrated as a prior 106 student
  • 35:16 - 35:19
    in wanting to get at some of those C++ things that weren't
  • 35:19 - 35:20
    fitting with our goals.
  • 35:20 - 35:23
    It is a place where you can
  • 35:23 - 35:26
    get more exposure to standard C++, do some exercises that help
  • 35:26 - 35:29
    you to test out those things and see how those things are expressed and get another
  • 35:29 - 35:32
    unit. It's a pass/fail lab course.
  • 35:32 - 35:35
    You can also just attend or grab the materials if you just want to look at
  • 35:35 - 35:35
    them.
  • 35:35 - 35:38
    It's a great way to
  • 35:41 - 35:43
    broaden that knowledge of C++ beyond what's
  • 35:43 - 35:48
    useful for us in terms of our goals. I'm going
  • 35:48 - 35:53
    to ask you some questions, because I don't get to do all the talking.
  • 35:53 - 35:56
    How much C++ do you need to know? Some of you may know nothing about it,
  • 35:56 - 35:58
    and that is perfectly fine. Some of you probably know something about it or at least
  • 35:58 - 36:02
    have heard something about it. I'm going to have you guys tell me
  • 36:02 - 36:04
    what it
  • 36:05 - 36:09
    is that people tell you about C++ that
  • 36:09 - 36:13
    makes you either excited to learn it or frightened to learn it or
  • 36:13 - 36:15
    interested in how it works. It's
  • 36:15 - 36:17
    what Java is based off of. It is what Java is
  • 36:17 - 36:20
    based
  • 36:20 - 36:24
    off of. That should be a little reassuring
  • 36:24 - 36:28
    that there is a syntax there that got adopted with some minor
  • 36:28 - 36:31
    changes. It should feel
  • 36:31 - 36:34
    more familiar than different when you look at it.
  • 36:34 - 36:37
    It was very strongly influenced by a generation of
  • 36:37 - 36:39
    programmers who C++ was their native language who designed the
  • 36:39 - 36:42
    Java language. That's a good thing to know. What else do you know
  • 36:42 - 36:47
    about C++?
  • 36:47 - 36:49
    It's extended
  • 36:50 - 36:53
    C. Yes. It's extended C. Here's how it fits in the spectrum.
  • 36:53 - 36:56
    C is kind of a 1970s creation. C++ is a
  • 36:56 - 36:58
    decade later.
  • 36:58 - 37:01
    C is the language which it is based on. It is an extended C. It's
  • 37:01 - 37:05
    called a superset. Everything that compiles and works in C
  • 37:05 - 37:07
    still exists in C++, but then they added a bunch of features.
  • 37:07 - 37:10
    Not only did they add a bunch of features but they tried to fix some of the things
  • 37:10 - 37:13
    about C++ by replacing existing things. For example, there's some
  • 37:13 - 37:17
    string handling in C that's kind of very primitive. They added a string
  • 37:17 - 37:18
    object
  • 37:18 - 37:22
    with much cleaner handling and safer semantics into the C++, but they kind of
  • 37:22 - 37:23
    left the old one around.
  • 37:23 - 37:26
    Some parts of C++ feel a little strange
  • 37:26 - 37:32
    because of this history to it - the legacy of incorporating everything C was plus the stuff
  • 37:32 - 37:35
    means at times there's a little bit of weirdness there. It also means
  • 37:35 - 37:39
    that the language, as a result, is very large.
  • 37:40 - 37:44
    C's
  • 37:44 - 37:47
    type safety
  • 37:47 - 37:52
    and runtime features were extended by what
  • 37:52 - 37:56
    got
  • 37:56 - 38:00
    added in C++. A friend of mine told me that [inaudible]. That's a
  • 38:07 - 38:08
    good thing
  • 38:08 - 38:09
    to know.
  • 38:09 - 38:13
    C++ might be a little bit more dangerous than Java.
  • 38:13 - 38:17
    That is true. Java is very
  • 38:17 - 38:21
    concerned with
  • 38:21 - 38:25
    safety, in particular since Java was designed for web
  • 38:25 - 38:27
    delivery of content. It was very important that the program have
  • 38:27 - 38:29
    very constrained
  • 38:29 - 38:31
    features on what it can and can't do,
  • 38:31 - 38:35
    and so as a result, Java tends to be very parental. When you
  • 38:35 - 38:38
    forget to initialize a variable or forget to
  • 38:38 - 38:39
    return from a function,
  • 38:39 - 38:41
    Java's
  • 38:41 - 38:45
    very aggressive about saying hey, you've got to fix this. C++ is a little
  • 38:46 - 38:47
    less
  • 38:47 - 38:51
    parental. Here's the overly protective mom, helicopter mom,
  • 38:51 - 38:54
    the ones who stand. That's Java. Java's making sure - oh, are you okay,
  • 38:54 - 38:57
    sweetie? Let me stand here
  • 38:57 - 39:01
    in case you fall. C++ is crack mom. She's like yeah, I'm over
  • 39:01 - 39:05
    here with my friends. Don't play
  • 39:05 - 39:06
    with
  • 39:06 - 39:08
    the kitchen knives.
  • 39:08 - 39:11
    It's a professional's tool,
  • 39:11 - 39:13
    and professionals don't want to feel encumbered. There are certain things they want
  • 39:13 - 39:16
    to do that require some of this
  • 39:16 - 39:19
    low-level access, and safety usually comes at a cost.
  • 39:19 - 39:23
    Any sort of feature where the language is double-checking for you is taking time and
  • 39:23 - 39:26
    efficiency. There's a cost associated with that. Every time you want
  • 39:26 - 39:28
    to get something out of an array,
  • 39:28 - 39:30
    it's checked to make sure that that number was
  • 39:30 - 39:34
    not off either end. Every array access costs you a little bit more.
  • 39:34 - 39:35
    C++ says
  • 39:35 - 39:38
    I'm not going to charge everybody that penalty. If you actually have the bad sense
  • 39:38 - 39:43
    to write a program that does those things, you deserve to be punished.
  • 39:43 - 39:47
    As a result, you will at some
  • 39:47 - 39:49
    point in this quarter get to experience some of that firsthand. Some of
  • 39:49 - 39:53
    it is a growth experience. Some
  • 39:53 - 39:56
    of it can be frustrating. It is part of what
  • 39:56 - 39:58
    professional tools often look like. They are making these tradeoffs
  • 39:58 - 40:01
    of efficiency over safety that
  • 40:01 - 40:04
    put more of the work back on you as the programmer to be a little more attentive on
  • 40:04 - 40:05
    those things.
  • 40:05 - 40:09
    You can write programs that crash in very spectacular ways
  • 40:09 - 40:14
    much more interesting and varied and dangerous than the kind of things you can do
  • 40:18 - 40:21
    in Java. Good to know. You want to
  • 40:21 - 40:29
    use
  • 40:29 - 40:29
    pointers.
  • 40:29 - 40:31
    You're going to get to use pointers.
  • 40:31 - 40:35
    Pointers are really neat, and they're also very challenging. Pointers are these
  • 40:35 - 40:37
    ways of building these very flexible and amazing
  • 40:37 - 40:40
    data structures - the kind of things that we're going to try to build. At some
  • 40:40 - 40:43
    point, they are going to be the only way to achieve those things well, so building
  • 40:43 - 40:46
    these things called trees, graphs and lists rely on understanding
  • 40:46 - 40:49
    a mastery of the pointer type. The pointer type is complicated, and it's part of
  • 40:49 - 40:51
    that danger thing, which is
  • 40:51 - 40:53
    having access to
  • 40:53 - 40:57
    rearranging memory by virtue of addresses opens up a lot of
  • 40:57 - 40:59
    opportunity for there to be mistakes.
  • 40:59 - 41:02
    Mistakes can be made in the passive voice
  • 41:02 - 41:06
    that have consequences. You'll get to experience firsthand what that's like.
  • 41:06 - 41:09
    There's joy in it, because getting it right is awesome, and there are things that you can
  • 41:09 - 41:12
    achieve that are really extraordinary with pointers, but
  • 41:12 - 41:13
    when it's not working,
  • 41:13 - 41:17
    it can
  • 41:17 - 41:18
    be frustrating. You're getting a
  • 41:18 - 41:22
    little
  • 41:22 - 41:25
    bit of both. It turns out C++ does not have a graphics system built
  • 41:25 - 41:26
    into it.
  • 41:26 - 41:29
    Java is actually distinguished from previous
  • 41:29 - 41:32
    languages. Java tries to solve all problems. Traditionally, a
  • 41:32 - 41:33
    programming language tends to have a set
  • 41:33 - 41:34
    of libraries that have
  • 41:34 - 41:38
    facilities for data management, reading and writing files and sometimes some
  • 41:38 - 41:42
    networking, but they don't tend to actually solve application layer problems. That
  • 41:42 - 41:46
    tended to be a different piece of technology. The Mac
  • 41:46 - 41:49
    OS might offer a graphics library that was written in C++, but C++
  • 41:49 - 41:50
    the language
  • 41:50 - 41:53
    didn't have a windowing system or graphics system.
  • 41:53 - 41:55
    C++ does not have those features
  • 41:55 - 41:56
    itself,
  • 41:56 - 41:58
    so any C++ compiler
  • 41:58 - 42:02
    you get comes with these basic things about handling files and managing these types of
  • 42:02 - 42:05
    data structures, but it does not come a priori with a bunch of graphics routines.
  • 42:05 - 42:07
    That said,
  • 42:07 - 42:09
    Windows and Mac and Linux and all these things have graphics routines that are
  • 42:09 - 42:12
    written in C++, but they're all different. To say what are they
  • 42:12 - 42:13
    like
  • 42:13 - 42:15
    relative to Java? They're all different relative
  • 42:15 - 42:16
    to Java. It's not standardized.
  • 42:18 - 42:21
    There's a wide variety of them out there, and
  • 42:21 - 42:24
    they tend to have a lot of very impressive and different solved
  • 42:24 - 42:27
    problems, because C++ has a longer history than Java that a lot
  • 42:27 - 42:30
    of problems have been solved in C++ that are available to you,
  • 42:30 - 42:32
    too. There's a lot of existing code
  • 42:32 - 42:36
    other than what you might think is standard.
  • 42:38 - 42:42
    I
  • 42:42 - 42:43
    will
  • 42:43 - 42:47
    see you on Friday, and we'll be seeing some C++. If you have
  • 42:47 - 42:58
    questions about your situation, come and talk to me now.
Title:
Lecture 1 | Programming Abstractions (Stanford)
Description:

The first lecture by Julie Zelenski for the Programming Abstractions Course (CS106B) in the Stanford Computer Science Department.

Julie Zelenski gives an introduction to the course, recursion, algorithms, dynamic data structures and data abstraction; she also introduced the significance of programming and gives her opinion of what makes 106B "great;" C++ is introduced, too.

Complete Playlist for the Course:
http://www.youtube.com/view_play_list?p=FE6E58F856038C69

CS 106B Course Website:
http://cs106b.stanford.edu

Stanford Center for Professional Development:
http://scpd.stanford.edu/

Stanford University:
http://www.stanford.edu/

Stanford University Channel on YouTube:
http://www.youtube.com/stanforduniversity/

more » « less
Video Language:
English
Duration:
43:03

English subtitles

Revisions